This topic describes the callback interfaces for the web audio and video call API.
OnMediaCallSucc(sid)
The audio and video initialization is complete.
OnMediaCallFail(err_code, err_msg)
Failed to initialize audio and video.
Parameters:
Callback parameter | Type | Description |
|---|---|---|
err_code | int | Returned when the audio and video call fails to initialize:
|
err_msg | String | The status message. |
OnInviteRequest(roomId, rtoken, inviter, extra)
The invitee receives an invitation message titled "Join Channel".
Parameters:
Callback parameter | Type | Description |
|---|---|---|
roomId | String | The channel ID. |
rtoken | String | The channel token. |
inviter | String | The UID of the inviter. |
extra | String | The pass-through field for business data. |
OnInviteReply(invitee, reply)
The inviter receives a reply to the channel invitation.
Parameters:
Callback parameter | Type | Description |
|---|---|---|
invitee | String | The UID of the invitee. |
reply | int |
|
OnRoomAttendanceList(participants)
Pushes the channel participant list to a new participant.
Parameters:
Callback parameter | Type | Value | Value type | Description |
|---|---|---|---|---|
participants | jsonarray | uid | String | The UID of the channel participant. |
userType | int | The user type of the participant:
| ||
publish | jsonarray | The published stream. | ||
feedId | String | The ID of the stream published by the channel participant. | ||
tag | String | The tag that corresponds to the feedId. |
OnNewJoinerIn(participant)
Push a notification about the new channel member to the participants.
Parameters:
Callback parameter | Type | Description |
|---|---|---|
participant | String | The UID of the new joiner. |
OnNewPublish(feed)
Notify the attendees that a new publication is available.
Parameters:
Callback parameter | Type | Description |
|---|---|---|
feed | JSON | Information about the new published stream:
|
OnNewSubscribe(subscriber,feed)
Pushes a 'new subscription' message to participants.
Parameters:
Callback parameter | Type | Description |
|---|---|---|
subscriber | String | The ID of the new subscriber. |
feed | JSON | Information about the new subscribed stream:
|
OnUnSubscribe(unsubscriber,feed)
You can send "unsubscribe" to attendees.
Parameters:
Callback parameter | Type | Description |
|---|---|---|
unsubscriber | String | Unsubscriber ID |
feed | JSON | Information about the unsubscribed stream:
|
OnMediaClose(code, sid)
Audio and video shutdown notifications.
Parameters:
Callback parameter | Type | Description |
|---|---|---|
code | int | Normal states:
Abnormal states:
|
sid | int | The stream ID. |
OnReceiveTextMsg(uid, msg)
Send a text message.
Parameters:
Callback parameter | Type | Description |
|---|---|---|
uid | String | The sender of the text message. |
msg | String | The text of the message. |
OnParticipantLeaveRoom(participant, exitType)
A callback that notifies the remaining participants when another participant leaves the channel.
Parameters:
Callback parameter | Type | Description |
|---|---|---|
participant | String | The ID of the participant who left. |
exitType | int | The exit type:
|
OnNetworkWeak(bpsSend, bpsRecv, sid)
A callback for a weak network connection.
Parameters:
Callback parameter | Type | Description |
|---|---|---|
bpsSend | String | The data sent per second, in bits. |
bpsRecv | String | The data received per second, in bits. |
sid | int | The stream ID. This helps identify which stream has a weak network connection. |
OnVodOver(vod_id)
Notification of audio-on-demand completion.
Parameters:
Callback parameter | Type | Description |
|---|---|---|
vod_id | String | The video-on-demand ID. |
OnVolumeAnalyser(sid, analyser)
A callback for real-time volume data.
Parameters:
Callback parameter | Type | Description |
|---|---|---|
sid | String | The stream ID. |
analyser | AnalyserNode | Returns an AnalyserNode object. |
OnClientRecordBlob(clientRecordId, blob)
Browser recording pushes data as BLOBs.
Parameters:
Callback parameter | Type | Description |
|---|---|---|
clientRecordId | String | The browser recording ID. |
blob | Blob | Saves the data as a multimedia file using a BLOB object. |
OnRemoteRecordOver(record_id)
A callback for when the server-side recording ends.
Parameters:
Callback parameter | Type | Description |
|---|---|---|
record_id | String | The recording ID. |
OnRemoteRecordingFailed(recordId, feedId, code, msg)
A callback for when the server-side recording fails.
Parameters:
Callback parameter | Type | Description |
|---|---|---|
recordId | String | The recording ID. |
feedId | String | The ID of the stream related to the event. |
code | int | Returned when the server-side recording fails:
|
msg | String | The status message. |
OnReceiveData
Accepts channel data.
Parameters:
Callback parameter | Type | Description |
|---|---|---|
data | String | The information received by the callback parameter. |
StreamFilterHandler
A handler that processes a stream based on custom business logic.
The StreamFilterHandler must be an asynchronous function or return a Promise object. The SDK uses then() to handle the processed stream.
Parameters:
Callback parameter | Type | Description |
|---|---|---|
publish_tag | String | The custom tag content. |
stream | MediaStream | The stream to be processed. |
stream_type | String | The publishing type: publish (publish a stream) or subscribe (subscribe to a stream). |
publish_device | int | This parameter is used only when stream_type is set to publish. For more information, see InitRoomConfig. |
media_type | String | The information received by the callback parameter. |
OnDesktopDisplayClosed
A callback for when screen sharing stops.
Callback parameters: None.
OnFileStreamClosed
The shared file is closed in the OnFileStreamClosed callback.
Callback parameters: None.
OnParticipantEvent
A callback for an event sent by a remote user.
Parameters:
Callback parameter | Type | Description |
|---|---|---|
uid | String | The remote user. |
eventType | int | The event type. |
eventDescription | String | The event description. |
eventExtra | Object | The event data (optional). |