tencent cloud

Tencent Real-Time Communication

Release Notes and Announcements
Release Notes
Recent Product Announcement
TRTC Live (TUILiveKit) Product Launch Announcement
TRTC Conference Official Editions Launched
The commercial version of Conference is coming soon
Terms and Conditions Applicable to $9.9 Starter Package
Rules for the "First Subscription $100 Discount" Promotion
Announcement on the Start of Beta Testing for Multi-person Audio and Video Conference
TRTC Call Official Editions Launched
License Required for Video Playback in New Version of LiteAV SDK
TRTC to Offer Monthly Packages
Product Introduction
Overview
Concepts
Features
Strengths
Use Cases
Performance Statistics
Tencent RTC Quickplay: Experience Ultimate Real-Time Audio and Video Interaction!
Purchase Guide
Billing Overview
Free Minutes
Monthly subscription
Pay-as-you-go
TRTC Overdue and Suspension Policy
FAQs
Refund Instructions
User Tutorial
Free Demo
Call
Overview
Activate the Service
Run Demo
Integration
Offline Call Push
Conversational Chat
On-Cloud Recording
AI Noise Reduction
UI Customization
Calls integration to Chat
Additional Features
No UI Integration
Server APIs
Client APIs
Solution
ErrorCode
Release Notes
FAQs
Conference
Overview(TUIRoomKit)
Activate the Service (TUIRoomKit)
Run Demo(TUIRoomKit)
Integration(TUIRoomKit)
Screen Sharing (TUIRoomKit)
Schedule a meeting (TUIRoomKit)
In-meeting Call (TUIRoomKit)
UI Customization(TUIRoomKit)
Virtual Background (TUIRoomKit)
Conference Control (TUIRoomKit)
Cloud Recording (TUIRoomKit)
AI Noise Reduction (TUIRoomKit)
In-Conference Chat (TUIRoomKit)
Robot Streaming (TUIRoomKit)
Enhanced Features (TUIRoomKit)
Client APIs (TUIRoomKit)
Server APIs (TUIRoomKit)
FAQs (TUIRoomKit)
Error Code (TUIRoomKit)
SDK Update Log (TUIRoomKit)
Live
Billing of Video Live Component
Overview
Activating the Service (TUILiveKit)
Run Demo
No UI Integration
UI Customization
Live Broadcast Monitoring
Video Live Streaming
Voice Chat Room
Advanced Features
Client APIs
Server APIs
Error Codes
Release Notes
FAQs
RTC Engine
Activate Service
SDK Download
API Examples
Usage Guidelines
API Reference Manual
Advanced Features
AI Integration
Overview
Configure MCP Server
Install Skills
Integration Guide
FAQ
RTC RESTFUL API
History
Introduction
API Category
Room Management APIs
Stream mixing and relay APIs
On-cloud recording APIs
Data Monitoring APIs
Pull stream Relay Related interface
Web Record APIs
AI Service APIs
Cloud Slicing APIs
Cloud Moderation APIs
Making API Requests
Call Quality Monitoring APIs
Usage Statistics APIs
Data Types
Appendix
Error Codes
Console Guide
Application Management
Package Management
Usage Statistics
Monitoring Dashboard
Development Assistance
Solution
Real-Time Chorus
FAQs
Migration Guide
Billing
Features
UserSig
Firewall Restrictions
How to Downsize Installation Package
Android and iOS
Web
Flutter
Electron
TRTCCalling for Web
Audio and Video Quality
Others
Legacy Documentation
RTC RoomEngine SDK(Old)
Integrating TUIRoom (Web)
Integrating TUIRoom (Android)
Integrating TUIRoom (iOS)
Integrating TUIRoom (Flutter)
Integrating TUIRoom (Electron)
TUIRoom APIs
On-Cloud Recording and Playback (Old)
RTC Analytics Monthly Packages (Previous Version)
Protocols and Policies
Compliance
Security White Paper
Notes on Information Security
Service Level Agreement
Apple Privacy Policy: PrivacyInfo.xcprivacy
TRTC Policy
Privacy Policy
Data Processing And Security Agreement
Glossary

Web

PDF
Focus Mode
Font Size
Last updated: 2024-06-28 15:03:32
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.



SDK Usage Overview

1. Call the TRTC.create() method to create the trtc object.
2. Call the trtc.enterRoom() method to enter the room, then other users will receive the TRTC.EVENT.REMOTE_USER_ENTER event.
3. After entering the room, you can turn on the camera and microphone and publish them to the room.
Call the TRTC.startLocalVideo() method to turn on the camera and publish it to the room.
Call the TRTC.startLocalAudio() method to turn on the microphone and publish it to the room.
4. When a remote user publishes audio and video, the SDK will automatically play the remote audio by default. You need to play the remote video by:
Listen for the TRTC.EVENT.REMOTE_VIDEO_AVAILABLE event before entering the room to receive all remote user video publishing events.
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.
Create a TRTC object through the TRTC.create() method
const trtc = TRTC.create();
Note:
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.
string
"mike"
userSig
User signature, refer to 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 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().
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);
}


Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback