This document describes how to enter a TRTC room. Only after entering an audio/video room can a user subscribe to the audio/video streams of other users in the room or publish his or her own audio/video streams.
In the event callback function, call the trtc.startRemoteVideo() method to play the remote video.
Step 1. Creating a TRTC object
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.
If you use the Vue3 framework, it is necessary to use markRaw to mark the trtc instance in order to avoid the conversion of trtc into the Proxy object by Vue, which may cause some unexpected problems.
import{ markRaw }from'vue';
const trtc =markRaw(TRTC.create());
Step 2. Entering the room
Call the 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.
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:
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 scene
anchor
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'
For more detailed parameter descriptions, refer to the interface document trtc.enterRoom().