TRTCCloudListener enum

Listener type enumeration

Inheritance

Constructors

TRTCCloudListener()
const

Values

onError → const TRTCCloudListener

Error callback, which indicates that the SDK encountered an irrecoverable error and must be listened on. Corresponding UI reminders should be displayed based on the actual conditions

Parameters:

errCode Error code

errMsg Error message


onWarning → const TRTCCloudListener

Warning callback. This callback is used to alert you of some non-serious problems such as lag or recoverable decoding failure

Parameters:

warningCode Warning code

warningMsg Warning message


onEnterRoom → const TRTCCloudListener

Callback for room entry

After the enterRoom() API in TRTCCloud is called to enter a room, the onEnterRoom(result) callback will be received from the SDK.

If room entry succeeded, result will be a positive number (result > 0), indicating the time in milliseconds (ms) used for entering the room.

If room entry failed, result will be a negative number (result < 0), indicating the error code for room entry failure.

Parameters:

If result is greater than 0, it will be the time used for room entry in ms; if result is smaller than 0, it will be room entry error code.


onExitRoom → const TRTCCloudListener

Callback for room exit

When the exitRoom() API in TRTCCloud is called, the logic related to room exit will be executed, such as releasing resources of audio/video devices and codecs. After resources are released, the SDK will use the onExitRoom() callback to notify you.

If you need to call enterRoom() again or switch to another audio/video SDK, please wait until you receive the onExitRoom() callback; otherwise, exceptions such as occupied audio device may occur.

Parameters:

reason Reason for exiting the room. 0: the user actively called exitRoom to exit the room; 1: the user was kicked out of the room by the server; 2: the room was dismissed.


onSwitchRole → const TRTCCloudListener

Callback for role switch

Calling the switchRole() API in TRTCCloud will switch between the anchor and audience roles, which will be accompanied by a line switch process. After the SDK switches the roles, the onSwitchRole() event callback will be returned.

Parameters:

errCode Error code. 0 indicates a successful switch

errMsg Error message


onRemoteUserEnterRoom → const TRTCCloudListener

A user enters the current room

For the sake of performance, the behaviors of this notification will be different in two different application scenarios:

Call scenario (TRTCCloudDef.TRTC_APP_SCENE_VIDEOCALL or TRTCCloudDef.TRTC_APP_SCENE_AUDIOCALL): users in this scenario do not have different roles, and this notification will be triggered whenever a user enters the room.

Live streaming scenario (TRTCCloudDef.TRTC_APP_SCENE_LIVE or TRTCCloudDef.TRTC_APP_SCENE_VOICE_CHATROOM): this scenario does not limit the number of audience users. If any user entering or exiting the room could trigger the callback, it would cause great performance loss. Therefore, this notification will be triggered only when an anchor rather than an audience user enters the room.

Parameters:

userId User ID


onRemoteUserLeaveRoom → const TRTCCloudListener

A user exits the current room

Similar to onRemoteUserEnterRoom, the behaviors of this notification will be different in two different application scenarios:

Call scenario (TRTCCloudDef.TRTC_APP_SCENE_VIDEOCALL or TRTCCloudDef.TRTC_APP_SCENE_AUDIOCALL): users in this scenario do not have different roles, and this notification will be triggered whenever a user exits the room.

Live streaming scenario (TRTCCloudDef.TRTC_APP_SCENE_LIVE or TRTCCloudDef.TRTC_APP_SCENE_VOICE_CHATROOM): this notification will be triggered only when an anchor rather than an audience user exits the room.

Parameters:

userId User ID

reason Reason for exiting the room. 0: the user proactively exited the room; 1: the user exited the room due to timeout; 2: the user was kicked out of the room.


onConnectOtherRoom → const TRTCCloudListener

Callback for the result of requesting cross-room call (anchor competition)

Calling the connectOtherRoom() API in TRTCCloud will establish a video call between two anchors in two different rooms, i.e., the "anchor competition" feature. The caller will receive the onConnectOtherRoom() callback to see whether the cross-room call is successful; and if so, all users in both rooms will receive the onUserVideoAvailable callback for anchor competition.

Parameters:

userId userId of the target anchor to compete with.

errCode Error code. ERR_NULL indicates a successful switch. For more information, please see Error Codes.

errMsg Error message


onDisConnectOtherRoom → const TRTCCloudListener

Callback for the result of ending cross-room call (anchor competition)


onSwitchRoom → const TRTCCloudListener

Callback for the result of room switching (switchRoom)

Parameters:

errCode Error code

errMsg Error message


onUserVideoAvailable → const TRTCCloudListener

Whether the remote user has a playable primary image (generally for camera)

When the onUserVideoAvailable(userId, true) notification is received, it indicates that available video data frames of the specified image channel have arrived. At this time, the TRTCCloud.startRemoteView API needs to be called to load the image of the remote user. Then, the callback for rendering the first video frame, i.e., onFirstVideoFrame(userid), will be received.

When the onUserVideoAvailable(userId, false) notification is received, it indicates that the specified channel of remote image has been disabled, which may be because the user called TRTCCloud.muteLocalVideo or TRTCCloud.stopLocalPreview.

Parameters:

userId User ID

available Whether image is enabled


onUserSubStreamAvailable → const TRTCCloudListener

Whether the remote user has a playable substream image (generally for screen sharing)

Parameters:

userId User ID

available Whether screen sharing is enabled


onUserAudioAvailable → const TRTCCloudListener

Whether the remote user has playable audio data

Parameters:

userId User ID

available Whether audio is enabled


onFirstVideoFrame → const TRTCCloudListener

Rendering of the first frame of a local or remote user starts

If userId is null, it indicates that the captured local camera image starts to be rendered, which needs to be triggered by calling startLocalPreview first. If userId is not null, it indicates that the first video frame of the remote user starts to be rendered, which needs to be triggered by calling startRemoteView first.

This callback will be triggered only after TRTCCloud.startLocalPreview() or TRTCCloud.startRemoteView() is called.

Parameters:

userId ID of the local or remote user. userId == null indicates the ID of the local user, while userId != null indicates the ID of a remote user.

streamType Video stream type: camera or screen sharing.

width Image width

height Image height


onFirstAudioFrame → const TRTCCloudListener

Playback of the first audio frame of a remote user starts (local audio is not supported for notification currently)

Parameters:

userId Remote user ID


onSendFirstLocalVideoFrame → const TRTCCloudListener

The first local audio frame data has been sent

The SDK will start capturing the camera and encode the captured image after successful call of TRTCCloud.enterRoom() and TRTCCloud.startLocalPreview(). This callback event will be returned after the SDK successfully sends the first video frame data to the cloud.

Parameters:

streamType Video stream type: big image, small image, or substream image (screen sharing)


onSendFirstLocalAudioFrame → const TRTCCloudListener

The first local audio frame data has been sent

The SDK will start capturing the mic and encoding the captured audio after successful call of TRTCCloud.enterRoom() and TRTCCloud.startLocalAudio(). This callback event will be returned after the SDK successfully sends the first audio frame data to the cloud.


onNetworkQuality → const TRTCCloudListener

Network quality: this callback is triggered once every 2 seconds to collect statistics of the current network upstreaming and downstreaming quality

userId is the local user ID, indicating the current local video quality

Parameters:

localQuality Upstream network quality

remoteQuality Downstream network quality


onStatistics → const TRTCCloudListener

Callback for technical metric statistics

If you are familiar with audio/video terms, you can use this callback to get all technical metrics of the SDK. If you are developing an audio/video project for the first time, you can focus only on the onNetworkQuality callback.

Note: the callback is triggered once every 2 seconds

Parameters:

statics Status data


onConnectionLost → const TRTCCloudListener

The connection between SDK and server is closed


onTryToReconnect → const TRTCCloudListener

The SDK tries to connect to the server again


onConnectionRecovery → const TRTCCloudListener

The connection between SDK and server has been restored


onSpeedTest → const TRTCCloudListener

Callback for server speed test. SDK tests the speed of multiple server IPs, and the test result of each IP is returned through this callback notification

Parameters:

currentResult Current speed test result

finishedCount Number of servers on which speed test has been performed

totalCount Total number of servers on which speed test needs to be performed


onCameraDidReady → const TRTCCloudListener

Camera is ready


onMicDidReady → const TRTCCloudListener

Mic is ready


onUserVoiceVolume → const TRTCCloudListener

Callback for volume, including the volume of each userId and total remote volume

The enableAudioVolumeEvaluation API in TRTCCloud can be used to enable this callback or set its triggering interval. It should be noted that after TRTCCloud.enableAudioVolumeEvaluation is called to enable the volume callback, no matter whether there is a user speaking in the channel, the callback will be called at the set time interval. If there is no one speaking, userVolumes will be empty, and totalVolume will be 0.

Note: if userId is the local user ID, it indicates the volume of the local user. userVolumes only includes the volume information of users who are speaking (i.e., volume is not 0).

Parameters:

userVolumes Volume of all members who are speaking in the room. Value range: 0100.

totalVolume Total volume of all remote members. Value range: 0100.


onRecvCustomCmdMsg → const TRTCCloudListener

Callback for receipt of custom message

When a user in a room uses TRTCCloud.sendCustomCmdMsg to send a custom message, other users in the room can receive the message through the onRecvCustomCmdMsg API.

Parameters:

userId User ID

cmdID Command ID

seq Message serial number

message Message data


onMissCustomCmdMsg → const TRTCCloudListener

Callback for loss of custom message

TRTC uses the UDP channel; therefore, even if reliable transfer is set, it cannot guarantee that no message will be lost; instead, it can only reduce the message loss rate to a very small value and meet general reliability requirements. After reliable transfer is set on the sender, the SDK will use this callback to notify of the number of custom messages lost during transfer in the specified past time period (usually 5s).

Note:

Only when reliable transfer is set on the sender can the receiver receive the callback for message loss.

Parameters:

userId User ID

cmdID Data stream ID

errCode Error code. The value is -1 on the current version

missed Number of lost messages


onRecvSEIMsg → const TRTCCloudListener

Callback for receipt of SEI message

When a user in a room uses TRTCCloud.sendSEIMsg to send data, other users in the room can receive the data through the onRecvSEIMsg API.

Parameters:

userId User ID

message Data


onStartPublishing → const TRTCCloudListener

Callback for starting pushing to Tencent Cloud CSS CDN, which corresponds to the startPublishing() API in TRTCCloud

Parameters:

errCode 0: success; other values: failure

errMsg Specific cause of error


onStopPublishing → const TRTCCloudListener

Callback for stopping pushing to Tencent Cloud CSS CDN, which corresponds to the stopPublishing() API in TRTCCloud

Parameters:

errCode 0: success; other values: failure

errMsg Specific cause of error


onStartPublishCDNStream → const TRTCCloudListener

Callback for completion of starting relayed push to CDN

This callback corresponds to the startPublishCDNStream() API in TRTCCloud

Note: if Start callback is successful, the relayed push request has been successfully sent to Tencent Cloud. If the target CDN is exceptional, relayed push may fail.

Parameters:

errCode 0: success; other values: failure

errMsg Specific cause of error


onStopPublishCDNStream → const TRTCCloudListener

Callback for completion of stopping relayed push to CDN

This callback corresponds to the stopPublishCDNStream() API in TRTCCloud

Parameters:

errCode 0: success; other values: failure

errMsg Specific cause of error


onSetMixTranscodingConfig → const TRTCCloudListener

Callback for setting On-Cloud MixTranscoding parameters, which corresponds to the setMixTranscodingConfig() API in TRTCCloud

Parameters:

errCode 0: success; other values: failure

errMsg Specific cause of error


onMusicObserverStart → const TRTCCloudListener

Background music playback start


onMusicObserverPlayProgress → const TRTCCloudListener

Background music playback progress


onMusicObserverComplete → const TRTCCloudListener

Background music playback end


onSnapshotComplete → const TRTCCloudListener

Callback for screencapturing completion

Parameters:

errCode of 0: success; other values: failure


onScreenCaptureStarted → const TRTCCloudListener

This callback will be returned by the SDK when screen sharing is started


onScreenCapturePaused → const TRTCCloudListener

This callback will be returned by the SDK when screen sharing is paused

Parameters:

reason Reason. 0: the user paused proactively; 1: screen sharing was paused as the screen window became invisible

Note: the value called back is only valid for iOS


onScreenCaptureResumed → const TRTCCloudListener

This callback will be returned by the SDK when screen sharing is resumed

Parameters:

reason Reason for resumption. 0: the user resumed proactively; 1: screen sharing was resumed as the screen window became visible

Note: the value called back is only valid for iOS


onScreenCaptureStoped → const TRTCCloudListener

This callback will be returned by the SDK when screen sharing is stopped

Parameters:

reason Reason for stop. 0: the user stopped proactively; 1: screen sharing stopped as the shared window was closed


onLocalRecordBegin → const TRTCCloudListener

When the local recording task has started, the SDK will notify through this callback

Parameters:

errCode -0: The recording task is started successfully. -1: An internal error caused the recording task to fail to start. -2: The file suffix name is incorrect (such as unsupported recording format). -6: Recording has been started and needs to be stopped first. -7: The recording file already exists and the file needs to be deleted first. -8: The recording directory does not have write permissions. Please check the directory permissions.

storagePath Recording file storage path.


onLocalRecording → const TRTCCloudListener

When the local recording task is in progress, the SDK will periodically notify you through this callback

You can set the throwing interval of this event callback when startingLocalRecording.

Parameters:

duration The accumulated duration of recording, in milliseconds.

storagePath Recording file storage path.


onLocalRecordFragment → const TRTCCloudListener

When you enable segmented recording, the SDK will notify you through this callback every time a segment is completed.

Parameters:

storagePath Shard file storage path.


onLocalRecordComplete → const TRTCCloudListener

When the local recording task has ended, the SDK will notify you through this callback

Parameters:

errCode -0: The recording task ends successfully. -1: Recording failed. -2: Switching resolution or horizontal and vertical screens causes the recording to end. -3: The recording time is too short, or no video or audio data was collected. Please check the recording time, or whether audio and video collection has been turned on.

storagePath Recording file storage path.


onDeviceChange → const TRTCCloudListener

Callback for local device connection and disconnection

Note: this callback only supports Windows and macOS platforms

Parameters:

deviceId Device ID

type Device type

state Event type


onTestMicVolume → const TRTCCloudListener

Callback for mic test volume

The mic test API TXDeviceManager.startMicDeviceTest will trigger this callback

Note: this callback only supports Windows and macOS platforms

Parameters:

volume Volume value between 0 and 100


onTestSpeakerVolume → const TRTCCloudListener

Callback for speaker test volume

The speaker test API TXDeviceManager.startSpeakerDeviceTest will trigger this callback

Note: this callback only supports Windows and macOS platforms

Parameters:

volume Volume value between 0 and 100


onStartPublishMediaStream → const TRTCCloudListener

Callback for starting to publish

code: 0 : Successful; other values: Failed.

extraInfo: Additional information. For some error codes, there may be additional information to help you troubleshoot the issues.

message: The callback information.

taskId: If a request is successful, a task ID will be returned via the callback. You need to provide this task ID when you call TRTCCloud.updatePublishMediaStream to modify publishing parameters or TRTCCloud.stopPublishMediaStream to stop publishing.


onUpdatePublishMediaStream → const TRTCCloudListener

Callback for modifying publishing parameters

code: 0 : Successful; other values: Failed.

extraInfo: Additional information. For some error codes, there may be additional information to help you troubleshoot the issues.

message: The callback information.

taskId: If a request is successful, a task ID will be returned via the callback. You need to provide this task ID when you call TRTCCloud.updatePublishMediaStream to modify publishing parameters or TRTCCloud.stopPublishMediaStream to stop publishing.


onStopPublishMediaStream → const TRTCCloudListener

Callback for stopping publishing

code: 0 : Successful; other values: Failed.

extraInfo: Additional information. For some error codes, there may be additional information to help you troubleshoot the issues.

message: The callback information.

taskId: If a request is successful, a task ID will be returned via the callback. You need to provide this task ID when you call TRTCCloud.updatePublishMediaStream to modify publishing parameters or TRTCCloud.stopPublishMediaStream to stop publishing.


Properties

hashCode int
The hash code for this object.
no setterinherited
index int
A numeric identifier for the enumerated value.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

values → const List<TRTCCloudListener>
A constant List of the values in this enum, in order of their declaration.