The interactive barrage feature is a crucial real-time communication tool, supporting various interactive methods. Users can input emojis in the barrage to enhance the entertainment value of messages, making the interactive experience more enjoyable and vivid. Through this feature, the audience can engage in richer communication with anchors and other viewers during live streaming, boosting the overall sense of participation and fun. The TUILiveKit has already implemented the interactive barrage feature through Chat.
Use Instructions
Display barrage
Send barrage
Note:
1. Supports switching between System Keyboard and Emoji Keyboard.
2. To respect the copyright of emoji designs, the TUILiveKit project does not include large emoji elements. Before the official commercial launch, please replace them with your own designed or copyrighted emoji packs. The default Little Yellow Face Emoji Pack shown below is copyrighted by Tencent Cloud and can be licensed for a fee. If you need authorization, please submit a ticket to contact us.
Feature customization
Customize message style
The barrage display component TUIBarrageDisplayView provides setAdapter and TUIBarrageDisplayAdapter for customizing the pop-up message Item style. If you need the Self Definition message view, please refer to the following path for changes.
// Handling of custom style 1LinearLayout ll =newLinearLayout(mContext);
ll.addView(newTextView(mContext));returnnewGiftViewHolder(ll);}returnnull;}@OverridepublicvoidonBindViewHolder(RecyclerView.ViewHolder holder,TUIBarrage barrage){if(holder instanceofGiftViewHolder){GiftViewHolder viewHolder =(GiftViewHolder) holder;
viewHolder.bind(barrage);}}@OverridepublicintgetItemViewType(int position,TUIBarrage barrage){if(...){// If the current barrage requires a custom Item style, return the corresponding style type.return GIFT_VIEW_TYPE_1;}return0;// 0 indicates that the default style is used}privatestaticclassGiftViewHolderextendsRecyclerView.ViewHolder{publicGiftViewHolder(View itemView){super(itemView);// ...}publicvoidbind(TUIBarrage barrage){// ...}}}
Supports multiple custom styles (specified by multiple return values throughgetItemViewType ), 0 represents the default style.
Insert Custom Message
The barrage display component TUIBarrageDisplayView provides the external interface method insertBarrages for inserting custom messages (in batches). Custom messages are usually used in combination with custom styles to achieve different display effects.
// Example: Insert a gift message in the barrage area.