setLocalVideoView to set the local video preview control.openLocalCamera API to start camera preview. This API requires the input of both parameters isFront and quality.isFront Select front or rear camera. It is a boolean value: true opens the front camera, false opens the rear camera.quality Video quality. This parameter is an enumeration of type TUIVideoQuality. We recommend you select quality720P or quality1080P.1080P video quality.import RTCRoomEngine// Step 1: Set the local video preview controllet videoView = UIView()// ...Add videoView to your view and perform layoutTUIRoomEngine.sharedInstance().setLocalVideoView(view: videoView)// Step 2: Open front camera previewlet isFrontCamera = truelet videoQuality: TUIVideoQuality = .quality1080PTUIRoomEngine.sharedInstance().openLocalCamera(isFront: isFrontCamera, quality: videoQuality) {// Open front camera successfully} onError: { code, message in// Open front camera failed}
// Step 1: Set the local video preview controlTUIVideoView videoView = new TUIVideoView(context);// ...Add videoView to your view and perform layoutTUIRoomEngine.sharedInstance().setLocalVideoView(videoView);// Step 2: Open front camera previewboolean isFrontCamera = true;TUIRoomDefine.VideoQuality videoQuality = TUIRoomDefine.VideoQuality.Q_1080P;TUIRoomEngine.sharedInstance().openLocalCamera(isFrontCamera, videoQuality, new TUIRoomDefine.ActionCallback() {@Overridepublic void onSuccess() {// Open front camera successfully}@Overridepublic void onError(TUICommonDefine.Error error, String message) {// Open front camera failed}});
TUIRoomEngine.once('ready', () => {const roomEngine = TUIRoomEngine.getInstance();await roomEngine.setLocalVideoView({streamType: TUIVideoStreamType.kCameraStream,view: 'preview-camera', // view is the id of the div element for playing local user stream});await roomEngine.updateVideoQuality({ quality: TUIVideoQuality.kVideoQuality_1080p });await roomEngine.openLocalCamera();});
openLocalMicrophone API to turn on microphone collection. This API requires the input of audio quality parameter quality. This parameter is an enumeration value of TUIAudioQuality data type. We recommend you select default mode. The following example shows how to start local microphone capture with default audio quality.import RTCRoomEngine// Open local microphonelet audioQuality: TUIAudioQuality = .defaultTUIRoomEngine.sharedInstance().openLocalMicrophone(audioQuality) {// Microphone turned on successfully} onError: { code, message in// Failed to open microphone}
// Open local microphoneTUIRoomDefine.AudioQuality audioQuality = TUIRoomDefine.AudioQuality.DEFAULT;TUIRoomEngine.sharedInstance().openLocalMicrophone(audioQuality, new TUIRoomDefine.ActionCallback() {@Overridepublic void onSuccess() {// Microphone turned on successfully}@Overridepublic void onError(TUICommonDefine.Error error, String message) {// Failed to open microphone}});
TUIRoomEngine.once('ready', () => {const roomEngine = TUIRoomEngine.getInstance();await roomEngine.updateAudioQuality({ quality: TUIAudioQuality.kAudioProfileDefault });await roomEngine.openLocalMicrophone();});
unlimitedRoom parameter. Advanced functions such as video preview, instant playback, and multi-template stream mixing require this parameter to be enabled to use.var jsonObject = [String: Any]()jsonObject["api"] = "enableUnlimitedRoom"var params = [String: Any]()params["enable"] = truejsonObject["params"] = paramsif let jsonData = try? JSONSerialization.data(withJSONObject: jsonObject, options: []),let jsonString = String(data: jsonData, encoding: .utf8) {TUIRoomEngine.callExperimentalAPI(jsonStr: jsonString)}
JSONObject jsonObject = new JSONObject();JSONObject params = new JSONObject();try {jsonObject.put("api", "enableUnlimitedRoom");params.put("enable", true);jsonObject.put("params", params);TUIRoomEngine.sharedInstance().callExperimentalAPI(jsonObject.toString());} catch (JSONException e) {}
await TUIRoomEngine.callExperimentalAPI(JSON.stringify({api: 'enableUnlimitedRoom',params: {enable: true,},}));
unlimitedRoom parameter with the example code above, you still need to activate the TUILiveKit service for the changes to take effect. Refer to the activation instructions to complete the TUILiveKit service activation.TUILiveInfo. Next, we'll provide detailed introduction:Parameter Name | Field Description | Additional Notes | Data Type | Fill Example |
roomId | room ID | Only allow a combination of uppercase and lowercase letters (a-z, A-Z), digits (0-9), underline, and hyphen. This field is a required parameter when creating a room and supports up to 48 bytes. | String | "live_100001" |
name | room name | room name of string type (same as roomId if left empty) | String | "live room" |
isSeatEnabled | Whether microphone position control is enabled | Boolean type microphone position control enable flag. | Boolean value | true |
seatMode | Microphone mode | This field takes effect only after enabling microphone position control. Divided into freeToTake and applyToTake. In freeToTake mode, the audience can freely join the podium without applying. In applyToTake mode, the audience must obtain the room owner's approval to become a speaker. | Enumeration Value | TUISeatMode .applyToTake |
maxSeatCount | maximum number of microphone slots | The maximum number of microphone slots for the number type, indicating up to maxSeatCount people can be online simultaneously. The maximum number of microphone slots matches the purchased package's cap on mic-on users. | Digits | 10 |
isPublicVisible | Whether the live room is public | Set to true to display in the room list. | Boolean value | true |
keepOwnerOnSeat | Host starts broadcasting and automatically becomes a speaker | If you are in a live streaming scenario, it is strongly recommended to set keepOwnerOnSeat to true, otherwise you must takeSeat to go live normally. | Boolean value | true |
TUILiveListManager plug-in's startLive API to start live streaming.import RTCRoomEnginelet liveInfo = TUILiveInfo()liveInfo.roomId = "video_100001" // Replace with your own room IDliveInfo.name = "denny`s room" // Replace with your own room nameliveInfo.seatMode = .applyToTake // Normally in live broadcasting scenarios, the apply to take microphone mode is used. If your business allows the audience to take the microphone without applying, rewrite here as freeToTake.liveInfo.maxSeatCount = 10 // Replace with the maximum number of microphone slots in the Live package you have purchasedliveInfo.isSeatEnabled = true // If you do not need microphone position control, set isSeatEnabled to falseliveInfo.isPublicVisible = true // Control whether the live room is public. It is recommended to set to true.liveInfo.keepOwnerOnSeat = true // If you are in a live streaming scenario, it is strongly recommended to set to true, otherwise you must takeSeat to go live normally.guard let liveListManager = TUIRoomEngine.sharedInstance().getExtension(extensionType: .liveListManager) as? TUILiveListManager else {return}liveListManager.startLive(liveInfo: liveInfo, onSuccess: { liveInfo in// Go live successfully}, onError: { code, message in// Failed to go live})
TUILiveListManager.LiveInfo liveInfo = new TUILiveListManager.LiveInfo();liveInfo.roomId = "video_100001"; // Replace with your own room IDliveInfo.name = "denny`s room"; // Replace with your own room nameliveInfo.seatMode = TUIRoomDefine.SeatMode.APPLY_TO_TAKE; // Normally in live broadcasting scenarios, the apply to take microphone mode is used. If your business allows the audience to take the microphone without applying, rewrite here as freeToTake.liveInfo.maxSeatCount = 10; // Replace with the maximum number of microphone slots in the Live package you have purchasedliveInfo.isSeatEnabled = true; // If you do not need microphone position control, set isSeatEnabled to falseliveInfo.isPublicVisible = true; // Control whether the live room is public. It is recommended to set to true.liveInfo.keepOwnerOnSeat = true; // If you are in a live streaming scenario, it is strongly recommended to set to true, otherwise you must takeSeat to go live normally.TUILiveListManager liveListManager = (TUILiveListManager)TUIRoomEngine.sharedInstance().getExtension(TUICommonDefine.ExtensionType.LIVE_LIST_MANAGER);liveListManager.startLive(liveInfo, new TUILiveListManager.LiveInfoCallback() {@Overridepublic void onSuccess(TUILiveListManager.LiveInfo liveInfo) {// Go live successfully}@Overridepublic void onError(TUICommonDefine.Error error, String message) {// Failed to go live}});
TUIRoomEngine.once('ready', () => {const liveInfo = {roomId: 'live_100001',roomType: TUIRoomType.kLivingRoom,name: 'live room',isSeatEnabled: true,seatMode: TUISeatMode.kApplyToTake,maxSeatCount: 10,keepOwnerOnSeat: true,};const roomEngine = TUIRoomEngine.getInstance();const liveListManager = roomEngine.getLiveListManager();const resultLiveInfo = await liveListManager.startLive(liveInfo);console.log('Live stream started successfully, CDN stream address:', resultLiveInfo.cdnStreamUrl);});
TUILiveListManager plug-in's stopLive API to end the live stream.import RTCRoomEngineguard let liveListManager = TUIRoomEngine.sharedInstance().getExtension(extensionType: .liveListManager) as? TUILiveListManager else {return}liveListManager.stopLive { TUILiveStatisticsData in// Live stream ended successfully} onError: { code, message in// Live stream ended unsuccessfully}
TUILiveListManager liveListManager = (TUILiveListManager)TUIRoomEngine.sharedInstance().getExtension(TUICommonDefine.ExtensionType.LIVE_LIST_MANAGER);liveListManager.stopLive(new TUILiveListManager.StopLiveCallback() {@Overridepublic void onSuccess(TUILiveListManager.LiveStatisticsData statisticData) {// Live stream ended successfully}@Overridepublic void onError(TUICommonDefine.Error error, String message) {// Live stream ended unsuccessfully}});
TUIRoomEngine.once('ready', () => {const roomEngine = TUIRoomEngine.getInstance();const liveListManager = roomEngine.getLiveListManager();const statistics = await liveListManager.stopLive();console.log('Live stream ended, stats:', {Audience count: statistics.totalViewers,Gift count: statistics.totalGiftsSent,Like count: statistics.totalLikesReceived});});
Feedback