Live Room Information Settings
This document primarily introduces how to use the
RTC Room Engine
SDK to implement custom room information.Prerequisites
Before using the
RTC RoomEngine
SDK, you need to first call the Log In SDK so that subsequent features can be used normally.The set live room information is effective only when you are the host. You can refer to Audio Live Broadcast or Video Live Broadcast to complete the creation of the live room.
User Guide
Note:
When using the custom room information feature, please ensure that you are the room owner or administrator.
Setting Room Information
You need to prepare the parameter set
TUILiveInfo
. Next, we will provide a detailed introduction:Parameter: TUILiveInfo
TUILiveInfo
is composed of many fields, but you only need to care about filling in the following fields:Parameter Name | Type | Description |
activityStatus | Int | Live streaming room active status: user-customized tag |
backgroundUrl | String | Live room background, supports up to 200 bytes |
categoryList | List<Int> | Live room category tags, a single room supports up to 3 tags |
coverUrl | String | Live room cover, supports up to 200 bytes |
isPublicVisible | Bool |
After preparing TUILiveInfo, you can call
setLiveInfo
API to set live room information.You need to prepare the parameter set
LiveInfo
. Next, we will provide a detailed introduction:Parameter: LiveInfo
LiveInfo
is composed of many fields, but you only need to care about filling in the following fields:Parameter Name | Type | Description |
activityStatus | Int | Live streaming room active status: user-customized tag |
backgroundUrl | String | Live room background, supports up to 200 bytes |
categoryList | List<Int> | Live room category tags, a single room supports up to 3 tags |
coverUrl | String | Live room cover, supports up to 200 bytes |
isPublicVisible | Bool |
After preparing TUILiveInfo, you can call
setLiveInfo
API to set live room information.Example:
import RTCRoomEnginelet roomEngine = TUIRoomEngine.sharedInstance()let liveListManager = roomEngine.getExtension(extensionType: .liveListManager) as? TUILiveListManagerlet liveInfo = TUILiveInfo()liveInfo.backgroundUrl = "backgroundUrl" // Replace with the live room background image you needliveInfo.coverUrl = "coverUrl" // Replace with the live room cover image you needliveInfo.isPublicVisible = true // Live streaming room is publicliveInfo.categoryList = [1, 2] // Can be replaced with the live room categories in your businesslet modifyFlag: TUILiveModifyFlag = [.backgroundUrl,.coverUrl,.publish,.category] // Categories modified hereliveListManager?.setLiveInfo(liveInfo, modifyFlag: modifyFlag) {// Successfully set live room information} onError: { code, message in// Fail to set live room information}
TUIRoomEngine roomEngine = TUIRoomEngine.sharedInstance();TUILiveListManager liveListManager = (TUILiveListManager) roomEngine.getExtension(TUICommonDefine.ExtensionType.LIVE_LIST_MANAGER);TUILiveListManager.LiveInfo liveInfo = new TUILiveListManager.LiveInfo();liveInfo.backgroundUrl = "backgroundUrl"; // Replace with the live room background image you needliveInfo.coverUrl = "coverUrl"; // Replace with the live room cover image you needliveInfo.isPublicVisible = true; // Live streaming room is publicliveInfo.categoryList = new ArrayList<>(Arrays.asList(1, 2)); // Can be replaced with the live room categories in your businessList<TUILiveListManager.LiveModifyFlag> modifyFlag = new ArrayList<>();// Following are the categories modified by youmodifyFlag.add(TUILiveListManager.LiveModifyFlag.BACKGROUND_URL);modifyFlag.add(TUILiveListManager.LiveModifyFlag.COVER_URL);modifyFlag.add(TUILiveListManager.LiveModifyFlag.PUBLISH);modifyFlag.add(TUILiveListManager.LiveModifyFlag.CATEGORY);liveListManager.setLiveInfo(liveInfo, modifyFlag, new TUIRoomDefine.ActionCallback() {@Overridepublic void onSuccess() {// Successfully set live room information}@Overridepublic void onError(TUICommonDefine.Error error, String message) {// Fail to set live room information}});
Modifying Room Name
Use the
updateRoomNameByAdmin
API to modify the room name. The SDK will notify users in the room through the onRoomNameChanged
callback.This function can only be called by the room owner or administrator.
Example:
import RTCRoomEnginelet roomEngine = TUIRoomEngine.sharedInstance()let name = "New Name" //Replace with your real usernameroomEngine.updateRoomNameByAdmin(roomName: newName) {//Room name modified successfully} onError: { code, message in//Failed to modify room name}
TUIRoomEngine roomEngine = TUIRoomEngine.sharedInstance();String newName = ""; //Replace with your required newNameroomEngine.updateRoomNameByAdmin(newName ,new TUIRoomDefine.ActionCallback() {@Overridepublic void onSuccess() {//Room name modified successfully}@Overridepublic void onError(TUICommonDefine.Error error, String message) {//Room name modified successfully}});
Customizing Room Information
Use the
setRoomMetadataByAdmin
API to set custom room information. If the attribute exists, update its value; if not, add the attribute.This function can only be called by the room owner or administrator, and this function only supports live room type
Live
.Example:
import RTCRoomEnginelet roomEngine = TUIRoomEngine.sharedInstance()roomEngine.setRoomMetadataByAdmin([key:value], onSuccess: {//Succeed in setting custom data.}, onError: {code ,message in//Fail to set custom data.})
TUIRoomEngine roomEngine = TUIRoomEngine.sharedInstance();// Prepare the metadata key-value pairs to be set or updatedHashMap<String, String> metadataToUpdate = new HashMap<>(); // Fill in the key-value pairs you wantmetadataToUpdate.put("is_recording", "true"); // Set whether recording in progress, here just for exampleroomEngine.setRoomMetadataByAdmin(metadataToUpdate, new TUIRoomDefine.ActionCallback() {@Overridepublic void onSuccess() {// Callback for successful setting}@Overridepublic void onError(int errorCode, String errorMessage) {// Callback for setting failure}});
Retrieve Custom Room Information
After setting the custom information, you can call
getRoomMetadata
API to get all or specified information of the current live streaming room.This function can only be called by the room owner or administrator, and this function only supports live room type
Live
.Example:
import RTCRoomEnginelet roomEngine = TUIRoomEngine.sharedInstance()let keys: [String] = [""] // Parameter passing for room custom information key list. If keys is empty, obtain all custom information.roomEngine.getRoomMetadata(array) { metadata in//Succeed in obtaining custom information.} onError: { code, message in//Fail to obtain custom information.}
TUIRoomEngine roomEngine = TUIRoomEngine.sharedInstance();List<String> keysToQuery = new ArrayList<>(); //Replace with the list you want to queryroomEngine.getRoomMetadata(keysToQuery, new TUIRoomDefine.GetRoomMetadataCallback() {@Overridepublic void onSuccess(Map<String, String> metadata) {// Successful callback}@Overridepublic void onError(int errorCode, String errorMessage) {// Callback failure}});