// Use npmnpm i @tencentcloud/tuiroom-engine-electron --save// Use pnpmpnpm i @tencentcloud/tuiroom-engine-electron --save// Use yarnyarn add @tencentcloud/tuiroom-engine-electron
API | Validation |
Listening TUIRoomEngine ready event. Note: All methods other than TUIRoomEngine.init must be executed after the TUIRoomEngine ready event is received and the TUIRoomEngine.init method is successfully executed. | |
Log in to TUIRoomEngine | |
Log out of TUIRoomEngine | |
Set basic information of the current user (user name, user avatar) | |
Get basic information of the current user (user name, user avatar) | |
Get device manager | |
Get audio effect manager | |
Get media source mixing manager | |
Get video effect plugin manager |
API | Validation |
Create a room | |
Enter a room | |
Destroy a room | |
Exit a room | |
Fetch room information | |
Update room name (Only available to room owners or administrators) | |
Update room seat mode (Only available to room owners or administrators) | |
Get members list | |
Get member detail information |
API | Validation |
Set the HTML element where to play local camera video stream | |
Open local camera | |
Close local camera | |
Open local microphone | |
Close local microphone | |
Set local video parameters | |
Set the resolution mode of the local video stream | |
Set local video encoding parameters | |
Set local audio parameters | |
Start pushing the local video stream to the remote end | |
Stop pushing the local video stream to the remote end | |
Stop pushing the local audio stream to the remote end | |
Start pushing the local audio stream to the remote end | |
Set the HTML element where to play the remote video stream | |
Start playing the remote user's video stream | |
Stop playing the remote user's video stream | |
Stop the remote user's audio stream |
API | Validation |
Cancel a request already sent | |
Response to remote use request | |
Change user role | |
Kick user out of current room | |
Disable/Enable instant message chat |
API | Validation |
Get seats information | |
Take a seat | |
Release a seat | |
Invite someone else to speak (only available to room owner and administrators) | |
Kick someone off the seat (only available to room owner and administrators) | |
Lock a seat (only available to room owner and administrators) | |
Get the list of speaking requests |
API | Validation |
Start screen or window sharing | |
Stop screen or window sharing | |
Get the screens and windows to be shared | |
Select the screen or window to share |
API | Validation |
API | Validation |
Get TRTCCloud instance | |
Get TIM/Chat instance |
TUIRoomEngine.once('ready', () => {const roomEngine = new TUIRoomEngine();await TUIRoomEngine.init({sdkAppId: 0, // Fill your `sdkAppId`userId: '', // Fill your `userId`userSig: '', // Fill your `userSig`});await roomEngine.createRoom({roomId: '12345', // Fill room ID of type stringname: 'Test Room', // Fill room name, default value is `roomId`, maximize length: 30roomType: TUIRoomType.kLive, // Room type should be `TUIRoomType.kLive`});});
// Log in to TUIRoomEngineawait TUIRoomEngine.login({sdkAppId: 0, // Fill your `sdkAppId`userId: '', // Fill your `userId`userSig: '', // Fill the `userSig` responded from server or generated locally.});
Parameter | Type | Validation | Default value | Description |
sdkAppId | number | Required | - | sdkAppId On TRTC Cloud Console Click `Application Management` > `Create Application`. After creation, you can get the `sdkappId` from application detail information. |
userId | string | Required | - | It is recommended that the user ID be limited to 32 bytes and only contain uppercase and lowercase letters (a-zA-Z), digits (0-9), underscores, and hyphens. |
userSig | string | Required | - | userSig For detail about what and how to generate `userSig`, please refer to the online documentation:UserSig. |
tim | TIM | Not required | - | If you want to use more capabilities of the Instant Messaging SDK while connecting to roomEngine, you can pass the created tim instance into TUIRoomEngine. For the creation method of the tim instance, please refer to:TIM.create. |
// Log out of TUIRoomEngineawait TUIRoomEngine.logout();
// Set basic information of the current user (user name, user avatar)await TUIRoomEngine.setSelfInfo({userName: '', // Fill your `userName`avatarUrl: '', // Fill your avatar URL});
Parameter | Type | Validation | Default value | Description |
userName | string | Required | - | User name |
avatarUrl | string | Required | - | User avatar |
// Get basic information of the current user (user name, user avatar)const loginUserInfo = await TUIRoomEngine.getSelfInfo();
import TUIRoomEngine, {TUIDeviceManager} from '@tencentcloud/tuiroom-engine-electron';const deviceManager:TUIDeviceManager = TUIRoomEngine.getDeviceManager();
import TUIRoomEngine, {TUIAudioEffectManager} from '@tencentcloud/tuiroom-engine-electron';const audioEffectManager: TUIAudioEffectManager = TUIRoomEngine.getAudioEffectManager();
import TUIRoomEngine, { TUIMediaMixingManager } from '@tencentcloud/tuiroom-engine-electron';const mediaMixingManager: TUIMediaMixingManager = TUIRoomEngine.getMediaMixingManager();
import TUIRoomEngine, {TUIVideoEffectPluginManager} from '@tencentcloud/tuiroom-engine-electron';const videoEffectPluginManager: TUIVideoEffectPluginManager = TUIRoomEngine.getVideoEffectPluginManager();
const roomEngine = new TUIRoomEngine();await roomEngine.createRoom({roomId: '12345', // Fill the `roomId`of string typeroomName: 'Test Room', // Enter your room name. The room name defaults to roomId and can be up to 30 bytes long.roomType: TUIRoomType.kLive, // The room type must be `TUIRoomType.kLive` for online livingisSeatEnabled: false, // Whether to enable microphone seat control.isMicrophoneDisableForAllUser: false, // Whether to allow joining users to turn on the microphone.isCameraDisableForAllUser: false, // Whether to allow joining users to turn on the camera.isMessageDisableForAllUser: false, // Whether to allow joining users to send instance message.});
Parameter | Type | Validation | Default value | Description |
roomId | string | Required | - | Room ID is limited to 64 bytes in length and only supports the following character sets: Uppercase and lowercase English letters (a-zA-Z), number(0-9), Space ! # $ % & ( ) + - : ; < = . > ? @ [ ] ^ _ { } | ~ , |
roomName | string | Optional | roomId | Room name, default to `roomId`, cannot be empty. |
roomType | Optional | TUIRoomType.kConference | Room type For office collaboration, medical consultation, remote meetings, and educational scenarios, set roomType to TUIRoomType.kConference, for e-commerce live streaming and voice chat room scenarios, set roomType to TUIRoomType.kLive. | |
isSeatEnabled | boolean | Optional | false | Whether to enable microphone seat control. Default is `false` to not enable. |
seatMode | Optional | TUISeatMode.kFreeToTake | Seat mode(enable when microphone seat controlling is enabled), default value:`TUISeatMode.kFreeToTake` `TUISeatMode.kFreeToTake`: user can open or close microphone and camera freely without requesting for permission. When `seatMode`is `TUISeatMode.kApplyToTake` TUISeatMode.kApplyToTake: Audience members need the approval of the room owner or administrator before they can speak. | |
isMicrophoneDisableForAllUser | boolean | Optional | false | Whether to disable users to control their microphones. Not disabled by default. |
isCameraDisableForAllUser | boolean | Optional | false | Whether to disable users to control their cameras. Not disabled by default. |
isMessageDisableForAllUser | boolean | Optional | false | Whether to disable users to send instance messages. Not disabled by default. |
maxSeatCount | number | Optional | - | Maximum number of seats When `roomType` is `TUIRoomType.kConference`(education and meeting scenarios), there is no limit on the `maxSeatCount` value. When `roomType` is `TUIRoomType.kLivingRoom`(living scenarios), the maximum value for `maxSeatCount` is 16. |
enableCDNStreaming | boolean | Optional | false | Whether to enable CDN live streaming. |
cdnStreamDomain | string | Optional | '' | The URL domain to receive living stream. |
const roomEngine = new TUIRoomEngine();const roomInfo = await roomEngine.enterRoom({roomId: '12345',roomType: TUIRoomType.kLive});
Parameter | Type | Validation | Default value | Description |
roomId | string | Required | - | Room ID |
roomType | Optional | TUIRoomType.kConference | Room type |
const roomEngine = new TUIRoomEngine();await roomEngine.destroyRoom();
const roomEngine = new TUIRoomEngine();await roomEngine.exitRoom();
const roomEngine = new TUIRoomEngine();const roomInfo = roomEngine.fetchRoomInfo();
const roomEngine = new TUIRoomEngine();await roomEngine.createRoom({ roomId: '12345' });await roomEngine.updateRoomNameByAdmin({ roomName: 'New room name' });
Parameter | Type | Validation | Default value | Description |
roomName | string | Required | - | Room name that can not be empty string. |
const roomEngine = new TUIRoomEngine();await roomEngine.createRoom({ roomId: '12345' });await roomEngine.updateRoomSeatModeByAdmin({seatMode: TUISeatMode.kApplyToTake, // Update room seat mode});
Parameter | Type | Validation | Default value | Description |
seatMode | Required | - | Room seat mode |
const roomEngine = new TUIRoomEngine();const userList = [];let result;let nextSequence = 0;do {result = await roomEngine.getUserList({ nextSequence });userList.push(...result.userInfoList);nextSequence = result.nextSequence;} while (result.nextSequence !== 0)
Parameter | Type | Validation | Default value | Description |
nextSequence | number | Optional | 0 | Offset. By default, users are pulled starting from offset 0. |
const roomEngine = new TUIRoomEngine();const userList = [];const userInfo = await roomEngine.getUserInfo({userId: 'user_12345',});
Parameter | Type | Validation | Default value | Description |
userId | string | Required | - | Get a user detail information by user ID. |
const roomEngine = new TUIRoomEngine();// HTML div element with id 'preview-camera' to play local camera streamawait roomEngine.setLocalVideoView({view: 'preview-camera',});
Parameter | Type | Validation | Default value | Description |
view | string | Required | - | `id` value of HTML element attribute |
const roomEngine = new TUIRoomEngine();await roomEngine.setLocalVideoView({streamType: TUIVideoStreamType.kCameraStream,view: 'preview-camera',});await roomEngine.openLocalCamera();
const roomEngine = new TUIRoomEngine();await roomEngine.closeLocalCamera();
const roomEngine = new TUIRoomEngine();await roomEngine.openLocalMicrophone();
const roomEngine = new TUIRoomEngine();await roomEngine.closeLocalMicrophone();
const roomEngine = new TUIRoomEngine();await roomEngine.updateVideoQuality({quality: TUIVideoQuality.kVideoQuality_540p,});
Parameter | Type | Validation | Default value | Description |
quality | Required | - | Clear definition TUIVideoProfile.kVideoQuality_360P Standard definition TUIVideoProfile.kVideoQuality_540P High definition TUIVideoProfile.kVideoQuality_720P Ultra high definition TUIVideoProfile.kVideoQuality_1080P |
const roomEngine = new TUIRoomEngine();await roomEngine.setVideoResolutionMode({type: TUIVideoStreamType.kCameraStream,resolutionMode: TUIResolutionMode.kResolutionMode_Landscape,});
Parameter | Type | Validation | Default value | Description |
streamType | Required | - | Video stream type | |
resolutionMode | Required | TUIResolutionMode.kResolutionMode_Landscape | Resolution mode |
const roomEngine = new TUIRoomEngine();await roomEngine.updateVideoQualityEx({streamType: TUIVideoStreamType.kCameraStream,encoderParams: {videoResolution: TUIVideoQuality.kVideoQuality_720p,fps: 15,bitrate: 2000,resolutionMode: TUIResolutionMode.kResolutionMode_Landscape,}});
Parameter | Type | Validation | Default value | Description |
streamType | Required | - | Video stream type | |
encoderParams | Required | - | Detailed encoding parameters |
const roomEngine = new TUIRoomEngine();await roomEngine.updateAudioQuality({quality: TUIAudioQuality.kAudioProfileMusic,});
Parameter | Type | Validation | Default value | Description |
audioProfile | Required | - | TUIAudioQuality.kAudioProfileSpeech: Speech Mode; Sample Rate: 16kHz TUIAudioQuality.kAudioProfileDefault: Standard mode(Default mode); Sample Rate: 48kHz TUIAudioQuality.kAudioProfileMusic: Music Mode; Sample Rate: 48kHz |
const roomEngine = new TUIRoomEngine();await roomEngine.startPushLocalVideo();
const roomEngine = new TUIRoomEngine();await roomEngine.stopPushLocalVideo();
const roomEngine = new TUIRoomEngine();await roomEngine.muteLocalAudio();
const roomEngine = new TUIRoomEngine();await roomEngine.unmuteLocalAudio();
const roomEngine = new TUIRoomEngine();// Play remote video at HTML element with id attribute 'remote_preview_camera'await roomEngine.setRemoteVideoView({userId: 'user_1234',streamType: TUIVideoStreamType.kCameraStream,view: 'remote_preview_camera',});// Play remote user screen sharing at HTML element with id attribute 'remote_preview_screen'await roomEngine.setRemoteVideoView({userId: 'user_1234',streamType: TUIVideoStreamType.kScreenStream,view: 'remote_preview_screen',});
Parameter | Type | Validation | Default value | Description |
userId | string | Required | - | User ID |
streamType | Required | - | Video stream type | |
view | string | Required | - | `id` value of HTML element attribute |
const roomEngine = new TUIRoomEngine();await roomEngine.startPlayRemoteVideo({userId: 'user_1234',streamType: TUIVideoStreamType.kCameraStream,});
Parameter | Type | Validation | Default value | Description |
userId | string | Required | - | User ID |
streamType | Required | - | User video stream type TUIVideoStreamType.kCameraStream Camera video stream TUIVideoStreamType.kScreenStream Screen/window sharing video stream TUIVideoStreamType.kCameraStreamLow Camera video stream of Low definition |
const roomEngine = new TUIRoomEngine();await roomEngine.stopPlayRemoteVideo({userId: 'user_1234',streamType: TUIVideoStreamType.kCameraStream,});
Parameter | Type | Validation | Default value | Description |
userId | string | Required | - | User ID |
streamType | Required | - | User video stream type TUIVideoStreamType.kCameraStream Camera video stream TUIVideoStreamType.kScreenStream Screen/window sharing video stream TUIVideoStreamType.kCameraStreamLow Camera video stream of Low definition |
const roomEngine = new TUIRoomEngine();await roomEngine.muteRemoteAudioStream({userId: 'user_1234',isMute: true,});
Parameter | Type | Validation | Default value | Description |
userId | string | Required | - | User ID |
isMute | boolean | Required | - | Whether to stop subscribing remote user audio |
const roomEngine = new TUIRoomEngine();await roomEngine.cancelRequest({requestId: '', // Request unique ID});
Parameter | Type | Validation | Default value | Description |
requestId | string | Required | - | Request ID |
const roomEngine = new TUIRoomEngine();// Agree with remote user requestawait roomEngine.responseRemoteRequest({requestId: '', // Request IDagree: true,});// Disagree with remote user requestawait roomEngine.responseRemoteRequest({requestId: '', // Request IDagree: false,});
Parameter | Type | Validation | Default value | Description |
requestId | string | Required | - | Request ID |
agree | boolean | Required | - | Whether to agree |
await roomEngine.disableSendingMessageByAdmin({userId: 'user_1234',isDisable: true,});
Parameter | Type | Validation | Default value | Description |
userId | string | Required | - | User ID |
isDisable | boolean | Required | - | Whether it is disabled |
const roomEngine = new TUIRoomEngine();// Transfer the room to user user_1234await roomEngine.changeUserRole({userId: 'user_1234',role: TUIRole.kRoomOwner,});// Set user user_1234 as the room administratorawait roomEngine.changeUserRole({userId: 'user_1234',userRole: TUIRole.kAdministrator,});
Parameter | Type | Validation | Default value | Description |
userId | string | Required | - | User ID |
userRole | Required | - | User role Room owner TUIRole.kRoomOwner Room administrator TUIRole.kAdministrator Regular member TUIRole.kGeneralUser |
const roomEngine = new TUIRoomEngine();await roomEngine.kickRemoteUserOutOfRoom({userId: 'user_1234',});
Parameter | Type | Validation | Default value | Description |
userId | string | Required | - | User ID |
const roomEngine = new TUIRoomEngine();const seatList = await roomEngine.getSeatList();
const roomEngine = new TUIRoomEngine();// Case 1: room owner/administrator takes microphone seat// Case 2: When roomInfo.roomType is `TUIRoomType.kConference`// and roomInfo.seatMode `TUISeatMode.kFreeToTake`, regular user takes microphone seatawait roomEngine.takeSeat({seatIndex: -1,timeout: 0,});// Case 3: When roomInfo.seatMode is TUISeatMode.kApplyToTake, regular user takes microphone seatconst requestId = await roomEngine.instance?.takeSeat({seatIndex: -1,timeout: 0,requestCallback: ({ requestCallbackType, requestId, userId, code, message }) => {switch (requestCallbackType) {case TUIRequestCallbackType.kRequestAccepted:// Request is acceptedbreak;case TUIRequestCallbackType.kRequestRejected:// Request is rejectedbreak;case TUIRequestCallbackType.kRequestCancelled:// Request is cancelledbreak;case TUIRequestCallbackType.kRequestTimeout:// Request is timeoutbreak;case TUIRequestCallbackType.kRequestError:// Incorrect requestbreak;default:break;}},});
Parameter | Type | Validation | Default value | Description |
seatIndex | number | Required | - | Microphone seat index. When seat mode is TUISeatMode.kFreeToTake, the value must be -1. |
timeout | number | Required | - | Timeout period. If timeout is set to 0, there is no timeout limitation. |
requestCallback | Function | Optional | Empty function | Request callback, used to notify the initiator that the request has been accepted/rejected/canceled/timed out/errored. |
const roomEngine = new TUIRoomEngine();await roomEngine.leaveSeat();
const roomEngine = new TUIRoomEngine();const requestId = roomEngine.takeUserOnSeatByAdmin({seatIndex: 0,userId: 'user_1234',timeout: 0,requestCallback: ({ requestCallbackType, requestId, userId, code, message }) => {switch (requestCallbackType) {case TUIRequestCallbackType.kRequestAccepted:// Request is acceptedbreak;case TUIRequestCallbackType.kRequestRejected:// Request is rejectedbreak;case TUIRequestCallbackType.kRequestCancelled:// Request is cancelledbreak;case TUIRequestCallbackType.kRequestTimeout:// Request is timeoutbreak;case TUIRequestCallbackType.kRequestError:// Incorrect requestbreak;default:break;}},});
Parameter | Type | Validation | Default value | Description |
seatIndex | number | Required | - | Microphone seat index |
userId | string | Required | - | User ID |
timeout | number | Required | - | Timeout period. If timeout is set to 0, there is no timeout limitation. |
requestCallback | Function | Optional | Empty function | Request callback, used to notify the initiator that the request has been accepted/rejected/canceled/timed out/errored. |
const roomEngine = new TUIRoomEngine();const requestId = await roomEngine.kickUserOffSeatByAdmin({seatIndex: 0,userId: 'user_1234',});
Parameter | Type | Validation | Default value | Description |
seatIndex | number | Required | - | Microphone seat index |
userId | string | Required | - | User ID |
const roomEngine = new TUIRoomEngine();await roomEngine.lockSeatByAdmin({seatIndex: 0,lockParams: {lockSeat: true,lockVideo: true,lockAudio: true,},});
Parameter | Type | Validation | Default value | Description |
seatIndex | number | Required | - | Microphone seat index |
lockParams | Required | - | Lock microphone seat parameter |
const roomEngine = new TUIRoomEngine();const applicationList = await roomEngine.getSeatApplicationList();
const roomEngine = new TUIRoomEngine();// Case 1: Start sharing screenawait roomEngine.startScreenSharingElectron({targetId: 'targetId'});// Case 2: Start sharing screen and preview locallyawait roomEngine.startScreenSharingElectron({targetId: 'targetId',view: 'screen-preview'});
Parameter | Type | Validation | Default value | Description |
targetId | string | Optional | - | Scree or window ID, which can be obtained from getScreenSharingTarget. |
view | string | Optional | - | The HTML element ID for local preview of screen sharing |
const roomEngine = new TUIRoomEngine();await roomEngine.stopScreenSharingElectron();
const roomEngine = new TUIRoomEngine();const screenList = await roomEngine.getScreenSharingTarget();
const roomEngine = new TUIRoomEngine();await roomEngine.selectScreenSharingTarget({targetId: 'targetId'});
Parameter | Type | Validation | Default value | Description |
targetId | string | Required | - | Screen or window ID, which can be obtained from getScreenSharingTarget. |
const roomEngine = new TUIRoomEngine();roomEngine.on(event, func);
Parameter | Type | Validation | Default value | Description |
event | Required | - | TUIRoomEngine events | |
func | Function | Required | - | Event handler function |
const roomEngine = new TUIRoomEngine();roomEngine.off(event, func);
Parameter | Type | Validation | Default value | Description |
event | Required | - | TUIRoomEngine events | |
func | Function | Required | - | Event handler function |
const roomEngine = new TUIRoomEngine();const trtcCloud = roomEngine.getTRTCCloud();
const roomEngine = new TUIRoomEngine();const tim = roomEngine.getTIM();
Was this page helpful?