// Create a TRTCCloud singleton trtcCloud = (await TRTCCloud.sharedInstance())!; // Register TRTC event callback trtcCloud.registerListener(onRtcListener);
// We need to define a method to handle event callbacks, processing appropriately based on the type of the received event. // Taking onError as an example trtcCloud.registerListener(onRtcListener); onRtcListener(type, param) async { if (type == TRTCCloudListener.onError) { if (param['errCode'] == -1308) { MeetingTool.toast('Failed to initiate screen recording', context); } else { showErrordDialog(param['errMsg']); } } }
TRTCParams
and the application scene. A detailed introduction is as follows:Scenario Type | Scenario Introduction |
TRTC_APP_SCENE_VIDEOCALL | Within the context of video calling, 720p and 1080p high-definition image quality is supported. A single room can accommodate up to 300 simultaneous online users, with a maximum of 50 users speaking at the same time. |
TRTC_APP_SCENE_LIVE | In the context of interactive video broadcasting, the mic can be smoothly turned on/off without switching latency, with host latency as low as 300 milliseconds. Supports live streaming for hundreds of thousands of concurrent viewers, with playback delay reduced to 1000 milliseconds. Note: In this scenario, you need to specify the current user's role using the 'role' field in TRTCParams. |
TRTC_APP_SCENE_AUDIOCALL | In the audio call context, it supports 48 kHz duplex audio calls. A single room accommodates up to 300 concurrent online users, with a maximum of 50 people speaking at once. |
TRTC_APP_SCENE_VOICE_CHATROOM | In the context of interactive audio live streaming, microphones can be switched on and off smoothly without delay. The host experiences a low latency of fewer than 300 milliseconds. It accommodates hundreds of thousands concurrent viewer users, with the broadcast delay reduced to 1000 milliseconds. Note: In this scenario, you need to specify the current user's role using the 'role' field in TRTCParams. |
Parameter name | Field Description | Supplementary Information | Data Type | Example |
sdkAppId | Application ID | You can locate the SDKAppID within the Tencent Real-Time Communication console, if not present, click on the "Create Application" button to institute a new application. | Number | 1400000123 |
userId | User ID | It can contain only letters, digits, underscores, and hyphens. In TRTC, a user cannot use the same user ID to enter the same room on two different devices at the same time. | String | "denny" or "123321" |
userSig | The authentication ticket needed to enter a room | You can calculate userSig using the SDKAppID and userId. Please refer to Calculating and Using UserSig for the calculation method. | String | eJyrVareCeYrSy1SslI... |
roomId | Room ID | Numeric type 'Room ID'. Be aware, if you wish to utilize a character sequence as the Room ID, please resort to the strRoomId field, rather than the roomId field, as strRoomId and roomId should not be used interchangeably. | Number | 29834 |
strRoomId | Room ID | Room ID of string type. Note that `strRoomId` and `roomId` shouldn't be used interchangeably, as to the TRTC backend service, "123" and 123 are not the same room. | String | "29834" |
role | Roles | Divided into "Anchor" and "Audience" roles, this field only needs to be specified when the TRTCAppScene is designated as TRTCAppSceneLIVE or TRTCAppSceneVoiceChatRoom , these two live streaming scenarios. | Enumeration | TRTCRoleAnchor or TRTCRoleAudience |
enterRoom() async { try { userInfo['userSig'] = await GenerateTestUserSig.genTestSig(userInfo['userId']); meetModel.setUserInfo(userInfo); } catch (err) { userInfo['userSig'] = ''; print(err); }// If your scenario is "interactive video live broadcast", please set the scene to TRTC_APP_SCENE_LIVE, and set the appropriate value for the role field in TRTCParams. await trtcCloud.enterRoom( TRTCParams( sdkAppId: GenerateTestUserSig.sdkAppId, userId: userInfo['userId'], userSig: userInfo['userSig'], role: TRTCCloudDef.TRTCRoleAnchor, roomId: meetId!), TRTCCloudDef.TRTC_APP_SCENE_LIVE); }
result
will be a negative number, representing the error code of room entry failure.//Listen for SDK's onEnterRoom event to check if room entry is successful or notonRtcListener(type, param) async {if (type == TRTCCloudListener.onEnterRoom) { if (param > 0) { MeetingTool.toast('Enter room success', context); } }}
Was this page helpful?