TUILiveListManager
Live room list relevant APIs. Functions on this page only support live room type (LIVE).
TUIRoomEngine version 3.0.0 starts support.
TUILiveListManager
Function API | Description |
Start live streaming. This API is supported from version v3.3.0. | |
Stop live streaming. This API is supported from version v3.3.0. | |
Join live stream. This API is supported from version v3.3.0. | |
Leave live stream. This API is supported from version v3.3.0. | |
Get live room list. | |
Modify live room information. | |
Get live room information. | |
Room Entry Preview video stream. This API is supported since v3.3.0. | |
Stop preview video stream. This API is supported since v3.3.0. | |
TUILiveListManagerEvents
Event API | Description |
Live room information has changed event. |
Type Definition
Type | Description |
Live room information. | |
Live room list query result. | |
Live room information modification struct. | |
Live stream stats. |
Function API Description
startLive
Note:
This API starts support from v3.3.0.
Start live streaming.
const liveInfo = {roomId: '123',roomType: TUIRoomType.kLive,name: 'ABC',notice: 'this is a description',isSeatEnabled: true,seatMode: TUISeatMode.kApplyToTake,seatLayoutTemplateId: 200,maxSeatCount: 8,coverUrl: '',backgroundUrl: '',categoryList: [],activityStatus: 1,isMessageDisableForAllUser: false,isGiftEnabled: false,isLikeEnabled: false,isPublicVisible: false,keepOwnerOnSeat: false,};const roomEngine = new TUIRoomEngine();const liveListManager = roomEngine.getLiveListManager();const resultLiveInfo = await liveListManager.startLive(liveInfo);console.log('Live stream started successfully, CDN stream address:', resultLiveInfo.cdnStreamUrl);
Parameter | Type | Required or Not | Default Value | Description |
liveInfo | Yes | - | Live room information, including room ID, name, notice, and configurations. |
stopLive
Note:
This API starts support from v3.3.0.
Stop live streaming.
try {const roomEngine = new TUIRoomEngine();const liveListManager = roomEngine.getLiveListManager();const statistics = await liveListManager.stopLive();console.log('Live streaming end, stats:', {Audience count: statistics.totalViewers,Total gifts: statistics.totalGiftsSent,Total likes: statistics.totalLikesReceived});} catch (error) {console.error('Stop live streaming failed: ', error);}
joinLive
Note:
This API starts support from v3.3.0.
Join live stream.
try {const roomEngine = new TUIRoomEngine();const liveListManager = roomEngine.getLiveListManager();const liveInfo = await liveListManager.joinLive('live_room_123');console.log('Join live room successful:', {roomName: liveInfo.name,roomNotice: liveInfo.notice,CDN stream address: liveInfo.cdnStreamUrl});} catch (error) {console.error('Failed to join the live room: ', error);}
Parameter | Type | Required or Not | Default Value | Description |
roomId | String | Yes | - | Live streaming room ID to join. |
leaveLive
Note:
This API starts support from v3.3.0.
Exit live streaming.
try {const roomEngine = new TUIRoomEngine();const liveListManager = roomEngine.getLiveListManager();await liveListManager.leaveLive();console.log('Exit live room successful.');} catch (error) {console.error('Failed to exit live room: ', error);}
Return Value: Promise<void>
fetchLiveList
Get live room list.
const roomEngine = new TUIRoomEngine();const liveListManager = roomEngine.getLiveListManager();const liveList = [];let cursor = '';let count = 20;let result;do {result = await liveListManager.fetchLiveList({ cursor, count });liveList.push(...result.liveInfoList);cursor = result.cursor;} while(cursor !== '');
Parameter | Type | Required or Not | Default Value | Description |
options | Object | Yes | - | Parameter Options |
options.cursor | String | Yes | '' | For pagination index retrieval, leave it blank on the first pull. If the returned data contains a non-empty cursor, it indicates pagination is required. Use the returned cursor as a parameter to call the API again until the cursor is empty, which means all data has been pulled. |
options.count | Number | Yes | - | Pull count this time. |
setLiveInfo
Modify live room information.
const roomEngine = new TUIRoomEngine();const liveListManager = roomEngine.getLiveListManager();liveListManager.setLiveInfo({roomId: "141569",coverUrl: "https://qcloudimg.tencent-cloud.cn/image/document/live-cover.png",isPublicVisible: false,activityStatus: 1,categoryList: [1,2,3],backgroundUrl: "https://qcloudimg.tencent-cloud.cn/image/document/live-cover.png"});
Parameter | Type | Required or Not | Default Value | Description |
options | Object | Yes | - | Parameter Options |
options.roomId | String | Yes | - | Live streaming room ID. |
options.activityStatus | Number | No | - | Live streaming room active status: user custom tag. |
options.categoryList | Array | No | - | Live room category tags, a single room supports up to 3 tags. |
options.coverUrl | String | No | - | Live room cover image HTTP URL address, supports up to 200 bytes. |
options.backgroundUrl | String | No | - | Live room background image HTTP URL address, supports up to 200 bytes. |
options.isPublicVisible | Boolean | No | - | Whether the live room is public. |
options.seatLayoutTemplateId | Number | No | - | Live streaming room mic layout template ID. |
Return Value: Promise<void>
getLiveInfo
Get live room information.
const roomEngine = new TUIRoomEngine();const liveListManager = roomEngine.getLiveListManager();const result = await liveListManager.getLiveInfo({ roomId: "141569" });
Parameter | Type | Required or Not | Default Value | Description |
options | Object | Yes | - | Parameter Options |
options.roomId | String | Yes | - | Live streaming room ID. |
startPreloadVideoStream
Room Entry Preview video stream.
const roomEngine = new TUIRoomEngine();const liveListManager = roomEngine.getLiveListManager();await liveListManager.startPreloadVideoStream({roomId: "live_room_123",isMuteAudio: false,view: "previewVideoContainer"});
Parameter | Type | Required or Not | Default Value | Description |
options | Object | Yes | - | Parameter Options |
options.roomId | String | Yes | - | Room ID. |
options.isMuteAudio | Boolean | Yes | - | Whether to mute the preview. |
options.view | String | Yes | - | Play video stream area. |
Return Value: Promise<void>
stopPreloadVideoStream
Stop preview video stream.
const roomEngine = new TUIRoomEngine();const liveListManager = roomEngine.getLiveListManager();await liveListManager.stopPreloadVideoStream({roomId: "live_room_123"});
Parameter | Type | Required or Not | Default Value | Description |
options | Object | Yes | - | Parameter Options |
options.roomId | String | Yes | - | Room ID. |
Return Value: Promise<void>
on
const roomEngine = new TUIRoomEngine();const liveListManager = roomEngine.getLiveListManager();const callback = ({ liveModifyInfo }) => {console.log('liveListManager.onLiveInfoChanged', liveModifyInfo);};liveListManager.on(TUILiveListManagerEvents.onLiveInfoChanged, callback);
Parameter | Type | Required or Not | Default Value | Description |
eventName | Yes | - | Event name. | |
func | (...args: any[]) => void | Yes | - | Event handler. |
off
const roomEngine = new TUIRoomEngine();const liveListManager = roomEngine.getLiveListManager();const callback = ({ liveModifyInfo }) => {console.log('liveListManager.onLiveInfoChanged', liveModifyInfo);};liveListManager.off(TUILiveListManagerEvents.onLiveInfoChanged, callback);
Parameter | Type | Required or Not | Default Value | Description |
eventName | Yes | - | Event name. | |
func | (...args: any[]) => void | Yes | - | Event handler. |
Event API Detail
onLiveInfoChanged
Live room information has changed event.
const roomEngine = new TUIRoomEngine();const liveListManager = roomEngine.getLiveListManager();liveListManager.on(TUILiveListManagerEvents.onLiveInfoChanged, ({ liveModifyInfo}) => {console.log('liveListManager.onLiveInfoChanged', liveModifyInfo);});
Parameter | Type | Description |
options | Object | Parameter Options |
options.liveModifyInfo | Modify live room information. |
Type Definition Details
TUILiveInfo
Attribute | Type | Description |
roomId | String | Live streaming room ID. |
roomType | The live streaming room type can only be TUIRoomType.kLive. | |
name | String | Live room name. |
notice | String | Live room notice. |
isMessageDisableForAllUser | Boolean | Whether to mute all users from sending text and emoji messages. |
isGiftEnabled | Boolean | Whether sending gifts is supported in the live streaming room. |
isLikeEnabled | Boolean | Whether liking is supported in the live streaming room. |
isPublicVisible | Boolean | Whether the live room is public. |
isSeatEnabled | Boolean | Whether the voice chat seat is supported in the live streaming room. |
keepOwnerOnSeat | Boolean | Whether the host always stays on mic in the live streaming room. |
seatLayoutTemplateId | Number | Live streaming room mic layout template ID. |
maxSeatCount | Number | Maximum number of microphones in the live streaming room. |
seatMode | Seat mode in live streaming room. | |
coverUrl | String | Live room cover image HTTP URL address, supports up to 200 bytes. |
backgroundUrl | String | Live room background image HTTP URL address, supports up to 200 bytes. |
categoryList | Array | Live room category tags, a single room supports up to 3 tags. |
activityStatus | Number | Live streaming room active status: user custom tag. |
roomOwner | String | Live streaming room owner ID, read-only. |
ownerName | String | Live streaming room owner username, read-only. |
ownerAvatarUrl | String | Live streaming room owner profile photo URL, read-only. |
createTime | Number | Live streaming room creation time in milliseconds, read-only. |
totalViewers | Number | Total view count, read-only. |
isUnlimitedRoomEnabled | Boolean | Whether unlimited rooms are supported, read-only. |
cdnStreamUrl | String | Live streaming URL, read-only. |
lebSecretKey | String | Live stream encryption key, read-only. |
lebEncrypted | String | Live stream encrypted information, read-only. |
lebSignature | String | Live stream encrypted signature, read-only. |
TUILiveListResult
Attribute | Type | Description |
cursor | String | List index. |
listInfoList | Pulled live room list. |
TUILiveModifyInfo
Attribute | Type | Description |
roomId | String | Live streaming room ID. |
isPublicVisible | Boolean | Selectable. Whether the live room is public. |
activityStatus | Number | Selectable. Live streaming room active status: user custom tag. |
coverUrl | String | Selectable. Live room cover image HTTP URL address, supports up to 200 bytes. |
backgroundUrl | String | Selectable. Live room background image HTTP URL address, supports up to 200 bytes. |
categoryList | Array | Option, live room category tags, a single room supports up to 3 tags. |
TUILiveStatisticsData
Attribute | Type | Description |
totalViewers | Number | Audience count. |
totalGiftsSent | Number | Total gifts sent. |
totalGiftCoins | Number | Total gift value. |
totalUniqueGiftSenders | Number | Total gift senders. |
totalLikesReceived | Number | Total likes. |