Occurs when a remote user or host joins the channel.
The SDK triggers this callback when one of the following situations occurs:
Occurs when a remote user becomes offline.
The SDK triggers this callback when one of the following situations occurs:
In live-broadcast channels, the SDK triggers this callback only when a host goes offline.
Occurs when a remote user publishes an audio or video track.
You can subscribe to and play the audio or video track in this callback. See subscribe and [RemoteTrack.play]IRemoteTrack.play.
The SDK also triggers this callback to report the existing tracks in the channel when a user joins the channel.
client.on("user-published", async (user, mediaType) => {
await client.subscribe(user, mediaType);
if (mediaType === "video") {
console.log("subscribe video success");
user.videoTrack.play("xxx");
}
if (mediaType === "audio") {
console.log("subscribe audio success");
user.audioTrack.play();
}
})
Occurs when a remote user unpublishes an audio or video track.
Reports the state change of users.
In most cases, you only need to listen for [user-published]IAgoraRTCClient.event_user_published and [user-unpublished]IAgoraRTCClient.event_user_unpublished events for operations including subscribing, unsubscribing, and displaying whether the remote user turns on the camera and microphone. You do not need to pay special attention to user states since the SDK automatically handles user states.
This event indicating the media stream of a remote user is active does not necessarily mean that the local user can subscribe to this remote user. The local user can subscribe to a remote user only when receiving the [user-published]IAgoraRTCClient.event_user_published event.
Occurs when the SDK starts to reestablish the media connection for publishing and subscribing.
Occurs when the SDK ends reestablishing the media connection for publishing and subscribing.
Occurs when the type of a remote video stream changes.
The SDK triggers this callback when a high-quality video stream changes to a low-quality video stream, or vice versa.
Occurs when a remote video stream falls back to an audio stream due to unreliable network conditions or switches back to video after the network conditions improve.
Occurs when the state of the media stream relay changes.
The SDK reports the state and error code of the current media relay with this callback.
If the media relay is in an abnormal state, you can find the error code in ChannelMediaRelayError (for example if the token has expired, or repeated reconnection attempts fail.)
Reports events during a media stream relay.
Reports all the speaking remote users and their volumes.
It is disabled by default. You can enable this callback by calling enableAudioVolumeIndicator. If enabled, it reports the users' volumes every two seconds regardless of whether there are users speaking.
The volume is an integer ranging from 0 to 100. Usually a user with volume above 60 is a speaking user.
client.on("volume-indicator", function(result){
result.forEach(function(volume, index){
console.log(`${index} UID ${volume.uid} Level ${volume.level}`);
});
});
Occurs when decryption fails.
The SDK triggers this callback when the decryption fails during the process of subscribing to a stream. The failure is usually caused by incorrect encryption settings. See setEncryptionConfig for details.
Occurs 30 seconds before a token expires.
You must request a new token from your server and call renewToken to pass a new token as soon as possible.
client.on("token-privilege-will-expire", async function(){
// After requesting a new token
await client.renewToken(token);
});
Occurs when the token expires.
You must request a new token from your server and call join to use the new token to join the channel.
client.on("token-privilege-did-expire", async () => {
// After requesting a new token
await client.join(<APPID>, <CHANNEL NAME>, <NEW TOKEN>);
});
Reports the network quality of the local user.
After the local user joins the channel, the SDK triggers this callback to report the uplink and downlink network conditions of the local user once every two second.
Agora recommends listening for this event and displaying the network quality.
Occurs when an error occurs in CDN live streaming.
After the method call of startLiveStreaming succeeds, the SDK triggers this callback when errors occur during CDN live streaming.
You can visit err.code
to get the error code. The errors that you may encounter include:
LIVE_STREAMING_INVALID_ARGUMENT
: Invalid argument.LIVE_STREAMING_INTERNAL_SERVER_ERROR
: An error occurs in Agora's streaming server.LIVE_STREAMING_PUBLISH_STREAM_NOT_AUTHORIZED
: The URL is occupied.LIVE_STREAMING_TRANSCODING_NOT_SUPPORTED
: Sets the transcoding parameters when the transcoding is not enabled.LIVE_STREAMING_CDN_ERROR
: An error occurs in the CDN.LIVE_STREAMING_INVALID_RAW_STREAM
: Timeout for the CDN live streaming. Please check your media stream.Occurs when a warning occurs in CDN live streaming.
After the method call of startLiveStreaming succeeds, the SDK triggers this callback when warnings occur during CDN live streaming.
You can visit err.code
to get the warning code. The warnings that you may encounter include:
LIVE_STREAMING_WARN_STREAM_NUM_REACH_LIMIT
: Pushes stremas to more than 10 URLs.LIVE_STREAMING_WARN_FAILED_LOAD_IMAGE
: Fails to load the background image or watermark image.LIVE_STREAMING_WARN_FREQUENT_REQUEST
: Pushes stremas to the CDN too frequently.Reports exceptions in the channel.
Exceptions are not errors, but usually reflect quality issues.
This callback also reports recovery from an exception.
Each exception corresponds to a recovery event.
Exception
Code | Message | Exception |
---|---|---|
1001 | FRAMERATE_INPUT_TOO_LOW | Captured video frame rate is too low |
1002 | FRAMERATE_SENT_TOO_LOW | Sent video frame rate is too low |
1003 | SEND_VIDEO_BITRATE_TOO_LOW | Sent video bitrate is too low |
1005 | RECV_VIDEO_DECODE_FAILED | Decoding received video fails |
2001 | AUDIO_INPUT_LEVEL_TOO_LOW | Sent audio volume is too low |
2002 | AUDIO_OUTPUT_LEVEL_TOO_LOW | Received audio volume is too low |
2003 | SEND_AUDIO_BITRATE_TOO_LOW | Sent audio bitrate is too low |
2005 | RECV_AUDIO_DECODE_FAILED | Decoding received audio fails |
Recoveries
Code | Message | Recovery |
---|---|---|
3001 | FRAMERATE_INPUT_TOO_LOW_RECOVER | Captured video frame rate recovers |
3002 | FRAMERATE_SENT_TOO_LOW_RECOVER | Sent video frame rate recovers |
3003 | SEND_VIDEO_BITRATE_TOO_LOW_RECOVER | Sent video bitrate recovers |
3005 | RECV_VIDEO_DECODE_FAILED_RECOVER | Decoding received video recovers |
4001 | AUDIO_INPUT_LEVEL_TOO_LOW_RECOVER | Sent audio volume recovers |
4002 | AUDIO_OUTPUT_LEVEL_TOO_LOW_RECOVER | Received audio volume recovers |
4003 | SEND_AUDIO_BITRATE_TOO_LOW_RECOVER | Sent audio bitrate recovers |
4005 | RECV_AUDIO_DECODE_FAILED_RECOVER | Decoding received audio recovers |
Since
4.4.0
The SDK triggers this callback to indicate whether the media stream is forwarded by the Agora cloud proxy service.
Since
4.9.0
Occurs when the SDK automatically switches to TCP/TLS 443.
As of v4.11.0, if the SDK fails in the attempt to directly connect to Agora SD-RTN™ after you call [[join]], the SDK automatically switches to TCP/TLS 443 in order to ensure connectivity.
Since
4.11.0
If you enable support for 128 hosts in a channel, this callback is triggered when [[join]] is called. The callback reports remote users who publish audio and/or video tracks in the channel.
Note:
- For the
published-user-list
to be triggered, every user in the channel must use a number as their user ID (uid
).published-user-list
has the following impacts on [AgoraRTCClient.on("user-joined")]event_user_joined and [AgoraRTCClient.on("user-published")]event_user_published:
- If you listen for the
published-user-list
event, users reported by thepublished-user-list
callback are not reported byuser-joined
anduser-published
.- If you do not listen for the
published-user-list
event, theuser-joined
anduser-published
callbacks are not affected.
Occurs when the state of the connection between the SDK and the server changes.
Occurs when the state of the connection between the SDK and the server changes.
Callback for receiving the DataStream message.
Occurs when the state of the connection between the SDK and the server changes.