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

iOS
Android
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
Whether the live room is public, set to true and it can be displayed in the room list.
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
Whether the live room is public, set to true and it can be displayed in the room list.
After preparing TUILiveInfo, you can call setLiveInfo API to set live room information.
Example:
iOS
Android
import RTCRoomEngine

let roomEngine = TUIRoomEngine.sharedInstance()
let liveListManager = roomEngine.getExtension(extensionType: .liveListManager) as? TUILiveListManager

let liveInfo = TUILiveInfo()
liveInfo.backgroundUrl = "backgroundUrl" // Replace with the live room background image you need
liveInfo.coverUrl = "coverUrl" // Replace with the live room cover image you need
liveInfo.isPublicVisible = true // Live streaming room is public
liveInfo.categoryList = [1, 2] // Can be replaced with the live room categories in your business

let modifyFlag: TUILiveModifyFlag = [.backgroundUrl,.coverUrl,.publish,.category] // Categories modified here

liveListManager?.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 need
liveInfo.coverUrl = "coverUrl"; // Replace with the live room cover image you need
liveInfo.isPublicVisible = true; // Live streaming room is public
liveInfo.categoryList = new ArrayList<>(Arrays.asList(1, 2)); // Can be replaced with the live room categories in your business


List<TUILiveListManager.LiveModifyFlag> modifyFlag = new ArrayList<>();
// Following are the categories modified by you
modifyFlag.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() {
@Override
public void onSuccess() {
// Successfully set live room information
}
@Override
public 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:
iOS
Android
import RTCRoomEngine

let roomEngine = TUIRoomEngine.sharedInstance()
let name = "New Name" //Replace with your real username
roomEngine.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 newName
roomEngine.updateRoomNameByAdmin(newName ,new TUIRoomDefine.ActionCallback() {
@Override
public void onSuccess() {
//Room name modified successfully
}

@Override
public 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:
iOS
Android
import RTCRoomEngine

let 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 updated
HashMap<String, String> metadataToUpdate = new HashMap<>(); // Fill in the key-value pairs you want
metadataToUpdate.put("is_recording", "true"); // Set whether recording in progress, here just for example

roomEngine.setRoomMetadataByAdmin(metadataToUpdate, new TUIRoomDefine.ActionCallback() {
@Override
public void onSuccess() {
// Callback for successful setting
}

@Override
public 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:
iOS
Android
import RTCRoomEngine

let 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 query
roomEngine.getRoomMetadata(keysToQuery, new TUIRoomDefine.GetRoomMetadataCallback() {
@Override
public void onSuccess(Map<String, String> metadata) {
// Successful callback
}

@Override
public void onError(int errorCode, String errorMessage) {
// Callback failure
}
});