TUILiveLayoutManager
Live streaming custom layout relevant APIs. Functions on the page only support the live room type (LIVE).
TUILiveLayoutManager
Function API | Description |
Set custom layout info | |
TUILiveLayoutManagerEvents
Event API | Description |
Live stream layout change event | |
Mic position layout has changed event |
Type Definition
Type | Description |
Live streaming room mic layout | |
Mic layout info | |
Media status of on-mic user |
Function API Description
setLiveStreamLayoutInfo
Set custom layout info.
const roomEngine = new TUIRoomEngine();const liveLayoutManager = roomEngine.getLiveLayoutManager();const layoutData = {// Set the canvas sizeVideoEncode: {Width: 1920,Height: 1080,},LayoutMode: 1000, // 0~9 built-in layout template, 1000 for custom layout, LayoutInfo property is valid only when set to 1000// Set screen layoutLayoutInfo: {LayoutList: [{LocationX: 0, // x coordinate with the top-left corner of the frame as the origin pointLocationY: 0, // y coordinate with the top-left corner of the frame as the origin pointImageWidth: 1080, // Adjusted frame widthImageHeight: 960, // Adjusted screen heightZOrder: 0, // Frame layer, value ranges from 0 to +∞StreamType: 0, // 0 camera, 1 screen sharing, 2 whiteboard, 3 customMember_Account: 'admin001', // User ID of this streamBackgroundImageUrl: 'ImageUrl', // can be emptyRoomId: 'roomId',BackgroundColor: '0x1F212C', // nullable},],},// Set maximum screen layout infoMaxUserLayout: {LocationX: 0, // x coordinate with the top-left corner of the frame as the origin pointLocationY: 0, // y coordinate with the top-left corner of the frame as the origin pointImageWidth: 1920, // Adjusted frame widthImageHeight: 1080, // Adjusted screen heightZOrder: 0, // Frame layer, the maximum recommended layer is 0StreamType: 0, // 0 camera, 1 screen sharingMember_Account: 'admin001', // User ID of this streamBackgroundImageUrl: 'ImageUrl', // can be set, may not function on large screenRoomId: 'roomId',BackgroundColor: '0x1F212C'},};const roomId = 'roomId';const layoutInfo = JSON.stringify(layoutData);await liveLayoutManager.setLiveStreamLayoutInfo(roomId, layoutInfo);
Note:
layoutData object, all Key values are in Big Camel Hump.
Currently, the LayoutMode attribute value supports only 0 and 1000.
Only when LayoutMode is set to 1000, the LayoutInfo property is valid. When LayoutMode is 0~9, the LayoutInfo and VideoEncode attributes are not required to input.
LayoutInfo.LayoutList is an array that can be configured to set the layout of video images.
Parameter | Type | Required or Not | Default Value | Description |
roomId | String | Yes | - | Live streaming room ID. |
layoutInfo | String | Yes | - | Custom layout info in JSON string format. |
Return value: Promise<void>
on
const roomEngine = new TUIRoomEngine();const liveLayoutManager = roomEngine.getLiveLayoutManager();const callback = (roomId, layoutInfo) => {console.log('liveLayoutManager.onLiveVideoLayoutChanged', roomId, layoutInfo);};liveLayoutManager.on(TUILiveLayoutManagerEvents.onLiveVideoLayoutChanged, callback);
Parameter | Type | Required or Not | Default Value | Description |
eventName | Yes | - | Event name. | |
func | (...args: any[]) => void | Yes | - | event handler |
Return value: void
off
const roomEngine = new TUIRoomEngine();const liveLayoutManager = roomEngine.getLiveLayoutManager();const callback = (roomId, layoutInfo) => {console.log('liveLayoutManager.onLiveVideoLayoutChanged', roomId, layoutInfo);};liveLayoutManager.off(TUILiveLayoutManagerEvents.onLiveVideoLayoutChanged, callback);
Parameter | Type | Required or Not | Default Value | Description |
eventName | Yes | - | Event name. | |
func | (...args: any[]) => void | Yes | - | event handler |
Return value: void
Event API Detail
onLiveVideoLayoutChanged
Live stream layout change event.
const roomEngine = new TUIRoomEngine();const liveLayoutManager = roomEngine.getLiveLayoutManager();liveLayoutManager.on(TUILiveLayoutManagerEvents.onLiveVideoLayoutChanged, (roomId, layoutInfo) => {console.log('liveLayoutManager.onLiveVideoLayoutChanged', roomId, layoutInfo);});
Parameter | Type | Description |
roomId | String | room ID. |
layoutInfo | String | Latest screen layout info. |
onSeatLayoutChanged
Mic position layout has changed event.
const roomEngine = new TUIRoomEngine();const liveLayoutManager = roomEngine.getLiveLayoutManager();liveLayoutManager.on(TUILiveLayoutManagerEvents.onSeatLayoutChanged, ({ roomId, seatLayout }) => {console.log('liveLayoutManager.onSeatLayoutChanged', roomId, seatLayout);});
Parameter | Type | Description |
options | Object | Parameter Options. |
options.roomId | String | room ID. |
options.seatLayout | Mic layout info. |
Type Definition Details
TUISeatLayout
Attribute | Type | Description |
templateId | Number | Mic layout template ID. |
canvasWidth | Number | Mic layout canvas width. |
canvasHeight | Number | Mic layout canvas height. |
regions | Mic layout area list |
TUISeatRegion
Attribute | Type | Description |
roomId | String | Live streaming room ID. |
seatIndex | Number | Mic serial number. |
isSeatLocked | Boolean | Indicates the lock status. |
userId | String | user ID. |
userName | String | username. |
userAvatar | String | user profile photo. |
userMicrophoneStatus | User mic status. | |
userCameraStatus | User camera status. | |
x | Number | Mic X coordinate. |
y | Number | Mic Y coordinate. |
width | Number | Mic width. |
height | Number | Mic height. |
zorder | Number | Mic Z-axis sequence. |
TUIDeviceStatus
Attribute | Type | Description |
TUIDeviceStatusOpened | Number | The current device is in open status. |
TUIDeviceStatusClosedBySelf | Number | The current device is closed due to user-initiated closure. |
TUIDeviceStatusClosedByAdmin | Number | The current device is closed due to forcible close by the room owner/admin. |