TRTC.create()
method to create the trtc
object.trtc.enterRoom()
method to enter the room, then other users will receive the TRTC.EVENT.REMOTE_USER_ENTER event.TRTC.startLocalVideo()
method to turn on the camera and publish it to the room.TRTC.startLocalAudio()
method to turn on the microphone and publish it to the room.trtc.startRemoteVideo()
method to play the remote video.TRTC
class, whose instance represents a local client. The object methods of TRTC provide functions such as joining a call room, previewing a local camera, publishing a local camera and microphone, and playing remote audio and video.const trtc = TRTC.create();
import { markRaw } from 'vue';const trtc = markRaw(TRTC.create());
trtc.enterRoom()
method to enter the room. Usually called in the click callback of the Start Call
button.
Key parameters:Name | Description | Type | Example |
sdkAppId | The sdkAppId of the audio and video application you created on Tencent Cloud. | number | 1400000123 |
userId | It is recommended to limit the length to 32 bytes, and only allow uppercase and lowercase English letters (a-zA-Z), numbers (0-9), underscores, and hyphens. | string | "mike" |
userSig | string | eJyrVareCeYrSy1SslI... | |
roomId | Numeric type roomId. The value must be an integer between 1 and 4294967294.
If you need to use a string type roomId, please use the strRoomId parameter. One of roomId and strRoomId must be passed in. If both are passed in, the roomId will be selected first. | number | 29834 |
strRoomId | String type roomId. The length is limited to 64 bytes, and only supports the following characters: Uppercase and lowercase English letters (a-zA-Z) Numbers (0-9) Space ! # $ % & ( ) + - : ; < = . > ? @ [ ] ^ _ { } | Note: It is recommended to use a numeric type roomId. The string type room id "123" is not the same room as the numeric type room id 123. | string | "29834" |
scene | rtc :Real-time call scene.live :Interactive live streaming scene | string | 'rtc' or 'live' |
role | User role, only works for live sceneanchor audience The audience role does not have the permission to publish local audio and video, only the permission to watch remote streams. If the audience wants to interact with the anchor by connecting to the microphone, please switch the role to the anchor through trtc.switchRole() before publishing local audio and video. | string | 'anchor' or 'audience' |
try {await trtc.enterRoom({ roomId: 8888, scene:'rtc', sdkAppId, userId, userSig });console.log('Entered the room successfully');} catch (error) {console.error('Failed to enter the room ' + error);}
Was this page helpful?