Event Callback

Callback List

EventDescription
token_requestThe token expired, needs to be updated immediately
token_will_expireThe token will expire, needs to be updated
sdk_auth_resultReturn the token authentication results
publish_auth_failFailure to pass the publishing authentication will cut off the publishing
audio_track_endThe audio track ended, often encountered during mid-publishing microphone disconnection
video_track_endThe video track ended, often encountered during the mid-publishing camera disconnection
remote_stream_addDetect a remote media stream in the room, which you can subscribe to according to your requirements
remote_stream_removeWhen a remote media stream stops, the subscription is canceled according to the service requirements
remote_stream_updateThe remote stream is updating. No need to process it
player_state_changeThe player status changes
stream_reconnect_startThe media stream starts reconnecting
stream_reconnect_endThe media stream reconnected
first_audio_frame_decodeSubscribe to the first frame of the decoded audio
first_video_frame_decodeSubscribe to the first frame of the decoded video
active_speakerThe user with the loudest voice in the channel changes
audio_level_reportReport volume events regularly every 2 seconds
audio_input_changedThe audio input device added or removed
video_input_changedThe video input device added or removed
audio_output_changedThe audio output device added or removed
audio_mixing_playedThe audio mixing published
audio_mixing_finishedThe audio mixing completed
network_scoreReport the local user's uplink and downlink network quality scores every 2 seconds
connectedServer connection succeeded
reconnectReconnecting to the server
exceptionMedia stream abnormality and recovery
push_stream_statusStream pushing status
mute_playMute
mute_play_resumeUmute

Callback Details

token_request

on(event: "token_request", callback: (event: string, data: { uid: string }) => void);

The token expired and needs to be updated immediately.

ParameterDescription
event'token_request'
data.uidUser ID

token_will_expire

on(event: "token_will_expire", callback: (event: string, data: { uid: string, token: string }) => void);

The token will expire and needs to be updated.

ParameterDescription
event'token_will_expire'
data.uidUser ID
data.tokenCurrent token

sdk_auth_result

on(event: "sdk_auth_result", callback: (event: string, data: { uid: string, result: number }) => void);

Return the token authentication results

ParameterDescription
event'sdk_auth_result'
data.uidUser ID
data.resultnumber type, see details in the table below
Return CodeDescription
0Authentication succeeded
10000Internal server error, try again
10001Without token
10002The token authentication failed (incorrect digital signature), which may be caused by incorrect appSecret
10003The appid in the token is inconsistent with the appid when authentication is executed
10004The uid in the token is inconsistent with the uid when authentication is executed
10005The token expired
10006The application does not exist, which is not registered in the management background
10007The token will expire
10008The user is banned

publish_auth_fail

on(event: "publish_auth_fail", callback: (event: string, data: { uid: string, result: number }) => void);

Indicate failure to pass the publishing stream authentication.

audio_track_end

on(event: "audio_track_end", callback: (event: string, data: { uid: string, roomId: string }) => void);

The audio track ended, often encountered when the microphone disconnects during the publishing.

ParameterDescription
event'audio_track_end'
data.uidUser ID
data.roomIdUser's room ID

video_track_end

on(event: "video_track_end", callback: (event: string, data: { uid: string, roomId: string }) => void);

The video track ended, often encountered when the camera disconnects during the publishing.

ParameterDescription
event'video_track_end'
data.uidUser ID
data.roomIdUser's room ID

remote_stream_add

on(event: "remote_stream_add", callback: (event: string, remoteStream: RemoteStream) => void);

Detect a remote media stream in the channel; you can then subscribe according to the service requirements.

Parameter

ParameterDescription
event'remote_stream_add'
remoteStreamRemoteStream remote stream information

remote_stream_remove

on(event: "remote_stream_remove", callback: (event: string, remoteStream: RemoteStream) => void);

When a remote media stream stops, the subscription is canceled according to the service requirements.

Parameter

ParameterDescription
event'remote_stream_remove'
remoteStreamRemoteStream remote stream information

remote_stream_update

on(event: "remote_stream_update", callback: (event: string, remoteStream: RemoteStream) => void);

The remote stream is updating. No need to process it.

Parameters

ParameterDescription
event'remote_stream_update'
remoteStreamRemote stream information

player_state_change

on(event: "player_state_change", callback: (event: string, data: { uid: string, reason: string, state: string }) => void);

The player status changes.

ParameterDescription
event'player_state_change'
data.uidUser ID
data.reasonReason for change
data.stateThe current player status. "pause": playing paused, "play": currently playing, "end": playing completed

stream_reconnect_start

on(event: "stream_reconnect_start", callback: (event: string, data: { uid: string, roomId: string }) => void);

The media stream has started reconnecting.

ParameterDescription
event'stream_reconnect_start'
data.uidUser ID of the media stream
data.roomIdRoom ID of the media stream

stream_reconnect_end

on(event: "stream_reconnect_end", callback: (event: string, data: { uid: string, roomId: string }) => void);

The media stream reconnected.

ParameterDescription
event'stream_reconnect_end'
data.uidUser ID of the media stream
data.roomIdRoom ID of the media stream

first_audio_frame_decode

on(event: "first_audio_frame_decode", callback: (event: string, data: { uid: string, roomId: string }) => void);

Subscribe to the first frame of the decoded audio.

ParameterDescription
event'first_audio_frame_decode'
data.uidUser ID of the media stream
data.roomIdRoom ID of the media stream

first_video_frame_decode

on(event: "first_video_frame_decode", callback: (event: string, data: { uid: string, roomId: string }) => void);

Subscribe to the first frame of the decoded video.

ParameterDescription
event'first_video_frame_decode'
data.uidUse ID of the media
data.roomIdRoom ID of the media stream

active_speaker

on(event: "active_speaker", callback: (event: string, uid: string) => void);

The user with the loudest voice in the channel changes.

Note:

  • Calculation includes the local anchor stream
  • Calculated as well with the local anchor stream publishing
ParameterDescription
event'active_speaker'
uidThe loudest user's ID

audio_level_report

on(event: "audio_level_report", callback: (event: string, data: {uid: string, audioLevel: number}[]) => void);

Enable volume events reporting (every 2 seconds) by calling enableAudioLevelReport.

ParameterDescription
event'audio_level_report'
DateArray; each element includes uid and audioLevel, indicating the specified user's volume

example

webRtc.on("audio_level_report", (event, data)=>{
    for (let item of data) {
        console.log(`uid: ${item.uid}, audioLevel: ${item.audioLevel}`);
    }
});

audio_input_changed

on(event: "audio_input_changed", callback: (event: string, data: { state: 'added' | 'removed', deviceId: string }) => void);

The audio input device added or removed.

Detect and report after the room joined.

ParameterDescription
event'audio_input_changed'
data.state'added': the added device; 'removed': the removed device
data.deviceIdDevice ID

video_input_changed

on(event: "video_input_changed", callback: (event: string, data: { state: 'added' | 'removed', deviceId: string }) => void);

The video input device added or removed.

Detect and report after joing the room.

ParameterDescription
event'video_input_changed'
data.state'added': the added device; 'removed': the removed devices
data.deviceIdDevice ID

audio_output_changed

on(event: "audio_output_changed", callback: (event: string, data: { state: 'added' | 'removed', deviceId: string }) => void);

The audio output device added or removed.

Detect and report after joing the room.

ParameterDescription
event'audio_output_changed'
data.state'added' indicates the added devices; 'removed' indicates the removed devices
data.deviceIdDevice ID

audio_mixing_played

on(event: "audio_mixing_played", callback: (event: string, data: { id: number, fileName: string }) => void);

Playing the mixed audio started.

ParameterDescription
event'audio_mixing_played'
data.idMixed audio ID
data.fileNameName of the mixed audio file

audio_mixing_finished

on(event: "audio_mixing_finished", callback: (event: string, data: { id: number }) => void);

Playing the mixed audio completed.

ParameterDescription
event'audio_mixing_finished'
data.idMixed audio ID

network_score

on(event: "network_score", callback: (event: string, data: { uplinkNetworkScore: number, downlinkNetworkScore: number }) => void);

Report the local user's uplink and downlink network quality scores every 2 seconds.

Quality score standards: 0: unknown network quality; 1-5: excellent to very bad network quality; 6: network disconnected.

ParameterDescription
event'network_score'
data.uplinkNetworkScoreUplink network score
data.downlinkNetworkScoreDownlink network score

connected

on(event: "connected", callback: (event: string, data: { uid: string, roomId: string }) => void);

Connection to the server succeeded.

ParameterDescription
event'connected'
data.uidUser ID
data.roomIdUser's room ID

reconnect

on(event: "reconnect", callback: (event: string, data: { uid: string, roomId: string }) => void);

Connecting to the server.

ParameterDescription
event'reconnect'
data.uidUser ID
data.roomIdUser's room ID

exception

on(event: "exception", callback: (event: string, data: { uid: string, roomId: string, error: string }) => void);

Abnormality and recovery.

Abnormal ContentDescription
AUDIO_RECEIVE_BITRATE_TOO_LOW(_RESUME)Audio receiving bit rate is too low (resumed)
AUDIO_SEND_BITRATE_TOO_LOW(_RESUME)Audio sending bit rate is too low (resumed)
VIDEO_DECODE_FRAMERATE_TOO_LOW(_RESUME)Video decoding frame rate too low (resumed)
VIDEO_RECEIVE_BITRATE_TOO_LOW(_RESUME)Video receiving bit rate is too low (resumed)
VIDEO_RECEIVE_FRAMERATE_TOO_LOW(_RESUME)Video receiving frame rate is too low (resumed)
VIDEO_ENCODE_FRAMERATE_TOO_LOW(_RESUME)Video encoding frame rate is too low (resumed)
VIDEO_SEND_BITRATE_TOO_LOW(_RESUME)Video sending bit rate is too low (resumed)
VIDEO_SEND_FRAMERATE_TOO_LOW(_RESUME)Video sending frame rate is too low (resumed)

push_stream_status

on(event: "push_stream_status", callback: (event: string, data: { url: string, status: string, reason: string }) => void);

Push-stream status callabck.

ParameterDescription
event'push_stream_status'
data.urlPush-stream URL
data.statusPush-stream status
PUSH_STREAM_ONGOING: pushing
PUSH_STREAM_FAILED: failed
INTERNEL_ERROR: internal error
PUSH_STREAM_FINISHED: pushed
data.reasonReserved

mute_play

on(event: "mute_play", callback: (event: string, data: {uid : string }) => void);

Mute.

ParameterDescription
event'mute_play'
data.uidID of the user to whom the audio stream belongs

mute_play_resume

on(event: "mute_play_resume", callback: (event: string, data: {uid : string }) => void);

Umute.

ParameterDescription
event'mute_play_resume'
data.uidID of the user to whom the audio stream belongs

Was this page helpful?

Helpful Not helpful
Submitted! Your feedback would help us improve the website.
Feedback
Top