In the live streaming business, hosts and viewers usually need to interact in real time through various means such as on-screen comments and chat. However, integration of such features is complex. This document uses IM as an example to describe how to implement requirements such as on-screen comments, chat, and item recommendations during live streaming as well as possible problems and considerations, giving a glimpse of the live streaming business and requirements.
|Live on-screen comments, gifts, and likes||Hundreds of millions of concurrent messages can be sustained to build a friendly interaction experience.|
|Various chat modes such as one-to-one and group live chat||Users can send messages and receive messages from other members in the same chat room. Diverse message types such as text, images, audio, and short videos can be pushed in real time, which encourages more user activity.|
|Item push in live shopping||In live shopping scenarios, when the host recommends an item, it needs to be immediately displayed in the item slot at the bottom of the screen and notified to all viewers. Notifications of new items are generally triggered by the virtual assistant.|
|Broadcast in a live room||The broadcast feature is similar to a system notice sent to live rooms. When the system admin delivers a broadcast message, all the live rooms under the
To set up a live room in Tencent Cloud, you need to create an IM application in the console as shown below:
The application created in step 1 is the Free edition, which applies only to development. In the production environment, you need to activate the Pro or Ultimate edition as needed. For more information on differences between different editions, see Pricing.
In live streaming scenarios, you need some extra configurations after creating the application.
UserSigwith a key
UserSigin the console as shown below:
administrator. You can also create multiple admin accounts as needed. Note that you can create up to five admin accounts.
After completing the preparations, you need to integrate the IM and TRTC client SDKs into your project. You can select different integration options as needed. For detailed directions, see Get Started.
The following describes common features in a live room and provides best practices with implementation code.
Therefore, you can select AVChatRoom as the Group type for the live room based on the group characteristics of IM as described in Group System. IM audio-video groups (
AVChatRoom) have the following characteristics:
The IM SDK for web allows users to join only one audio-video group (
AVChatRoom) at a time. If a user logs in to an client and enters live room A, multi-client login is enabled in the console, and the user logs in to another client and enters live room B, the user will be removed from live room A.
AVChatRoom) support on-screen comments, gifts, and like messages to build a friendly interaction experience.
99included in the parameter.
Item push in live shopping
When the host recommends an item, it needs to be immediately displayed in the item slot at the bottom of the screen and notified to all viewers. Notifications of new items are generally triggered by the virtual assistant. We recommend you implement notifications of new items by enabling the admin to modify a custom group field as follows:
Add a custom group field
Log in to the IM console, click the target IM application card, and select Feature Configuration > Group configuration on the left sidebar.
On the Custom Group Field page, click Add in the top-right corner.
In the pop-up dialog box, enter a field name and set the group types and read/write permissions.
- The field name can contain up to 16 characters, supporting letters, digits, and underscores (_). It cannot begin with a digit.
- A custom group field and a custom group member field cannot have the same name.
Select I understand that after a custom group field is added, only the read-write permissions of the added group type can be modified; the group type cannot be reselected or deleted; the field cannot be deleted. and click Confirm.
The custom group field will take effect in about ten minutes after configuration.
Use the custom group field
The virtual assistant calls the RESTful API for modifying the profile of a group as the group admin at an appropriate time to update the custom group field, so as to send notifications of new items and notifications of live streaming status change in the live room.
Broadcast in a live room
The broadcast feature is similar to a system notice feature in the live room, but it differs from the latter in that it belongs to messaging. When the system admin delivers a broadcast message, all the live rooms under the
SDKAppID will receive it.
The broadcast feature is currently available only for the Ultimate edition and needs to be enabled in the console. For more information on how to send a broadcast message on the business backend, see Broadcast Message of Audio-Video Group.
If you are not an Ultimate edition user, you can implement the feature by sending a custom group message on the server.
To implement more live room features such as user identity, user level, historical messages, and displaying the number of online users, see Live Room Setup Guide.