Class: ZegoExpressEngine

ZegoExpressEngine()

ZegoExpressEngine

Constructor

new ZegoExpressEngine()

Source:

Methods

addPublishCdnUrl(streamID, targetURL) → {Promise.<number>}

Adds a target CDN URL to which the stream will be relayed from ZEGO RTC server. Description: Forward audio and video streams from ZEGO RTC servers to custom CDN content distribution networks with high latency but support for high concurrent pull streams. Use cases: 1. It is often used in large-scale live broadcast scenes that do not have particularly high requirements for delay. 2. Since ZEGO RTC server itself can be configured to support CDN(content distribution networks), this function is mainly used by developers who have CDN content distribution services themselves. 3. This function supports dynamic relay to the CDN content distribution network, so developers can use this function as a disaster recovery solution for CDN content distribution services. When to call: After calling the [initWithProfile/init] function to create the engine. Restrictions: When the [enablePublishDirectToCDN] function is set to true to publish the stream straight to the CDN, then calling this function will have no effect. Related APIs: Remove URLs that are re-pushed to the CDN [removePublishCdnUrl].
Parameters:
Name Type Description
streamID string Stream ID.
targetURL string CDN relay address, supported address format is rtmp.
Source:
Returns:
- The execution result of update the relay CDN operation.
Type
Promise.<number>

callExperimentalAPI(params) → {string}

Call the RTC experimental API ZEGO provides some technical previews or special customization functions in RTC business through this API. If you need to get the use of the function or the details, please consult ZEGO technical support
Parameters:
Name Type Description
params string You need to pass in a parameter in the form of a JSON string
Source:
Returns:
- Returns an argument in the format of a JSON string
Type
string

createMediaPlayer() → {ZegoMediaPlayer}

Creates a media player instance. Description: Creates a media player instance. Use case: It is often used to play media resource scenes, For example, play video files, push the video of media resources in combination with custom video acquisition, and the remote end can pull the stream for viewing. When to call: It can be called after the SDK has been initialized [initWithProfile/init]. Restrictions: Currently, a maximum of 4 instances can be created, after which it will return null. Caution: The more instances of a media player, the greater the performance overhead on the device. Related APIs: User can call [destroyMediaPlayer] function to destroy a media player instance.
Source:
Returns:
- Media player instance, null will be returned when the maximum number is exceeded.
Type
ZegoMediaPlayer

destroyMediaPlayer(mediaPlayer)

Destroys a media player instance. Description: Destroys a media player instance. Related APIs: User can call [createMediaPlayer] function to create a media player instance.
Parameters:
Name Type Description
mediaPlayer ZegoMediaPlayer The media player instance object to be destroyed.
Source:

enableAEC(enable)

Whether to enable acoustic echo cancellation (AEC). Description: Turning on echo cancellation, the SDK filters the collected audio data to reduce the echo component in the audio. Use case: When you need to reduce the echo to improve the call quality and user experience, you can turn on this feature. Default value: When this function is not called, echo cancellation is enabled by default. When to call: It needs to be called after init SDK [initWithProfile/init], before [startPublishingStream], [startPlayingStream], [startPreview], [createMediaPlayer], [createAudioEffectPlayer]. Caution: The AEC function only supports the processing of sounds playbacked through the SDK, such as sounds played by the playing stream, media player, audio effect player, etc. Restrictions: None. Related APIs: Developers can use [enableHeadphoneAEC] to set whether to enable AEC when using headphones, and use [setAECMode] to set the echo cancellation mode.
Parameters:
Name Type Description
enable boolean Whether to enable echo cancellation, true: enable, false: disable
Source:

enableAGC(enable)

Enables or disables automatic gain control (AGC). Description: After turning on this function, the SDK can automatically adjust the microphone volume to adapt to near and far sound pickups and keep the volume stable. Use case: When you need to ensure volume stability to improve call quality and user experience, you can turn on this feature. Default value: When this function is not called, AGC is enabled by default. When to call: It needs to be called after init SDK [initWithProfile/init] and before [startPublishingStream], [startPlayingStream], [startPreview], [createMediaPlayer] and [createAudioEffectPlayer]. Note that the Mac needs to be called after [startPreview] and before [startPublishingStream]. Restrictions: None.
Parameters:
Name Type Description
enable boolean Whether to enable automatic gain control, true: enable, false: disable
Source:

enableANS(enable)

Enables or disables active noise suppression (ANS, aka ANC). Description: Enable the noise suppression can reduce the noise in the audio data and make the human voice clearer. Use case: When you need to suppress noise to improve call quality and user experience, you can turn on this feature. Default value: When this function is not called, ANS is enabled by default. When to call: It needs to be called after init SDK [initWithProfile/init], before [startPublishingStream], [startPlayingStream], [startPreview], [createMediaPlayer], [createAudioEffectPlayer]. Related APIs: This function has a better suppression effect on continuous noise (such as the sound of rain, white noise). If you need to turn on transient noise suppression, please use [enableTransientANS]. And the noise suppression mode can be set by [setANSMode]. Restrictions: None.
Parameters:
Name Type Description
enable boolean Whether to enable noise suppression, true: enable, false: disable
Source:

enableAudioCaptureDevice(enable)

Enables or disables the audio capture device. Description: This function is used to control whether to release the audio collection device. When the audio collection device is turned off, the SDK will no longer occupy the audio device. Of course, if the stream is being published at this time, there is no audio data. Use cases: When the user never needs to use the audio, you can call this function to close the audio collection. Default value: The default is `false`. When to call: After creating the engine [initWithProfile/init]. Restrictions: None. Related APIs: Turning off or turning on the microphone on the hardware is a time-consuming operation, and there is a certain performance overhead when the user performs frequent operations. [muteMicrophone] is generally recommended.
Parameters:
Name Type Description
enable boolean Whether to enable the audio capture device, `true`: disable audio capture device, `false`: enable audio capture device.
Source:

enableCamera(enable, channel)

Turns on/off the camera (for the specified channel). Description: This function is used to control whether to start the camera acquisition. After the camera is turned off, video capture will not be performed. At this time, the publish stream will also have no video data. Default value: The default is `true` which means the camera is turned on. When to call: After creating the engine [initWithProfile/init]. Restrictions: None. Caution: In the case of using the custom video capture function [enableCustomVideoCapture], since the developer has taken over the video data capture, the SDK is no longer responsible for the video data capture, but this function still affects whether to encode or not. Therefore, when developers use custom video capture, please ensure that the value of this function is `true`.
Parameters:
Name Type Description
enable boolean Whether to turn on the camera, `true`: turn on camera, `false`: turn off camera
channel ZegoPublishChannel Publishing stream channel
Source:

enableCheckPoc(enable)

Enables or disables frame order detection. Description: Control whether to turn on frame order detection, on to not support B frames, off to support B frames. Use cases: Turning on frame order detection when pulling cdn's stream will prevent splash screens. Default value: Turn on frame order detection by default when this interface is not called. When to call: This function needs to be called after [initWithProfile/init] creates an instance. Restrictions: None. Caution: Turn off frame order detection during playing stream may result in a brief splash screen.
Parameters:
Name Type Description
enable boolean Whether to turn on frame order detection, true: enable check poc,not support B frames, false: disable check poc, support B frames.
Source:

enableConsolePrintDebugInfo(enable)

Turns on/off print debugging info on the console
Parameters:
Name Type Description
enable boolean Detailed debugging information switch
Source:

enableCustomVideoCapture(enable, channel)

Enables or disables custom video capture (for the specified channel). Description: If the value of enable is true, the video collection function is enabled. If the value of enable is false, the video collection function is disabled. Use case: The App developed by the developer uses the beauty SDK of a third-party beauty manufacturer to broadcast non-camera collected data. Default value: When this function is not called, custom video collection is disabled by default. When to call: After init SDK [initWithProfile/init], call [startPreview], [startPublishingStream], and call [logoutRoom] to modify the configuration. Caution: Custom video rendering can be used in conjunction with custom video capture, but when both are enabled, the local capture frame callback for custom video rendering will no longer be triggered, and the developer should directly capture the captured video frame from the custom video capture source. Related callbacks: When developers to open a custom collection, by calling [setCustomVideoCaptureHandler] can be set up to receive a custom collection start-stop event notification.
Parameters:
Name Type Description
enable boolean enable or disable
channel ZegoPublishChannel publish channel
Source:

enableCustomVideoProcess(enable, channel)

Enables or disables custom video processing. When developers to open before the custom processing, by calling [setCustomVideoCaptureHandler] can be set up to receive a custom video processing of the original video data Precondition:Call [initWithProfile/init] to initialize the Zego SDK. Call timing:must be set before calling [startPreview], [startPublishingStream]; The configuration cannot be changed again until the [logoutRoom] is called, otherwise the call will not take effect
Parameters:
Name Type Description
enable boolean enable or disable. disable by default
channel ZegoPublishChannel Publishing stream channel
Source:

enableHardwareDecoder(enable)

Enables or disables hardware decoding. Description: Control whether hardware decoding is used when playing streams, with hardware decoding enabled the SDK will use the GPU for decoding, reducing CPU usage. Use cases: If developers find that the device heats up badly when playing large resolution audio and video streams during testing on some models, consider calling this function to enable hardware decoding. Default value: Hardware decoding is disabled by default when this interface is not called. When to call: This function needs to be called after [initWithProfile/init] creates an instance. Restrictions: None. Caution: Need to be called before calling [startPlayingStream], if called after playing the stream, it will only take effect after stopping the stream and re-playing it. Once this configuration has taken effect, it will remain in force until the next call takes effect.
Parameters:
Name Type Description
enable boolean Whether to turn on hardware decoding switch, true: enable hardware decoding, false: disable hardware decoding.
Source:

enableHardwareEncoder(enable)

Enables or disables hardware encoding. Description: Whether to use the hardware encoding function when publishing the stream, the GPU is used to encode the stream and to reduce the CPU usage. When to call: The setting can take effect before the stream published. If it is set after the stream published, the stream should be stopped first before it takes effect. Caution: Because hard-coded support is not particularly good for a few models, SDK uses software encoding by default. If the developer finds that the device is hot when publishing a high-resolution audio and video stream during testing of some models, you can consider calling this function to enable hard coding.
Parameters:
Name Type Description
enable boolean Whether to enable hardware encoding, true: enable hardware encoding, false: disable hardware encoding.
Source:

enableHeadphoneMonitor(enable)

Enables or disables headphone monitoring. Description: Enable/Disable headphone monitor, and users hear their own voices as they use the microphone to capture sounds. When to call: After the engine is created [initWithProfile/init]. Default value: Disable. Caution: This setting does not actually take effect until both the headset and microphone are connected.
Parameters:
Name Type Description
enable boolean Whether to use headphone monitor, true: enable, false: disable
Source:

enableMixSystemPlayout(enable)

Enable or disable system audio capture. Description: Enable sound card capture to mix sounds played by the system into the publishing stream, such as sounds played by the browser, sounds played by the third-party player, etc. Default value: Default is disable. When to call: Called this function after calling [startPublishingStream] or [startPreview]. Restrictions: None. Caution: The system sound card sound does not include streaming sound, media player sound and sound effect player sound. Related APIs: [setMixSystemPlayoutVolume] function can set system audio capture volume. Platform differences: Only supports Windows and macOS.
Parameters:
Name Type Description
enable boolean Whether to mix system playout.
Source:

enablePublishDirectToCDN(enable, confignullable, channel)

Whether to directly push to CDN (without going through the ZEGO RTC server), for the specified channel. Description: Whether to publish streams directly from the client to CDN without passing through Zego RTC server. Use cases: It is often used in large-scale live broadcast scenes that do not have particularly high requirements for delay. Default value: The default is false, and direct push is not enabled. When to call: After creating the engine [initWithProfile/init], before starting to push the stream [startPublishingStream]. Caution: The Direct Push CDN feature does not pass through the ZEGO Real-Time Audio and Video Cloud during network transmission, so you cannot use ZEGO's ultra-low latency audio and video services. Related APIs: Dynamic re-push to CDN function [addPublishCdnUrl], [removePublishCdnUrl].
Parameters:
Name Type Attributes Description
enable boolean Whether to enable direct publish CDN, true: enable direct publish CDN, false: disable direct publish CDN.
config ZegoCDNConfig <nullable>
CDN configuration, if null, use Zego's background default configuration.
channel ZegoPublishChannel Publish stream channel.
Source:

enableTrafficControl(enable, property)

Enables or disables traffic control. Description: Enabling traffic control allows the SDK to adjust the audio and video streaming bitrate according to the current upstream network environment conditions, or according to the counterpart's downstream network environment conditions in a one-to-one interactive scenario, to ensure smooth results. At the same time, you can further specify the attributes of traffic control to adjust the corresponding control strategy. Default value: Enable. When to call: After the engine is created [initWithProfile/init], Called before [startPublishingStream] can take effect. Restrictions: Only support RTC publish. Caution: Act on the main publish channel ZegoPublishChannel.Main.
Parameters:
Name Type Description
enable boolean Whether to enable traffic control. The default is ture.
property number Adjustable property of traffic control, bitmask format. Should be one or the combinations of [ZegoTrafficControlProperty] enumeration. [AdaptiveFPS] as default.
Source:

enableTransientANS(enable)

Enables or disables transient noise suppression. Description: Enable the transient noise suppression can suppress the noises such as keyboard and desk knocks. Use case: When you need to suppress transient noise to improve call quality and user experience, you can turn on this feature. Default value: When this function is not called, this is disabled by default. When to call: It needs to be called after init SDK [initWithProfile/init], before [startPublishingStream], [startPlayingStream], [startPreview], [createMediaPlayer], [createAudioEffectPlayer]. Related APIs: This function will not suppress normal noise after it is turned on. If you need to turn on normal noise suppression, please use [enableANS]. Restrictions: None.
Parameters:
Name Type Description
enable boolean Whether to enable transient noise suppression, true: enable, false: disable
Source:

enableVirtualStereo(enable, angle)

Enables the virtual stereo feature with publishing stream. Description: Call this function to enable/disable virtual stereo effect with publishing stream. Use cases: Often used in live broadcasting, voice chatroom and KTV. When to call: It needs to be called after init SDK [initWithProfile/init]. Restrictions: Virtual stereo effect is only effective for SDK captured sound. Caution: You need to set up a dual channel with [setAudioConfig] for the virtual stereo to take effect.
Parameters:
Name Type Description
enable boolean true to turn on the virtual stereo, false to turn off the virtual stereo.
angle number angle of the sound source in the virtual stereo, ranging from 0 to 180, with 90 being the front, and 0 and 180 being respectively Corresponds to rightmost and leftmost, usually use 90.
Source:

getAudioConfig() → {ZegoAudioConfig}

Gets the current audio configurations. Description: You can get the current audio codec, bit rate, and audio channel through this function. When to call: After the engine is created [initWithProfile/init]. Restrictions: None. Caution: Act on the main publish channel ZegoPublishChannel.Main. Related APIs: [setAudioConfig].
Source:
Returns:
- Audio config.
Type
ZegoAudioConfig

getAudioDeviceList(deviceType) → {Array.<ZegoDeviceInfo>}

Gets a list of audio devices.
Parameters:
Name Type Description
deviceType ZegoAudioDeviceType Audio device type
Source:
Returns:
- Audo device List
Type
Array.<ZegoDeviceInfo>

getAudioDeviceVolume(deviceType, deviceID) → {number}

Get volume for the specified audio device.
Parameters:
Name Type Description
deviceType ZegoAudioDeviceType Audio device type
deviceID string ID of a device obtained by [getAudioDeviceList]
Source:
Returns:
- Device volume
Type
number

getCurrentAudioDevice(deviceType) → {ZegoDeviceInfo}

Get the audio device information currently in use. Description: Get the audio device information currently in use. Use cases: Used for scenes that need to manually switch between multiple audio devices. When to call: Called this function after calling [startPublishingStream] or [startPreview]. Related APIs: The default audio device ID can be obtained through [getDefaultAudioDeviceID].
Parameters:
Name Type Description
deviceType ZegoAudioDeviceType Audio device type.Required:Yes.
Source:
Returns:
- Audio device information.
Type
ZegoDeviceInfo

getDefaultAudioDeviceID(deviceType) → {string}

Get the device ID of the default audio device.
Parameters:
Name Type Description
deviceType ZegoAudioDeviceType Audio device type
Source:
Returns:
- Default Audio device ID
Type
string

getDefaultVideoDeviceID() → {string}

Get the deviceID of the default video device.
Source:
Returns:
- Default video device ID
Type
string

getVersion() → {string}

Gets the SDK's version number. Description: If you encounter an abnormality during the running of the SDK, you can submit the problem, log and other information to the ZEGO technical staff to locate and troubleshoot. Developers can also collect current SDK version information through this API, which is convenient for App operation statistics and related issues. When to call: Any time. Restrictions: None. Caution: None.
Source:
Returns:
- SDK version
Type
string

getVideoConfig(channel) → {ZegoVideoConfig}

Gets the current video configurations (for the specified channel). This function can be used to get the specified publish channel's current video frame rate, bit rate, video capture resolution, and video encoding output resolution.
Parameters:
Name Type Description
channel ZegoPublishChannel Publish stream channel
Source:
Returns:
- Video configuration object
Type
ZegoVideoConfig

getVideoDeviceList() → {Array.<ZegoDeviceInfo>}

Gets a list of video devices.
Source:
Returns:
- Video device List
Type
Array.<ZegoDeviceInfo>

init(appID, appSign, isTestEnv, scenario)

Initializes the Engine. The engine needs to be initialized before calling other functions
Parameters:
Name Type Description
appID number Application ID issued by ZEGO for developers, please apply from the ZEGO Admin Console https://console-express.zego.im The value ranges from 0 to 4294967295.
appSign string Application signature for each AppID, please apply from the ZEGO Admin Console. Application signature is a 64 character string. Each character has a range of '0' ~ '9', 'a' ~ 'z'.
isTestEnv boolean Choose to use a test environment or a formal commercial environment, the formal environment needs to submit work order configuration in the ZEGO management console. The test environment is for test development, with a limit of 10 rooms and 50 users. Official environment App is officially launched. ZEGO will provide corresponding server resources according to the configuration records submitted by the developer in the management console. The test environment and the official environment are two sets of environments and cannot be interconnected.
scenario ZegoScenario The application scenario. Developers can choose one of ZegoScenario based on the scenario of the app they are developing, and the engine will preset a more general setting for specific scenarios based on the set scenario. After setting specific scenarios, developers can still call specific functions to set specific parameters if they have customized parameter settings.
Deprecated:
  • This method has been deprecated after version 0.25.3, please use the [initWithProfile] function to replace.
Source:

initWithProfile(profile)

Initializes the Engine. The engine needs to be initialized before calling other functions
Parameters:
Name Type Description
profile ZegoEngineProfile The basic configuration information is used to create the engine.
Source:

isMicrophoneMuted() → {boolean}

Checks whether the microphone is muted. Description: Used to determine whether the microphone is set to mute. When to call: After creating the engine [initWithProfile/init]. Restrictions: None. Related APIs: [muteMicrophone].
Source:
Returns:
- Whether the microphone is muted; true: the microphone is muted; `false`: the microphone is enable (not muted).
Type
boolean

isSpeakerMuted() → {boolean}

Checks whether the audio output speaker is muted. Description: Used to determine whether the audio output is muted. When to call: After creating the engine [initWithProfile/init]. Restrictions: None. Related APIs: [muteSpeaker].
Source:
Returns:
- Whether the speaker is muted; `true`: the speaker is muted; `false`: the speaker is enable (not muted).
Type
boolean

loginMultiRoom(roomID, config)

Logs in multi room. You must log in the main room with [loginRoom] before invoke this function to logging in to multi room. Currently supports logging into 1 main room and 1 multi room at the same time. When logging out, you must log out of the multi room before logging out of the main room. User can only publish the stream in the main room, but can play the stream in the main room and multi room at the same time, and can receive the signaling and callback in each room. The advantage of multi room is that you can login another room without leaving the current room, receive signaling and callback from another room, and play streams from another room. To prevent the app from being impersonated by a malicious user, you can add authentication before logging in to the room, that is, the [token] parameter in the ZegoRoomConfig object passed in by the [config] parameter. Different users who log in to the same room can get room related notifications in the same room (eg [onRoomUserUpdate], [onRoomStreamUpdate], etc.), and users in one room cannot receive room signaling notifications in another room. Messages sent in one room (e.g. [setStreamExtraInfo], [sendBroadcastMessage], [sendBarrageMessage], [sendCustomCommand], etc.) cannot be received callback ((eg [onRoomStreamExtraInfoUpdate], [onIMRecvBroadcastMessage], [onIMRecvBarrageMessage], [onIMRecvCustomCommand], etc) in other rooms. Currently, SDK does not provide the ability to send messages across rooms. Developers can integrate the SDK of third-party IM to achieve. SDK supports startPlayingStream audio and video streams from different rooms under the same appID, that is, startPlayingStream audio and video streams across rooms. Since ZegoExpressEngine's room related callback notifications are based on the same room, when developers want to startPlayingStream streams across rooms, developers need to maintain related messages and signaling notifications by themselves. If the network is temporarily interrupted due to network quality reasons, the SDK will automatically reconnect internally. You can get the current connection status of the local room by listening to the [onRoomStateUpdate] callback method, and other users in the same room will receive [onRoomUserUpdate] callback notification. It is strongly recommended that userID corresponds to the user ID of the business APP, that is, a userID and a real user are fixed and unique, and should not be passed to the SDK in a random userID. Because the unique and fixed userID allows ZEGO technicians to quickly locate online problems.
Parameters:
Name Type Description
roomID string Room ID, a string of up to 128 bytes in length. Only support numbers, English characters and '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '=', '-', '`', ';', '’', ',', '.', '<', '>', '/', '\'
config ZegoRoomConfig Advanced room configuration
Source:

loginRoom(roomID, user, config)

Logs in to a room with advanced room configurations. You must log in to a room before publishing or playing streams. Please do not fill in sensitive user information in this interface, including but not limited to mobile phone number, ID number, passport number, real name, etc. To prevent the app from being impersonated by a malicious user, you can add authentication before logging in to the room, that is, the [token] parameter in the ZegoRoomConfig object passed in by the [config] parameter. Different users who log in to the same room can get room related notifications in the same room (eg [onRoomUserUpdate], [onRoomStreamUpdate], etc.), and users in one room cannot receive room signaling notifications in another room. Messages sent in one room (e.g. [setStreamExtraInfo], [sendBroadcastMessage], [sendBarrageMessage], [sendCustomCommand], etc.) cannot be received callback ((eg [onRoomStreamExtraInfoUpdate], [onIMRecvBroadcastMessage], [onIMRecvBarrageMessage], [onIMRecvCustomCommand], etc) in other rooms. Currently, SDK does not provide the ability to send messages across rooms. Developers can integrate the SDK of third-party IM to achieve. SDK supports startPlayingStream audio and video streams from different rooms under the same appID, that is, startPlayingStream audio and video streams across rooms. Since ZegoExpressEngine's room related callback notifications are based on the same room, when developers want to startPlayingStream streams across rooms, developers need to maintain related messages and signaling notifications by themselves. If the network is temporarily interrupted due to network quality reasons, the SDK will automatically reconnect internally. You can get the current connection status of the local room by listening to the [onRoomStateUpdate] callback method, and other users in the same room will receive [onRoomUserUpdate] callback notification. It is strongly recommended that userID corresponds to the user ID of the business APP, that is, a userID and a real user are fixed and unique, and should not be passed to the SDK in a random userID. Because the unique and fixed userID allows ZEGO technicians to quickly locate online problems. After the first login failure due to network reasons or the room is disconnected, the default time of SDK reconnection is 20min. For restrictions on the use of this function, please refer to https://doc-en.zego.im/article/7611 or contact ZEGO technical support.
Parameters:
Name Type Description
roomID string Room ID, a string of up to 128 bytes in length. Only support numbers, English characters and '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '=', '-', '`', ';', '’', ',', '.', '<', '>', '/', '\'
user ZegoUser User object instance, configure userID, userName. Note that the userID needs to be globally unique with the same appID, otherwise the user who logs in later will kick out the user who logged in first.
config ZegoRoomConfig Advanced room configuration
Source:

logoutRoom(roomID)

Logs out of a room. Description: This API will log out the room named roomID. Use cases: In the same room, users can conduct live broadcast, audio and video calls, etc. When to call /Trigger: After successfully logging in to the room, if the room is no longer used, the user can call the function [logoutRoom]. Restrictions: None. Caution: 1. Exiting the room will stop all publishing and playing streams for user, and inner audio and video engine will stop, and then SDK will auto stop local preview UI. If you want to keep the preview ability when switching rooms, please use the [switchRoom] method. 2. If the user logs in to the room, but the incoming 'roomID' is different from the logged-in room name, SDK will return failure. Related callbacks: After calling this function, you will receive [onRoomStateUpdate] callback notification successfully exits the room, while other users in the same room will receive the [onRoomUserUpdate] callback notification(On the premise of enabling isUserStatusNotify configuration). Related APIs: Users can use [loginRoom], [switchRoom] functions to log in or switch rooms.
Parameters:
Name Type Description
roomID string Room ID, a string of up to 128 bytes in length. Only support numbers, English characters and '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '=', '-', '`', ';', '’', ',', '.', '<', '>', '/', '\'
Source:

muteAllPlayStreamVideo(mute)

Can the pull stream receive all video data. Description: In the process of real-time video and video interaction, local users can use this function to control whether to receive all remote users' video data when pulling the stream (including the video stream pushed by the new user who joins the room after calling this function). By default, users can receive video data pushed by all remote users after joining the room. When the developer does not receive the audio receipt, the hardware and network overhead can be reduced. Use cases: This function can be called when developers need to quickly close and resume watching remote video. Compared to re-flow, it can greatly reduce the time and improve the interactive experience. When to call: This function can be called after calling [initWithProfile/init]. Related APIs: You can call the [mutePlayStreamVideo] function to control whether to receive a single piece of video data. When the two functions [muteAllPlayStreamVideo] and [mutePlayStreamVideo] are set to `false` at the same time, the local user can receive the video data of the remote user when the stream is pulled: 1. When the [muteAllPlayStreamVideo(true)] function is called, it will take effect globally, that is, the local user will be prohibited from receiving all remote users' video data. At this time, the [mutePlayStreamVideo] function will not take effect whether it is called before or after [muteAllPlayStreamVideo]. 2. When the [muteAllPlayStreamVideo(false)] function is called, the local user can receive the video data of all remote users. At this time, the [mutePlayStreamVideo] function can be used to control whether to receive a single video data. Call the [mutePlayStreamVideo(true, streamID)] function, the local user can receive other video data other than the `streamID`; call the [mutePlayStreamVideo(false, streamID)] function, the local user can receive all the video data.
Parameters:
Name Type Description
mute boolean Whether it is possible to receive all remote users' video data when streaming, "true" means prohibition, "false" means receiving, and the default value is "false".
Source:

muteMicrophone(mute)

Mutes or unmutes the microphone. Description: This function is used to control whether to use the collected audio data. Mute (turn off the microphone) will use the muted data to replace the audio data collected by the device for streaming. At this time, the microphone device will still be occupied. Default value: The default is `false`, which means no muting. When to call: After creating the engine [initWithProfile/init]. Restrictions: None. Related APIs: Developers who want to control whether to use microphone on the UI should use this function to avoid unnecessary performance overhead by using the [enableAudioCaptureDevice]. You can use [isMicrophoneMuted] to check if the microphone is muted.
Parameters:
Name Type Description
mute boolean Whether to mute (disable) the microphone, `true`: mute (disable) microphone, `false`: enable microphone.
Source:

mutePlayStreamAudio(streamID, mute)

Whether the pull stream can receive the specified audio data. Description: In the process of real-time audio and video interaction, local users can use this function to control whether to receive audio data from designated remote users when pulling streams as needed. When the developer does not receive the audio receipt, the hardware and network overhead can be reduced. Use cases: Call this function when developers need to quickly close and restore remote audio. Compared to re-flow, it can greatly reduce the time and improve the interactive experience. When to call: This function can be called after calling [initWithProfile/init].
Parameters:
Name Type Description
streamID string Stream ID.
mute boolean Whether it can receive the audio data of the specified remote user when streaming, "true" means prohibition, "false" means receiving, the default value is "false".
Source:

mutePlayStreamVideo(streamID, mute)

Whether the pull stream can receive the specified video data. Description: In the process of real-time video and video interaction, local users can use this function to control whether to receive video data from designated remote users when pulling streams as needed. When the developer does not receive the audio receipt, the hardware and network overhead can be reduced. Use cases: This function can be called when developers need to quickly close and resume watching remote video. Compared to re-flow, it can greatly reduce the time and improve the interactive experience. When to call: This function can be called after calling [initWithProfile/init]. Caution: This function is valid only when the [muteAllPlayStreamVideo] function is set to `false`. Related APIs: You can call the [muteAllPlayStreamVideo] function to control whether to receive all video data. When the two functions [muteAllPlayStreamVideo] and [mutePlayStreamVideo] are set to `false` at the same time, the local user can receive the video data of the remote user when the stream is pulled: 1. When the [muteAllPlayStreamVideo(true)] function is called, it will take effect globally, that is, local users will be prohibited from receiving all remote users' video data. At this time, the [mutePlayStreamVideo] function will not take effect whether it is called before or after [muteAllPlayStreamVideo]. 2. When the [muteAllPlayStreamVideo(false)] function is called, the local user can receive the video data of all remote users. At this time, the [mutePlayStreamVideo] function can be used to control whether to receive a single video data. Call the [mutePlayStreamVideo(true, streamID)] function, the local user can receive other video data other than the `streamID`; call the [mutePlayStreamVideo(false, streamID)] function, the local user can receive all the video data.
Parameters:
Name Type Description
streamID string Stream ID.
mute boolean Whether it is possible to receive the video data of the specified remote user when streaming, "true" means prohibition, "false" means receiving, the default value is "false".
Source:

mutePublishStreamAudio(mute, channel)

Stops or resumes sending the audio part of a stream for the specified channel. Description: This function can be called when publishing the stream to realize not publishing the audio data stream. The SDK still collects and processes the audio, but does not send the audio data to the network. When to call: Called after the engine is created [initWithProfile/init] can take effect. Restrictions: None. Related callbacks: If you stop sending audio streams, the remote user that play stream of local user publishing stream can receive `Mute` status change notification by monitoring [onRemoteMicStateUpdate] callbacks. Related APIs: [mutePublishStreamVideo].
Parameters:
Name Type Description
mute boolean Whether to stop sending audio streams, true means not to send audio stream, and false means sending audio stream. The default is false.
channel ZegoPublishChannel Publish stream channel.
Source:

mutePublishStreamVideo(mute, channel)

Stops or resumes sending the video part of a stream for the specified channel. Description: This function can be called when publishing the stream to realize not publishing the video stream. The local camera can still work normally, can capture, preview and process video images normally, but does not send the video data to the network. When to call: Called after the engine is created [initWithProfile/init] can take effect. Restrictions: None. Related callbacks: If you stop sending video streams locally, the remote user that play stream of local user publishing stream can receive `Mute` status change notification by monitoring [onRemoteCameraStateUpdate] callbacks. Related APIs: [mutePublishStreamAudio].
Parameters:
Name Type Description
mute boolean Whether to stop sending video streams, true means not to send video stream, and false means sending video stream. The default is false.
channel ZegoPublishChannel Publish stream channel.
Source:

muteSpeaker(mute)

Mutes or unmutes the audio output speaker. Description: After mute speaker, all the SDK sounds will not play, including playing stream, mediaplayer, etc. But the SDK will still occupy the output device. Default value: The default is `false`, which means no muting. When to call: After creating the engine [initWithProfile/init]. Restrictions: None.
Parameters:
Name Type Description
mute boolean Whether to mute (disable) speaker audio output, `true`: mute (disable) speaker audio output, `false`: enable speaker audio output.
Source:

registerCustomVideoCapturePlugin(plugin, channel)

register custom video capture plugin
Parameters:
Name Type Description
plugin Number video capture plugin
channel ZegoPublishChannel publish channel
Source:

registerCustomVideoProcessPlugin(plugin, channel)

register custom video process plugin
Parameters:
Name Type Description
plugin Number video process plugin
channel ZegoPublishChannel publish channel
Source:

removePublishCdnUrl(streamID, targetURL) → {Promise.<number>}

Deletes the specified CDN URL, which is used for relaying streams from ZEGO RTC server to CDN. Description: When a CDN forwarding address has been added via [addPublishCdnUrl], this function is called when the stream needs to be stopped. When to call: After calling the [initWithProfile/init] function to create the engine. Restrictions: When the [enablePublishDirectToCDN] function is set to true to publish the stream straight to the CDN, then calling this function will have no effect. Caution: This function does not stop publishing audio and video stream to the ZEGO ZEGO RTC server. Related APIs: Add URLs that are re-pushed to the CDN [addPublishCdnUrl].
Parameters:
Name Type Description
streamID string Stream ID.
targetURL string CDN relay address, supported address format rtmp.
Source:
Returns:
- The execution result of update the relay CDN operation.
Type
Promise.<number>

sendBarrageMessage(roomID, message) → {Promise.<number, string>}

Sends a Barrage Message (bullet screen) to all users in the same room, without guaranteeing the delivery. Description: Send a barrage message to the room, users who have logged in to the same room can receive the message, the message is unreliable. Use cases: Generally used in scenarios where there is a large number of messages sent and received in the room and the reliability of the messages is not required, such as live barrage. When to call: After calling [loginRoom] to log in to the room. Restrictions: The frequency of sending barrage messages in the same room cannot be higher than 20 messages/s. For restrictions on the use of this function, please refer to https://doc-zh.zego.im/article/7581 or contact ZEGO technical support. Related callbacks: The room barrage message can be received through [onIMRecvBarrageMessage]. Related APIs: Broadcast messages can be sent through the [sendBroadcastMessage] function, and custom command can be sent through the [sendCustomCommand] function.
Parameters:
Name Type Description
roomID string Room ID. Required: Yes. Value range: The maximum length is 128 bytes. Caution: The room ID is in string format and only supports numbers, English characters and'~','!','@','#','$','%','^','&', ' *','(',')','_','+','=','-','`',';',''',',','.','<' ,'>','/','\'.
message string The content of the message. Required: Yes. Value range: The length does not exceed 1024 bytes.
Source:
Returns:
- Send barrage message result callback.
Type
Promise.<number, string>

sendBroadcastMessage(roomID, message) → {Promise.<number, number>}

Sends a Broadcast Message. Description: Send a broadcast message to the room, users who have entered the same room can receive the message, and the message is reliable. Use cases: Generally used when the number of people in the live room does not exceed 500. When to call: After calling [loginRoom] to log in to the room. Restrictions: It is not supported when the number of people online in the room exceeds 500. If you need to increase the limit, please contact ZEGO technical support to apply for evaluation. The frequency of sending broadcast messages in the same room cannot be higher than 10 messages/s. The maximum QPS for a single user calling this interface from the client side is 2. For restrictions on the use of this function, please refer to https://doc-zh.zego.im/article/7581 or contact ZEGO technical support. Related callbacks: The room broadcast message can be received through [onIMRecvBroadcastMessage]. Related APIs: Barrage messages can be sent through the [sendBarrageMessage] function, and custom command can be sent through the [sendCustomCommand] function.
Parameters:
Name Type Description
roomID string Room ID. Required: Yes. Value range: The maximum length is 128 bytes. Caution: The room ID is in string format and only supports numbers, English characters and'~','!','@','#','$','%','^','&', ' *','(',')','_','+','=','-','`',';',''',',','.','<' ,'>','/','\'.
message string The content of the message. Required: Yes. Value range: The length does not exceed 1024 bytes.
Source:
Returns:
- Send broadcast message result callback
Type
Promise.<number, number>

sendCustomCommand(roomID, command, toUserList) → {Promise.<number>}

Sends a Custom Command to the specified users in the same room. Description: After calling this function, users in the same room who have entered the room can receive the message, the message is unreliable. Use cases: Generally used in scenarios where there is a large number of messages sent and received in the room and the reliability of the messages is not required, such as live barrage. When to call: After calling [loginRoom] to log in to the room. Restrictions: Generally used when the number of people in the live room does not exceed 500.The frequency of sending barrage messages in the same room cannot be higher than 20 messages/s. For restrictions on the use of this function, please refer to https://doc-zh.zego.im/article/7581 or contact ZEGO technical support. Related callbacks: The room custom command can be received through [onIMRecvCustomCommand]. Related APIs: Broadcast messages can be sent through the [sendBroadcastMessage] function, and barrage messages can be sent through the [sendBarrageMessage] function. Privacy reminder: Please do not fill in sensitive user information in this interface, including but not limited to mobile phone number, ID number, passport number, real name, etc.
Parameters:
Name Type Description
roomID string Room ID. Required: Yes. Value range: The maximum length is 128 bytes. Caution: The room ID is in string format and only supports numbers, English characters and'~','!','@','#','$','%','^','&', ' *','(',')','_','+','=','-','`',';',''',',','.','<' ,'>','/','\'.
command string Custom command content. Required: Yes. Value range: The maximum length is 1024 bytes. Caution: To protect privacy, please do not fill in sensitive user information in this interface, including but not limited to mobile phone number, ID number, passport number, real name, etc.
toUserList Array.<ZegoUser> List of recipients of signaling. Required: Yes. Value range: user list or [null]. Caution: When it is [null], the SDK will send custom signaling back to all users in the room
Source:
Returns:
- Send command result callback.
Type
Promise.<number>

sendSEI(data, channel)

Sends Supplemental Enhancement Information. Description: While pushing the stream to transmit the audio and video stream data, the stream media enhancement supplementary information is sent to synchronize some other additional information. Use cases: Generally used in scenes such as synchronizing music lyrics or precise video layout, you can choose to send SEI. When to call: After starting to push the stream [startPublishingStream]. Restrictions: Do not exceed 30 times per second, and the SEI data length is limited to 4096 bytes. Caution: Since the SEI information follows the video frame, there may be frame loss due to network problems, so the SEI information may also be lost. In order to solve this situation, it should be sent several times within the restricted frequency. Related APIs: After the pusher sends the SEI, the puller can obtain the SEI content by monitoring the callback of [onPlayerRecvSEI].
Parameters:
Name Type Description
data Uint8Array SEI data.
channel ZegoPublishChannel Publish stream channel.
Source:

setAECMode(mode)

Sets the acoustic echo cancellation (AEC) mode. Description: When [enableAEC] is used to enable echo cancellation, this function can be used to switch between different echo cancellation modes to control the degree of echo cancellation. Use case: When the default echo cancellation effect does not meet expectations, this function can be used to adjust the echo cancellation mode. Default value: When this function is not called, the default echo cancellation mode is [Aggressive]. When to call: It needs to be called after init SDK [initWithProfile/init], before [startPublishingStream], [startPlayingStream], [startPreview], [createMediaPlayer], [createAudioEffectPlayer]. Restrictions: The value set by this function is valid only after the echo cancellation function is turned on.
Parameters:
Name Type Description
mode ZegoAECMode Echo cancellation mode
Source:

setANSMode(mode)

Sets the automatic noise suppression (ANS) mode. Description: When [enableANS] is used to enable noise suppression, this function can be used to switch between different noise suppression modes to control the degree of noise suppression. Use case: When the default noise suppression effect does not meet expectations, this function can be used to adjust the noise suppression mode. Default value: When this function is not called, the default echo cancellation mode is [Medium]. When to call: It needs to be called after init SDK [initWithProfile/init], before [startPublishingStream], [startPlayingStream], [startPreview], [createMediaPlayer], [createAudioEffectPlayer]. Restrictions: The value set by this function is valid only after the noise suppression function is turned on.
Parameters:
Name Type Description
mode ZegoANSMode Audio Noise Suppression mode
Source:

setAudioCaptureStereoMode(mode)

Set audio capture stereo mode. Description: This function is used to set the audio capture channel mode. When the developer turns on the two-channel capture, using a special two-channel capture device, the two-channel audio data can be collected and streamed. Use cases: In some professional scenes, users are particularly sensitive to sound effects, such as voice radio and musical instrument performance. At this time, support for dual-channel and high-quality sound is required. Default value: The default is None, which means mono capture. When to call: It needs to be called after [initWithProfile/init], before [startPublishingStream], [startPlayingStream], [startPreview], [createMediaPlayer] and [createAudioEffectPlayer]. Restrictions: None. Related APIs: When streaming, you need to enable the dual-channel audio encoding function through the [setAudioConfig] interface at the same time.
Parameters:
Name Type Description
mode ZegoAudioCaptureStereoMode Audio stereo capture mode.
Source:

setAudioConfig(config)

Sets up the audio configurations. Description: You can set the combined value of the audio codec, bit rate, and audio channel through this function. If the preset value cannot meet the developer's scenario, the developer can set the parameters according to the business requirements. Default value: The default audio config refers to the default value of [ZegoAudioConfig]. When to call: After the engine is created [initWithProfile/init], and before publishing [startPublishingStream]. Restrictions: None. Caution: Act on the main publish channel ZegoPublishChannel.Main. Related APIs: [getAudioConfig].
Parameters:
Name Type Description
config ZegoAudioConfigPreset | ZegoAudioConfig Audio config.
Source:

setAudioDeviceVolume(deviceType, deviceID, volume)

Set volume for the specified audio device. The direct operating system device may fail due to system restrictions. Please use [setCaptureVolume] and [setPlayVolume] first to adjust the volume of publish and play streams.
Parameters:
Name Type Description
deviceType ZegoAudioDeviceType Audio device type
deviceID string ID of a device obtained by [getAudioDeviceList]
volume number Device volume
Source:

setAudioEqualizerGain(bandIndex, bandGain)

Set the sound equalizer (EQ). Description: Call this function to set the sound equalizer adjust the tone. Use cases: Often used in voice chatroom, KTV. When to call: It needs to be called after init SDK [initWithProfile/init]. Restrictions: None.
Parameters:
Name Type Description
bandIndex number Band frequency index, the value range is [0, 9], corresponding to 10 frequency bands, and the center frequencies are [31, 62, 125, 250, 500, 1K, 2K, 4K, 8K, 16K] Hz.
bandGain number Band gain for the index, the value range is [-15, 15]. Default value is 0, if all gain values in all frequency bands are 0, EQ function will be disabled.
Source:

setCapturePipelineScaleMode(mode)

Sets the timing of video scaling in the video capture workflow. You can choose to do video scaling right after video capture (the default value) or before encoding. When to call: This function needs to be set before call [startPreview] or [startPublishingStream]. Caution: The main effect is Whether the local preview is affected when the acquisition resolution is different from the encoding resolution.
Parameters:
Name Type Description
mode ZegoCapturePipelineScaleMode The capture scale timing mode.
Source:

setCaptureVolume(volume)

Sets the audio recording volume for stream publishing. Description: This function is used to perform gain processing based on the device's collected volume. The local user can control the sound level of the audio stream sent to the remote end. Default value: Default is 100. When to call: After creating the engine [initWithProfile/init]. Restrictions: The capture volume can be dynamically set during publishing. Related APIs: Set the playing stream volume [setPlayVolume].
Parameters:
Name Type Description
volume number The volume gain percentage, the range is 0 ~ 200, and the default value is 100, which means 100% of the original collection volume of the device.
Source:

setCustomVideoProcessCutRegion(left, top, right, bottom, channel)

set custom video process cut region
Parameters:
Name Type Description
left Number left cutting length (px)
top Number top cutting length (px)
right Number right cutting length (px)
bottom Number bottom cutting length (px)
channel ZegoPublishChannel Publishing stream channel
Source:

setDebugVerbose(enable, language)

Turns on/off verbose debugging and sets up the log language. The debug switch is set to on and the language is English by default.
Parameters:
Name Type Description
enable boolean Detailed debugging information switch
language ZegoLanguage Debugging information language
Deprecated:
  • This method has been deprecated after version 0.23.0, please use the [setEngineConfig] function to set the advanced configuration property advancedConfig to achieve the original function.
Source:

setEngineConfig(config)

Set advanced engine configuration. Description: Used to enable advanced functions. When to call: Different configurations have different call timing requirements. For details, please consult ZEGO technical support. Restrictions: None.
Parameters:
Name Type Description
config ZegoEngineConfig Advanced engine configuration
Source:

setHeadphoneMonitorVolume(volume)

Sets the headphone monitor volume. Description: set headphone monitor volume. When to call: After the engine is created [initWithProfile/init]. Caution: This setting does not actually take effect until both the headset and microphone are connected. Related APIs: Enables or disables headphone monitoring via [enableHeadphoneMonitor].
Parameters:
Name Type Description
volume number headphone monitor volume, range from 0 to 200, 100 as default.
Source:

setMinVideoBitrateForTrafficControl(bitrate, mode)

Set the minimum video bitrate threshold for traffic control. Description: Set the control strategy when the video bitrate reaches the lowest threshold during flow control. When the bitrate is lower than the minimum threshold, you can choose not to send video data or send it at a very low frame bitrate. Default value: There is no control effect of the lowest threshold of video bitrate. When to call: After the engine is created [initWithProfile/init], Called before [startPublishingStream] can take effect. Restrictions: The traffic control must be turned on [enableTrafficControl]. Caution: Act on the main publish channel ZegoPublishChannel.Main. Related APIs: [enableTrafficControl].
Parameters:
Name Type Description
bitrate number Minimum video bitrate threshold for traffic control(kbps).
mode ZegoTrafficControlMinVideoBitrateMode Video sending mode below the minimum bitrate.
Source:

setPlayStreamVideoLayer(streamID, videoLayer)

[Deprecated] Set the selected video layer of playing stream. This function has been deprecated after version 0.24.3. Please use [setPlayStreamVideoType] instead. When the publisher has set the codecID to SVC through [setVideoConfig], the player can dynamically set whether to use the standard layer or the base layer (the resolution of the base layer is one-half of the standard layer) Under normal circumstances, when the network is weak or the rendered UI form is small, you can choose to use the video that plays the base layer to save bandwidth. It can be set before and after playing stream.
Parameters:
Name Type Description
streamID string Stream ID.
videoLayer ZegoPlayerVideoLayer Video layer of playing stream. AUTO by default.
Deprecated:
  • This function has been deprecated after version 0.24.3. Please use [setPlayStreamVideoType] instead.
Source:

setPlayStreamVideoType(streamID, streamType)

Set play video stream type. Description: When the publish stream sets the codecID to SVC through [setVideoConfig], the puller can dynamically set and select different stream types (small resolution is one-half of the standard layer). Use cases: In general, when the network is weak or the rendered UI window is small, you can choose to pull videos with small resolutions to save bandwidth. When to call: after init SDK [initWithProfile/init]. Restrictions: None.
Parameters:
Name Type Description
streamID string Stream ID.
streamType ZegoVideoStreamType Video stream type.
Source:

setPlayVolume(streamID, volume)

Sets the stream playback volume. Description: Set the sound size of the stream, the local user can control the playback volume of the audio stream. When to call: after called [startPlayingStream]. Restrictions: None. Caution: You need to reset after [stopPlayingStream] and [startPlayingStream].
Parameters:
Name Type Description
streamID string Stream ID.
volume number Volume percentage. The value ranges from 0 to 200, and the default value is 100.
Source:

setPublishWatermark(watermark, isPreviewVisible, channel)

Sets up the stream watermark before stream publishing (for the specified channel). Description: Set watermark for publish stream screen. Use cases: It is often used to identify the source of the publish. When to call: After creating the engine through [initWithProfile/init] function. Caution: The layout of the watermark cannot exceed the video encoding resolution of the stream. It can be set at any time before or during the publishing stream.
Parameters:
Name Type Description
watermark ZegoWatermark The upper left corner of the watermark layout is the origin of the coordinate system, and the area cannot exceed the size set by the encoding resolution. If it is null, the watermark is cancelled.
isPreviewVisible boolean the watermark is visible on local preview
channel ZegoPublishChannel Publish stream channel.
Source:

setReverbAdvancedParam(param)

Setting up the specific reverberation parameters. Description: Call this function to set preset reverb effect. Use cases: Often used in live broadcasting, voice chatroom and KTV. When to call: It needs to be called after init SDK [initWithProfile/init]. Restrictions: Reverb effect is only effective for SDK captured sound. Caution: Different values dynamically set during publishing stream will take effect. When all parameters are set to 0, the reverberation is turned off. Related APIs: [setReverbPreset] provide a set of preset reverb effects. If you need advanced reverb/echo/voice changer effect, please use [setReverbAdvancedParam], [setReverbEchoParam], [setVoiceChangerParam] together.
Parameters:
Name Type Description
param ZegoReverbAdvancedParam Reverb advanced parameter.
Source:

setReverbEchoParam(param)

Setting up the specific reverberation echo parameters. Description: Call this function to set reverb echo effect. This function can be used with voice changer and reverb to achieve a variety of custom sound effects. Use cases: Often used in live broadcasting, voice chatroom and KTV. When to call: It needs to be called after init SDK [initWithProfile/init]. Restrictions: Reverb echo effect is only effective for SDK captured sound. Related APIs: If you need advanced reverb/echo/voice changer effect, please use [setReverbAdvancedParam], [setReverbEchoParam], [setVoiceChangerParam] together.
Parameters:
Name Type Description
param ZegoReverbEchoParam The reverberation echo parameter.
Source:

setReverbPreset(preset)

Setting up the reverberation via preset enumeration. Description: Call this function to set preset reverb effect. Use cases: Often used in live broadcasting, voice chatroom and KTV. When to call: It needs to be called after init SDK [initWithProfile/init]. Support call this function to change preset reverb effect during publishing stream. Restrictions: Reverb effect is only effective for SDK captured sound. Related APIs: If you need advanced reverb effect, please use [setReverbAdvancedParam]. This function is mutually exclusive with [setVoiceChangerPreset]. If used at the same time, it will produce undefined effects. If you need advanced reverb/echo/voice changer effect, please use [setReverbAdvancedParam], [setReverbEchoParam], [setVoiceChangerParam] together.
Parameters:
Name Type Description
preset ZegoReverbPreset The reverberation preset enumeration.
Source:

setRoomExtraInfo(roomID, key, value) → {Promise.<number>}

Set room extra information. Description: The user can call this function to set the extra info of the room. Use cases: You can set some room-related business attributes, such as whether someone is Co-hosting. When to call /Trigger: After logging in the room successful. Restrictions: For restrictions on the use of this function, please refer to https://doc-en.zego.im/article/7611 or contact ZEGO technical support. Caution: 'key' and 'value' are non null. key.length < 128, value.length < 4096. The newly set key and value will overwrite the old setting. Related callbacks: Other users in the same room will be notified through the [onRoomExtraInfoUpdate] callback function. Related APIs: None.
Parameters:
Name Type Description
roomID string Room ID.
key string key of the extra info.
value string value if the extra info.
Source:
Returns:
- Set room extra info execution result notification
Type
Promise.<number>

setSEIConfig(config)

Set the Supplemental Enhancement Information type. Description: By default, the SDK wraps the data with ZEGO's self-defined SEI type, which is not specified by the SEI standard. When the developer needs to use a third-party decoder to decode the SEI, the correct SEI will not be decoded and the [setSEIConfig] interface needs to be called to change the type of the SEI sent by the SDK to UserUnregister type. Use cases: This function needs to be executed when the developer uses a third-party decoder to decode the SEI. When to call: After creating the engine [initWithProfile/init], before starting to push the stream [startPublishingStream]. Restrictions: None.
Parameters:
Name Type Description
config ZegoSEIConfig SEI configuration. The SEI defined by ZEGO is used by default.
Source:

setStreamExtraInfo(extraInfo, channel) → {Promise.<number>}

Sets the extra information of the stream being published for the specified publish channel. Description: Use this function to set the extra info of the stream. The stream extra information is an extra information identifier of the stream ID. Unlike the stream ID, which cannot be modified during the publishing process, the stream extra information can be modified midway through the stream corresponding to the stream ID. Developers can synchronize variable content related to stream IDs based on stream additional information. When to call: After the engine is created [initWithProfile/init], Called before and after [startPublishingStream] can both take effect. Restrictions: None. Related callbacks: Users can obtain the execution result of the function through [ZegoPublisherSetStreamExtraInfoCallback] callback.
Parameters:
Name Type Description
extraInfo string Stream extra information, a string of up to 1024 characters.
channel ZegoPublishChannel Publish stream channel.
Source:
Returns:
- Set stream extra information execution result notification.
Type
Promise.<number>

setTrafficControlFocusOn(mode, channel)

Set the factors of concern that trigger traffic control. Description: Use this interface to control whether to start traffic control due to poor remote network conditions. Default value: Default is disable. When to call: After the engine is created [initWithProfile/init], called before [startPublishingStream] can take effect. Restrictions: The traffic control must be turned on [enableTrafficControl]. Related APIs: [enableTrafficControl.
Parameters:
Name Type Description
mode ZegoTrafficControlFocusOnMode When LOCAL_ONLY is selected, only the local network status is concerned. When choosing REMOTE, also take into account the remote network.
channel ZegoPublishChannel When LOCAL_ONLY is selected, only the local network status is concerned. When choosing REMOTE, also take into account the remote network.
Source:

setVideoConfig(config, channel)

Sets up the video configurations (for the specified channel). Description: Set the video frame rate, bit rate, video capture resolution, and video encoding output resolution. Use cases: Recommended configuration in different business scenarios: https://doc-zh.zego.im/article/10365. Default value: The default video capture resolution is 360p, the video encoding output resolution is 360p, the bit rate is 600 kbps, and the frame rate is 15 fps. When to call: After [initWithProfile/init]. Restrictions: It is necessary to set the relevant video configuration before publishing the stream or startPreview, and only support the modification of the encoding resolution and the bit rate after publishing the stream. Caution: Developers should note that the wide and high resolution of the mobile end is opposite to the wide and high resolution of the PC. For example, in the case of 360p, the resolution of the mobile end is 360x640, and the resolution of the PC end is 640x360.
Parameters:
Name Type Description
config ZegoVideoConfigPreset | ZegoVideoConfig Video configuration, the SDK provides a common setting combination of resolution, frame rate and bit rate, they also can be customized.
channel ZegoPublishChannel Publish stream channel.
Source:

setVideoMirrorMode(mirrorMode, channel)

Sets the video mirroring mode (for the specified channel). Description: Set whether the local preview video and the published video have mirror mode enabled. For specific mirroring mode, please refer to: https://doc-zh.zego.im/article/10365. When to call: After [initWithProfile/init]. Restrictions: None.
Parameters:
Name Type Description
mirrorMode ZegoVideoMirrorMode Mirror mode for previewing or publishing the stream.
channel ZegoPublishChannel Publish stream channel.
Source:

setVoiceChangerParam(param)

Setting up the specific voice changer parameters. Description: Call this function to set custom voice changer effect. Use cases: Often used in live broadcasting, voice chatroom and KTV. When to call: It needs to be called after init SDK [initWithProfile/init]. Restrictions: Voice changer effect is only effective for SDK captured sound. Related APIs: [setVoiceChangerPreset] provide a set of preset voice changer effects. If you need advanced reverb/echo/voice changer effect, please use [setReverbAdvancedParam], [setReverbEchoParam], [setVoiceChangerParam] together.
Parameters:
Name Type Description
param ZegoVoiceChangerParam Voice changer parameters.
Source:

setVoiceChangerPreset(preset)

Setting up the voice changer via preset enumeration. Description: Call this function to use preset voice changer effect. Use cases: Often used in live broadcasting, voice chatroom and KTV. When to call: It needs to be called after init SDK [initWithProfile/init]. Restrictions: Voice changer effect is only effective for SDK captured sound. Related APIs: If you need advanced voice changer effect, please use [setVoiceChangerParam]. This function is mutually exclusive with [setReverbPreset]. If used at the same time, it will produce undefined effect. Using ANDROID/ETHEREAL preset voice changer effect will modify reverberation or reverberation echo parameters. Calling [setVoiceChangerParam], [setReverbAdvancedParam], [setReverbEchoParam] may affect the voice changer effect after use these preset voice changer effect. If you need advanced reverb/echo/electronic effects/voice changer effect, please use [setReverbAdvancedParam], [setReverbEchoParam], [setElectronicEffects], [setVoiceChangerParam] together.
Parameters:
Name Type Description
preset ZegoVoiceChangerPreset The voice changer preset enumeration.
Source:

startAudioSpectrumMonitor(millisecond)

Starts audio spectrum monitoring. Support setting the listening interval. Description: After starting monitoring, you can receive local audio spectrum via [onCapturedAudioSpectrumUpdate] callback, and receive remote audio spectrum via [onRemoteAudioSpectrumUpdate] callback. Use cases: In the host K song scene, has been published or played under the premise that the host or audience to see the tone and volume change animation. When to call: After the engine is created [initWithProfile/init]. Caution: [onCapturedAudioSpectrumUpdate] and [onRemoteAudioSpectrumUpdate] callback notification period is the value set by the parameter.
Parameters:
Name Type Default Description
millisecond number 100 Monitoring time period of the audio spectrum, in milliseconds, has a value range of [100, 3000]. Default is 100 ms.
Source:

startMixerTask(task) → {Promise.<number, string>}

Starts a stream mixing task. Description: Initiate a mixing stream request to the ZEGO RTC server, the server will look for the stream currently being pushed, and mix the layers according to the parameters of the mixing stream task requested by the SDK. When you need to update a mixing task, that is, when the input stream increases or decreases, you need to update the input stream list. At this time, you can update the field of the [ZegoMixerTask] object inputList and call this function again to pass in the same [ZegoMixerTask] object to update the mixing task. Use cases: It is often used when multiple video images are required to synthesize a video using mixed streaming, such as education, live broadcast of teacher and student images. When to call: After calling [loginRoom] to log in to the room. Restrictions: None. Caution: Due to the performance considerations of the client device, the SDK muxing is to start the mixing task on the ZEGO RTC server for mixing. If an exception occurs when the mixing task is requested to start, for example, the most common mixing input stream does not exist, the error code will be given from the callback callback. For specific error codes, please refer to the common error code document https://doc-zh.zego.im/zh/4378.html. If a certain input stream does not exist in the middle, the muxing task will automatically retry to pull this input stream for 90 seconds, and will not retry after 90 seconds. If all input streams no longer exist, the server will automatically stop the mixing task after 90 seconds. Related callbacks: [OnMixerRelayCDNStateUpdate] can be used to obtain the CDN status update notification of the mixed stream repost, and the sound update notification of each single stream in the mixed stream can be obtained through [onMixerSoundLevelUpdate]. Related APIs: the mixing task can be stopped by the [stopMixerTask] function.
Parameters:
Name Type Description
task ZegoMixerTask Mixing task object. Required: Yes.
Source:
Returns:
- Start stream mixing task result
Type
Promise.<number, string>

startNetworkSpeedTest(config)

Start network speed test. Support set speed test interval。 Description: This function supports uplink/downlink network speed test. Use cases: This function can be used to detect whether the network environment is suitable for pushing/pulling streams with specified bitrates. When to call: It needs to be called after [initWithProfile/init], and before [startPublishingStream]. If you call [startPublishingStream] while speed testing, the speed test will automatically stop. Restrictions: None. Caution: Developers can register [onNetworkSpeedTestQualityUpdate] callback to get the speed test result, which will be triggered every 3 seconds. If an error occurs during the speed test process, [onNetworkSpeedTestError] callback will be triggered. If this function is repeatedly called multiple times, the last functioh call's configuration will be used. Related APIs: Call [stopNetworkSpeedTest] to stop network speed test.
Parameters:
Name Type Description
config ZegoNetworkSpeedTestConfig Network speed test configuration.
Source:

startPlayingStream(streamID, view, config)

Starts playing a stream from ZEGO RTC server or from third-party CDN. Description: Play audio and video streams from the ZEGO RTC server or CDN. Use cases: In real-time or live broadcast scenarios, developers can listen to the [onRoomStreamUpdate] event callback to obtain the new stream information in the room where they are located, and call this interface to pass in streamID for play streams. When to call: After [loginRoom]. Restrictions: None. Caution: 1. The developer can update the player canvas by calling this function again (the streamID must be the same). 2. After the first play stream failure due to network reasons or the play stream is interrupted, the default time for SDK reconnection is 20min. 3. In the case of poor network quality, user play may be interrupted, the SDK will try to reconnect, and the current play status and error information can be obtained by listening to the [onPlayerStateUpdate] event. please refer to: https://doc-en.zego.im/faq/reconnect. 4. Playing the stream ID that does not exist, the SDK continues to try to play after calling this function. After the stream ID is successfully published, the audio and video stream can be actually played.
Parameters:
Name Type Description
streamID string Stream ID, a string of up to 256 characters. You cannot include URL keywords, otherwise publishing stream and playing stream will fails. Only support numbers, English characters and '~', '!', '@', '$', '%', '^', '&', '*', '(', ')', '_', '+', '=', '-', '`', ';', '’', ',', '.', '<', '>', '/', '\'.
view ZegoView The view used to display the preview image.
config ZegoPlayerConfig Advanced player configuration.
Source:

startPreview(view, channel)

Starts/Updates the local video preview (for the specified channel). Description: The user can see his own local image by calling this function. Use cases: It can be used for local preview in real-time connecting wheat, live broadcast and other scenarios. When to call: After [initWithProfile/init]. Restrictions: None. Caution: 1. The preview function does not require you to log in to the room or publish the stream first. But after exiting the room, SDK internally actively stops previewing by default. 2. Local view and preview modes can be updated by calling this function again. The user can only preview on one view. If you call [startPreview] again to pass in a new view, the preview screen will only be displayed in the new view. 3. You can set the mirror mode of the preview by calling the [setVideoMirrorMode] function. The default preview setting is image mirrored. 4. When this function is called, the audio and video engine module inside SDK will start really, and it will start to try to collect audio and video..
Parameters:
Name Type Description
view ZegoView The view used to display the preview image.
channel ZegoPublishChannel Publish stream channel
Source:

startPublishingStream(streamID, channel)

Starts publishing a stream (for the specified channel). You can call this function to publish a second stream. Description: Users push their local audio and video streams to the ZEGO RTC server or CDN, and other users in the same room can pull the audio and video streams to watch through the `streamID` or CDN pull stream address. Use cases: It can be used to publish streams in real-time connecting wheat, live broadcast and other scenarios. When to call: After [loginRoom]. Restrictions: None. Caution: 1. Before start to publish the stream, the user can choose to call [setVideoConfig] to set the relevant video parameters, and call [startPreview] to preview the video. 2. Other users in the same room can get the streamID by monitoring the [onRoomStreamUpdate] event callback after the local user publishing stream successfully. 3. In the case of poor network quality, user publish may be interrupted, and the SDK will attempt to reconnect. You can learn about the current state and error information of the stream published by monitoring the [onPublisherStateUpdate] event.
Parameters:
Name Type Description
streamID string Stream ID, a string of up to 256 characters, needs to be globally unique within the entire AppID. If in the same AppID, different users publish each stream and the stream ID is the same, which will cause the user to publish the stream failure. You cannot include URL keywords, otherwise publishing stream and playing stream will fails. Only support numbers, English characters and '~', '!', '@', '$', '%', '^', '&', '*', '(', ')', '_', '+', '=', '-', '`', ';', '’', ',', '.', '<', '>', '/', '\'.
channel ZegoPublishChannel Publish stream channel.
Source:

startRecordingCapturedData(config, channel)

Starts to record and directly save the data to a file. Description: Starts to record locally captured audio or video and directly save the data to a file, The recorded data will be the same as the data publishing through the specified channel. When to call: This function needs to be called after the success of [startPreview] or [startPublishingStream] to be effective. Restrictions: None. Caution: Developers should not [stopPreview] or [stopPublishingStream] during recording, otherwise the SDK will end the current recording task. The data of the media player needs to be mixed into the publishing stream to be recorded. Related callbacks: Developers will receive the [onCapturedDataRecordStateUpdate] and the [onCapturedDataRecordProgressUpdate] callback after start recording.
Parameters:
Name Type Description
config ZegoDataRecordConfig Record config.
channel ZegoPublishChannel Publishing stream channel.
Source:

startSoundLevelMonitor(millisecond)

Starts sound level monitoring. Support setting the listening interval. Description: After starting monitoring, you can receive local audio sound level via [onCapturedSoundLevelUpdate] callback, and receive remote audio sound level via [onRemoteSoundLevelUpdate] callback. Before entering the room, you can call [startPreview] with this function and combine it with [onCapturedSoundLevelUpdate] callback to determine whether the audio device is working properly. Use cases: During the publishing and playing process, determine who is talking on the wheat and do a UI presentation. When to call: After the engine is created [initWithProfile/init]. Caution: [onCapturedSoundLevelUpdate] and [onRemoteSoundLevelUpdate] callback notification period is the value set by the parameter. If you want to use advanced feature of sound level, please use the function of the same name (the parameter type is ZegoSoundLevelConfig) instead.
Parameters:
Name Type Default Description
millisecond number 100 Monitoring time period of the sound level, in milliseconds, has a value range of [100, 3000]. Default is 100 ms.
Source:

stopAudioSpectrumMonitor()

Stops audio spectrum monitoring. Description: After the monitoring is stopped, the callback of the local/remote audio spectrum will be stopped. When to call: After the engine is created [initWithProfile/init]. Related APIs: Audio spectrum monitoring can be initiated via [startAudioSpectrumMonitor].
Source:

stopMixerTask(task) → {Promise.<number>}

Stops a stream mixing task. Description: Initiate a request to end the mixing task to the ZEGO RTC server. Use cases: It is often used when multiple video images are required to synthesize a video using mixed streaming, such as education, live broadcast of teacher and student images. When to call: After calling [startMixerTask] to start mixing. Restrictions: None. Caution: If the developer starts the next mixing task without stopping the previous mixing task, the previous mixing task will not automatically stop until the input stream of the previous mixing task does not exist for 90 seconds. Before starting the next mixing task, you should stop the previous mixing task, so that when an anchor has already started the next mixing task to mix with other anchors, the audience is still pulling the output stream of the previous mixing task. Related APIs: You can start mixing by using the [startMixerTask] function.
Parameters:
Name Type Description
task ZegoMixerTask Mixing task object. Required: Yes.
Source:
Returns:
- Stop stream mixing task result
Type
Promise.<number>

stopNetworkSpeedTest()

Stop network speed test. Description: Stop network speed test. Use cases: This function can be used to detect whether the network environment is suitable for pushing/pulling streams with specified bitrates. When to call: It needs to be called after init SDK [initWithProfile/init]. Restrictions: None. Caution: After the network speed test stopped, [onNetworkSpeedTestQualityUpdate] callback will not be triggered. Related APIs: Call [startNetworkSpeedTest] to start network speed test.
Source:

stopPlayingStream(streamID)

Stops playing a stream. Description: Stop play audio and video streams from the ZEGO RTC server. Use cases: In the real-time scenario, developers can listen to the [onRoomStreamUpdate] event callback to obtain the delete stream information in the room where they are located, and call this interface to pass in streamID for stop play streams. When to call: After [loginRoom]. Restrictions: None. Caution: When stopped, the attributes set for this stream previously, such as [setPlayVolume], [mutePlayStreamAudio], [mutePlayStreamVideo], etc., will be invalid and need to be reset when playing the the stream next time.
Parameters:
Name Type Description
streamID string Stream ID.
Source:

stopPreview(channel)

Stops the local video preview (for the specified channel). This function can be called to stop previewing when there is no need to see the preview locally. Stopping the preview does not affect the publish stream, play stream function。
Parameters:
Name Type Description
channel ZegoPublishChannel Publish stream channel
Source:

stopPublishingStream(channel)

Stops publishing a stream (for the specified channel). Description: The user stops sending local audio and video streams, and other users in the room will receive a stream deletion notification. Use cases: It can be used to stop publish streams in real-time connecting wheat, live broadcast and other scenarios. When to call: After [startPublishingStream]. Restrictions: None. Caution: 1. After stopping the streaming, other users in the same room can receive the delete notification of the stream by listening to the [onRoomStreamUpdate] callback. 2. If the user has initiated publish flow, this function must be called to stop the publish of the current stream before publishing the new stream (new streamID), otherwise the new stream publish will return a failure. 3. After stopping streaming, the developer should stop the local preview based on whether the business situation requires it.
Parameters:
Name Type Description
channel ZegoPublishChannel Publish stream channel.
Source:

stopRecordingCapturedData(channel)

Stops recording locally captured audio or video. Description: Stops recording locally captured audio or video. When to call: After [startRecordingCapturedData]. Restrictions: None.
Parameters:
Name Type Description
channel ZegoPublishChannel Publishing stream channel.
Source:

stopSoundLevelMonitor()

Stops sound level monitoring. Description: After the monitoring is stopped, the callback of the local/remote audio sound level will be stopped. When to call: After the engine is created [initWithProfile/init]. Related APIs: Soundwave monitoring can be initiated via [startSoundLevelMonitor].
Source:

switchRoom(fromRoomID, toRoomID, config)

Switch the room with advanced room configurations. Description: Using this interface allows users to quickly switch from one room to another room. Use cases: if you need to quickly switch to the next room, you can call this function. When to call /Trigger: After successfully login room. Restrictions: None. Caution: 1. When this function is called, all streams currently publishing or playing will stop (but the local preview will not stop). 2. To prevent the app from being impersonated by a malicious user, you can add authentication before logging in to the room, that is, the [token] parameter in the ZegoRoomConfig object passed in by the [config] parameter. This parameter configuration affects the room to be switched over. 3. When the function [setRoomMode] is used to set ZegoRoomMode to ZEGO_ROOM_MODE_MULTI_ROOM, this function is not available. Privacy reminder: Please do not fill in sensitive user information in this interface, including but not limited to mobile phone number, ID number, passport number, real name, etc. Related callbacks: When the user call the [switchRoom] function, the [onRoomStateUpdate] callback will be triggered to notify the developer of the status of the current user connected to the room. Related APIs: Users can use the [logoutRoom] function to log out of the room.
Parameters:
Name Type Description
fromRoomID string Current roomID.
toRoomID string The next roomID.
config ZegoRoomConfig Advanced room configuration.
Source:

takePlayStreamSnapshot(streamID) → {Promise.<number, string>}

Take a snapshot of the playing stream. Please call this function after calling [startPlayingStream]
Parameters:
Name Type Description
streamID string Stream ID to be snapshot
Source:
Returns:
- snapshot error code(errorCode) and base64 string of the image in jpg format(image)
Type
Promise.<number, string>

takePublishStreamSnapshot(channel) → {Promise.<number, string>}

Take a snapshot of the publishing stream (for the specified channel). Please call this function after calling [startPublishingStream] or [startPreview] The resolution of the snapshot is the encoding resolution set in [setVideoConfig]. If you need to change it to capture resolution, please call [setCapturePipelineScaleMode] to change the capture pipeline scale mode to [Post]
Parameters:
Name Type Description
channel ZegoPublishChannel Publish stream channel
Source:
Returns:
- snapshot error code(errorCode) and base64 string of the image in jpg format(image)
Type
Promise.<number, string>

uninit()

Uninitializes the Engine. uninitialize engine to release the resources
Source:

unregisterCustomVideoCapturePlugin(plugin)

unregister custom video capture plugin
Parameters:
Name Type Description
plugin Number video capture plugin
Source:

uploadLog()

Uploads logs to the ZEGO server. Description: By default, SDK creates and prints log files in the App's default directory. Each log file defaults to a maximum of 5MB. Three log files are written over and over in a circular fashion. When calling this function, SDK will auto package and upload the log files to the ZEGO server. Use cases: Developers can provide a business “feedback” channel in the App. When users feedback problems, they can call this function to upload the local log information of SDK to help locate user problems. When to call: After [initWithProfile/init]. Restrictions: If you call this interface repeatedly within 10 minutes, only the last call will take effect. Caution: After calling this interface to upload logs, if you call [uninit] or exit the App too quickly, there may be a failure.It is recommended to wait a few seconds, and then call [uninit] or exit the App after receiving the upload success callback.
Source:

useAudioDevice(deviceID, deviceType)

Chooses to use the specified audio device.
Parameters:
Name Type Description
deviceID string ID of a device obtained by [getAudioDeviceList]
deviceType ZegoAudioDeviceType Audio device type
Source:

useVideoDevice(deviceID, channel)

Chooses to use the specified video device (for the specified channel).
Parameters:
Name Type Description
deviceID string ID of a device obtained by getVideoDeviceList
channel ZegoPublishChannel Publishing stream channel
Source:

Events

onAudioDeviceStateChanged

The callback triggered when there is a change to audio devices (i.e. new device added or existing device deleted). This callback is triggered when an audio device is added or removed from the system. By listening to this callback, users can update the sound collection or output using a specific device when necessary.
Properties:
Name Type Description
result object param object
Properties
Name Type Description
updateType ZegoUpdateType Update type (add/delete)
deviceType ZegoAudioDeviceType Audio device type
deviceInfo ZegoDeviceInfo Audio device information
Source:

onCapturedAudioSpectrumUpdate

The local captured audio spectrum callback. Description: The local captured audio spectrum callback. Trigger: After you start the audio spectrum monitor by calling [startAudioSpectrumMonitor]. Caution: The callback notification period is the parameter value set when the [startAudioSpectrumMonitor] is called. The callback value is the default value of 0 When you have not called the interface [startPublishingStream] or [startPreview]. Related APIs: Start audio spectrum monitoring via [startAudioSpectrumMonitor]. Monitoring remote played audio spectrum by callback [onRemoteAudioSpectrumUpdate]
Properties:
Name Type Description
result object param object
Properties
Name Type Description
audioSpectrum Array.<number> Locally captured audio spectrum value list. Spectrum value range is [0-2^30].
Source:

onCapturedDataRecordProgressUpdate

The callback to report the current recording progress. Description: Recording progress update callback, triggered at regular intervals during recording. Use cases: Developers can do UI hints for the user interface. When to trigger: After [startRecordingCapturedData] is called, If configured to require a callback, timed trigger during recording. Restrictions: None.
Properties:
Name Type Description
result object param object
Properties
Name Type Description
progress ZegoDataRecordProgress File recording progress, which allows developers to hint at the UI, etc.
config ZegoDataRecordConfig Record config.
channel ZegoPublishChannel Publishing stream channel.
Source:

onCapturedDataRecordStateUpdate

The callback triggered when the state of data recording (to a file) changes. Description: The callback triggered when the state of data recording (to a file) changes. Use cases: The developer should use this callback to determine the status of the file recording or for UI prompting. When to trigger: After [startRecordingCapturedData] is called, if the state of the recording process changes, this callback will be triggered. Restrictions: None.
Properties:
Name Type Description
result object param object
Properties
Name Type Description
state ZegoDataRecordState File recording status.
errorCode number Error code, please refer to the error codes document https://doc-en.zego.im/en/5548.html for details.
config ZegoDataRecordConfig Record config.
channel ZegoPublishChannel Publishing stream channel.
Source:

onCapturedSoundLevelUpdate

The local captured audio sound level callback. Description: The local captured audio sound level callback. Trigger: After you start the sound level monitor by calling [startSoundLevelMonitor]. Caution: The callback notification period is the parameter value set when the [startSoundLevelMonitor] is called. The callback value is the default value of 0 When you have not called the interface [startPublishingStream] or [startPreview]. Related APIs: Start sound level monitoring via [startSoundLevelMonitor]. Monitoring remote played audio sound level by callback [onRemoteSoundLevelUpdate]
Properties:
Name Type Description
result object param object
Properties
Name Type Description
soundLevel number Locally captured sound level value, ranging from 0.0 to 100.0.
Source:

onDebugError

The callback for obtaining debugging error information. Description: When the SDK functions are not used correctly, the callback prompts for detailed error information. Trigger: Notify the developer when an exception occurs in the SDK. Restrictions: None. Caution: None.
Properties:
Name Type Description
result object param object
Properties
Name Type Description
errorCode number Error code, please refer to the error codes document https://doc-en.zego.im/en/5548.html for details.
funcName string Function name.
info string Detailed error information.
Source:

onDeviceError

The callback triggered when a device exception occurs. Description: The callback triggered when a device exception occurs. Trigger: This callback is triggered when an exception occurs when reading or writing the audio and video device.
Properties:
Name Type Description
result object param object
Properties
Name Type Description
errorCode number The error code corresponding to the status change of the playing stream, please refer to the error codes document https://doc-en.zego.im/en/5548.html for details.
deviceName string device name
Source:

onEngineStateUpdate

The callback triggered when the audio/video engine state changes. Description: Callback notification of audio/video engine status update. When audio/video functions are enabled, such as preview, push streaming, local media player, audio data observering, etc., the audio/video engine will enter the start state. When you exit the room or disable all audio/video functions , The audio/video engine will enter the stop state. Trigger: The developer called the relevant function to change the state of the audio and video engine. For example: 1. Called ZegoExpressEngine's [startPreview], [stopPreview], [startPublishingStream], [stopPublishingStream], [startPlayingStream], [stopPlayingStream], [startAudioDataObserver], [stopAudioDataObserver] and other functions. 2. The related functions of MediaPlayer are called. 3. The [LogoutRoom] function was called. Restrictions: None. Caution: 1. When the developer calls [uninit], this notification will not be triggered because the resources of the SDK are completely released. 2. If there is no special need, the developer does not need to pay attention to this callback.
Properties:
Name Type Description
result object param object
Properties
Name Type Description
state ZegoEngineState The audio/video engine state.
Source:

onIMRecvBarrageMessage

The callback triggered when Barrage Messages are received. Description: This callback is used to receive barrage messages sent by other users in the same room. Use cases: Generally used in scenarios where there is a large number of messages sent and received in the room and the reliability of the messages is not required, such as live barrage. When to trigger: After calling [loginRoom] to log in to the room, if a user in the room sends a barrage message through the [sendBarrageMessage] function, this callback will be triggered. Restrictions: None Caution: Barrage messages sent by users themselves will not be notified through this callback. When there are a large number of barrage messages in the room, the notification may be delayed, and some barrage messages may be lost. Related callbacks: Develop can receive room broadcast messages through [onIMRecvBroadcastMessage], and can receive room custom signaling through [onIMRecvCustomCommand].
Properties:
Name Type Description
result object param object
Properties
Name Type Description
roomID string Room ID. Value range: The maximum length is 128 bytes. Caution: The room ID is in string format and only supports numbers, English characters and'~','!','@','#','$','%','^','&', ' *','(',')','_','+','=','-','`',';',''',',','.','<' ,'>','/','\'.
messageList Array.<ZegoBarrageMessageInfo> List of received messages. Value range: Up to 50 messages can be received each time.
Source:

onIMRecvBroadcastMessage

The callback triggered when Broadcast Messages are received. Description: This callback is used to receive broadcast messages sent by other users in the same room. Use cases: Generally used when the number of people in the live room does not exceed 500 When to trigger: After calling [loginRoom] to log in to the room, if a user in the room sends a broadcast message via [sendBroadcastMessage] function, this callback will be triggered. Restrictions: None Caution: The broadcast message sent by the user will not be notified through this callback. Related callbacks: You can receive room barrage messages through [onIMRecvBarrageMessage], and you can receive room custom signaling through [onIMRecvCustomCommand].
Properties:
Name Type Description
result object param object
Properties
Name Type Description
roomID string Room ID. Value range: The maximum length is 128 bytes. Caution: The room ID is in string format and only supports numbers, English characters and'~','!','@','#','$','%','^','&', ' *','(',')','_','+','=','-','`',';',''',',','.','<' ,'>','/','\'.
messageList Array.<ZegoBroadcastMessageInfo> List of received messages. Value range: Up to 50 messages can be received each time.
Source:

onIMRecvCustomCommand

The callback triggered when a Custom Command is received. Description: This callback is used to receive custom command sent by other users in the same room. Use cases: Generally used when the number of people in the live room does not exceed 500 When to trigger: After calling [loginRoom] to log in to the room, if other users in the room send custom signaling to the developer through the [sendCustomCommand] function, this callback will be triggered. Restrictions: None Caution: The custom command sent by the user himself will not be notified through this callback. Related callbacks: You can receive room broadcast messages through [onIMRecvBroadcastMessage], and you can receive room barrage message through [onIMRecvBarrageMessage].
Properties:
Name Type Description
result object param object
Properties
Name Type Description
roomID string Room ID. Value range: The maximum length is 128 bytes. Caution: The room ID is in string format and only supports numbers, English characters and'~','!','@','#','$','%','^','&', ' *','(',')','_','+','=','-','`',';',''',',','.','<' ,'>','/','\'.
fromUser ZegoUser Sender of the command.
command string Command content received.Value range: The maximum length is 1024 bytes.
Source:

onNetworkModeChanged

Network mode changed callback. Description: Network mode changed callback. When to trigger: This callback will be triggered when the device's network mode changed, such as switched from WiFi to 5G, or when network is disconnected. Restrictions: None.
Properties:
Name Type Description
result object param object
Properties
Name Type Description
mode ZegoNetworkMode Current network mode.
Source:

onNetworkSpeedTestError

Network speed test error callback. Description: Network speed test error callback. Use cases: This function can be used to detect whether the network environment is suitable for pushing/pulling streams with specified bitrates. When to Trigger: If an error occurs during the speed test, such as: can not connect to speed test server, this callback will be triggered. Restrictions: None.
Properties:
Name Type Description
result object param object
Properties
Name Type Description
errorCode number Network speed test error code. Please refer to error codes document https://doc-en.zego.im/en/5548.html for details.
type ZegoNetworkSpeedTestType Uplink or downlink.
Source:

onNetworkSpeedTestQualityUpdate

Network speed test quality callback. Description: Network speed test quality callback. Use cases: This function can be used to detect whether the network environment is suitable for pushing/pulling streams with specified bitrates. When to Trigger: After call [startNetworkSpeedTest] start network speed test, this callback will be triggered. The trigger period is determined by the parameter value specified by call [startNetworkSpeedTest], default value is 3 seconds Restrictions: None. Caution: When error occurred during network speed test or [stopNetworkSpeedTest] called, this callback will not be triggered.
Properties:
Name Type Description
result object param object
Properties
Name Type Description
quality ZegoNetworkSpeedTestQuality Network speed test quality.
type ZegoNetworkSpeedTestType Uplink or downlink.
Source:

onPlayerMediaEvent

The callback triggered when a media event occurs during streaming playing. Description: This callback is used to receive pull streaming events. Use cases: You can use this callback to make statistics on stutters or to make friendly displays in the UI of the app. When to trigger: After calling the [startPublishingStream], this callback is triggered when an event such as audio and video jamming and recovery occurs in the playing stream.
Properties:
Name Type Description
result object param object
Properties
Name Type Description
streamID string Stream ID.
event ZegoPlayerMediaEvent Specific events received when playing the stream.
Source:

onPlayerQualityUpdate

Callback for current stream playing quality. Description: After calling the [startPlayingStream] successfully, this callback will be triggered every 3 seconds. The collection frame rate, bit rate, RTT, packet loss rate and other quality data can be obtained, and the health of the played audio and video streams can be monitored in real time. Use cases: You can monitor the health of the played audio and video streams in real time according to the quality parameters of the callback function, in order to show the downlink network status on the device UI in real time. Caution: If you does not know how to use the various parameters of the callback function, you can only focus on the level field of the quality parameter, which is a comprehensive value describing the downlink network calculated by SDK based on the quality parameters. Related callbacks: After calling the [startPublishingStream] successfully, a callback [onPublisherQualityUpdate] will be received every 3 seconds. You can monitor the health of publish streams in real time based on quality data such as frame rate, code rate, RTT, packet loss rate, etc.
Properties:
Name Type Description
result object param object
Properties
Name Type Description
streamID string Stream ID.
quality ZegoPlayStreamQuality Playing stream quality, including audio and video framerate, bitrate, RTT, etc.
Source:

onPlayerRecvAudioFirstFrame

The callback triggered when the first audio frame is received. Description: After the [startPlayingStream] function is called successfully, this callback will be called when SDK received the first frame of audio data. Use cases: Developer can use this callback to count time consuming that take the first frame time or update the UI for playing stream. Trigger: This callback is triggered when SDK receives the first frame of audio data from the network. Related callbacks: After a successful call to [startPlayingStream], the callback function [onPlayerRecvVideoFirstFrame] determines whether the SDK has received the video data, and the callback [onPlayerRenderVideoFirstFrame] determines whether the SDK has rendered the first frame of the received video data.
Properties:
Name Type Description
result object param object
Properties
Name Type Description
streamID string Stream ID.
Source:

onPlayerRecvSEI

The callback triggered when Supplemental Enhancement Information is received. Description: After the [startPlayingStream] function is called successfully, when the remote stream sends SEI (such as directly calling [sendSEI], audio mixing with SEI data, and sending custom video capture encoded data with SEI, etc.), the local end will receive this callback. Trigger: After the [startPlayingStream] function is called successfully, when the remote stream sends SEI, the local end will receive this callback. Caution: Since the video encoder itself generates an SEI with a payload type of 5, or when a video file is used for publishing, such SEI may also exist in the video file. Therefore, if the developer needs to filter out this type of SEI, it can be before [initWithProfile/init] Call [ZegoEngineConfig.advancedConfig("unregister_sei_filter", "XXXXX")]. Among them, unregister_sei_filter is the key, and XXXXX is the uuid filter string to be set.
Properties:
Name Type Description
result object param object
Properties
Name Type Description
streamID string Stream ID.
data UInt8Array SEI content.
Source:

onPlayerRecvVideoFirstFrame

The callback triggered when the first video frame is received. Description: After the [startPlayingStream] function is called successfully, this callback will be called when SDK received the first frame of video data. Use cases: Developer can use this callback to count time consuming that take the first frame time or update the UI for playing stream. Trigger: This callback is triggered when SDK receives the first frame of video data from the network. Related callbacks: After a successful call to [startPlayingStream], the callback function [onPlayerRecvAudioFirstFrame] determines whether the SDK has received the audio data, and the callback [onPlayerRenderVideoFirstFrame] determines whether the SDK has rendered the first frame of the received video data.
Properties:
Name Type Description
result object param object
Properties
Name Type Description
streamID string Stream ID.
Source:

onPlayerRenderVideoFirstFrame

The callback triggered when the first video frame is rendered. Description: After the [startPlayingStream] function is called successfully, this callback will be called when SDK rendered the first frame of video data. Use cases: Developer can use this callback to count time consuming that take the first frame time or update the UI for playing stream. Trigger: This callback is triggered when SDK rendered the first frame of video data from the network. Related callbacks: After a successful call to [startPlayingStream], the callback function [onPlayerRecvAudioFirstFrame] determines whether the SDK has received the audio data, and the callback [onPlayerRecvVideoFirstFrame] determines whether the SDK has received the video data.
Properties:
Name Type Description
result object param object
Properties
Name Type Description
streamID string Stream ID.
Source:

onPlayerStateUpdate

The callback triggered when the state of stream playing changes. Description: After calling the [startPlayingStream] successfully, the notification of the playing stream state change can be obtained through the callback function. You can roughly judge the user's downlink network status based on whether the state parameter is in [PLAY_REQUESTING]. When to trigger: After calling the [startPublishingStream], this callback is triggered when a playing stream's state changed. Related callbacks: After calling the [startPublishingStream] successfully, the notification of the publish stream state change can be obtained through the callback function [onPublisherStateUpdate]. You can roughly judge the user's uplink network status based on whether the state parameter is in [PUBLISH_REQUESTING].
Properties:
Name Type Description
result object param object
Properties
Name Type Description
streamID string stream ID.
state ZegoPlayerState State of playing stream.
errorCode number The error code corresponding to the status change of the playing stream, please refer to the error codes document https://doc-en.zego.im/en/5548.html for details.
extendedData string Extended Information with state updates. As the standby, only an empty json table is currently returned.
Source:

onPlayerVideoSizeChanged

The callback triggered when the stream playback resolution changes. Description: After the [startPlayingStream] function is called successfully, the play resolution will change when the first frame of video data is received, or when the publisher changes the encoding resolution by calling [setVideoConfig], or when the network traffic control strategies work. Use cases: Developers can update or switch the UI components that actually play the stream based on the final resolution of the stream. Trigger: After the [startPlayingStream] function is called successfully, this callback is triggered when the video resolution changes while playing the stream. Caution: If the stream is only audio data, the callback will not be triggered.
Properties:
Name Type Description
result object param object
Properties
Name Type Description
streamID string Stream ID.
width number Video decoding resolution width.
height number Video decoding resolution height.
Source:

onPublisherCapturedAudioFirstFrame

The callback triggered when the first audio frame is captured. Description: After the [startPublishingStream] function is called successfully, this callback will be called when SDK received the first frame of audio data. Developers can use this callback to determine whether SDK has actually collected audio data. If the callback is not received, the audio capture device is occupied or abnormal. Trigger: In the case of no startPublishingStream audio and video stream or preview [startPreview], the first startPublishingStream audio and video stream or first preview, that is, when the engine of the audio and video module inside SDK starts, it will collect audio data of the local device and receive this callback. Related callbacks: After the [startPublishingStream] function is called successfully, determine if the SDK actually collected video data by the callback function [onPublisherCapturedVideoFirstFrame], determine if the SDK has rendered the first frame of video data collected by calling back [onPublisherRenderVideoFirstFrame].
Properties:
Name Type Description
result object param object
Source:

onPublisherCapturedVideoFirstFrame

The callback triggered when the first video frame is captured. Description: After the [startPublishingStream] function is called successfully, this callback will be called when SDK received the first frame of video data. Developers can use this callback to determine whether SDK has actually collected video data. If the callback is not received, the video capture device is occupied or abnormal. Trigger: In the case of no startPublishingStream video stream or preview, the first startPublishingStream video stream or first preview, that is, when the engine of the audio and video module inside SDK starts, it will collect video data of the local device and receive this callback. Related callbacks: After the [startPublishingStream] function is called successfully, determine if the SDK actually collected audio data by the callback function [onPublisherCapturedAudioFirstFrame], determine if the SDK has rendered the first frame of video data collected by calling back [onPublisherRenderVideoFirstFrame].
Properties:
Name Type Description
result object param object
Properties
Name Type Description
channel ZegoPublishChannel Publishing stream channel.If you only publish one audio and video stream, you can ignore this parameter.
Source:

onPublisherQualityUpdate

Callback for current stream publishing quality. Description: After calling the [startPublishingStream] successfully, the callback will be received every 3 seconds default(If you need to change the time, please contact the instant technical support to configure). Through the callback, the collection frame rate, bit rate, RTT, packet loss rate and other quality data of the published audio and video stream can be obtained, and the health of the publish stream can be monitored in real time.You can monitor the health of the published audio and video streams in real time according to the quality parameters of the callback function, in order to show the uplink network status in real time on the device UI. Caution: If you does not know how to use the parameters of this callback function, you can only pay attention to the [level] field of the [quality] parameter, which is a comprehensive value describing the uplink network calculated by SDK based on the quality parameters. Related callbacks: After calling the [startPlayingStream] successfully, the callback [onPlayerQualityUpdate] will be received every 3 seconds. You can monitor the health of play streams in real time based on quality data such as frame rate, code rate, RTT, packet loss rate, etc.
Properties:
Name Type Description
result object param object
Properties
Name Type Description
streamID string Stream ID.
quality ZegoPublishStreamQuality Publishing stream quality, including audio and video framerate, bitrate, RTT, etc.
Source:

onPublisherRelayCDNStateUpdate

The callback triggered when the state of relayed streaming to CDN changes. Description: Developers can use this callback to determine whether the audio and video streams of the relay CDN are normal. If they are abnormal, further locate the cause of the abnormal audio and video streams of the relay CDN and make corresponding disaster recovery strategies. Trigger: After the ZEGO RTC server relays the audio and video streams to the CDN, this callback will be received if the CDN relay status changes, such as a stop or a retry. Caution: If you do not understand the cause of the abnormality, you can contact ZEGO technicians to analyze the specific cause of the abnormality.
Properties:
Name Type Description
result object param object
Properties
Name Type Description
streamID string Stream ID.
infoList Array.<ZegoStreamRelayCDNInfo> List of information that the current CDN is relaying.
Source:

onPublisherStateUpdate

The callback triggered when the state of stream publishing changes. Description: After calling the [startPublishingStream] successfully, the notification of the publish stream state change can be obtained through the callback function. You can roughly judge the user's uplink network status based on whether the state parameter is in [PUBLISH_REQUESTING]. Caution: The parameter [extendedData] is extended information with state updates. If you use ZEGO's CDN content distribution network, after the stream is successfully published, the keys of the content of this parameter are [flv_url_list], [rtmp_url_list], [hls_url_list], these correspond to the publishing stream URLs of the flv, rtmp, and hls protocols. Related callbacks: After calling the [startPlayingStream] successfully, the notification of the play stream state change can be obtained through the callback function [onPlayerStateUpdate]. You can roughly judge the user's downlink network status based on whether the state parameter is in [PLAY_REQUESTING].
Properties:
Name Type Description
result object param object
Properties
Name Type Description
streamID string Stream ID.
state ZegoPublisherState State of publishing stream.
errorCode number The error code corresponding to the status change of the publish stream, please refer to the error codes document https://doc-en.zego.im/en/5548.html for details.
extendedData string Extended information with state updates.
Source:

onPublisherVideoSizeChanged

The callback triggered when the video capture resolution changes. Description: When the audio and video stream is not published [startPublishingStream] or previewed [startPreview] for the first time, the publishing stream or preview first time, that is, the engine of the audio and video module inside the SDK is started, the video data of the local device will be collected, and the collection resolution will change at this time. Trigger: After the successful publish [startPublishingStream], the callback will be received if there is a change in the video capture resolution in the process of publishing the stream. Use cases: You can use this callback to remove the cover of the local preview UI and similar operations.You can also dynamically adjust the scale of the preview view based on the resolution of the callback. Caution: What is notified during external collection is the change in encoding resolution, which will be affected by flow control.
Properties:
Name Type Description
result object param object
Properties
Name Type Description
width number Video capture resolution width.
height number Video capture resolution height.
channel ZegoPublishChannel Publishing stream channel.If you only publish one audio and video stream, you can ignore this parameter.
Source:

onRecvExperimentalAPI

Receive custom JSON content
Properties:
Name Type Description
result object param object
Properties
Name Type Description
content string JSON string content
Source:

onRemoteAudioSpectrumUpdate

The remote playing streams audio spectrum callback. Description: The remote playing streams audio spectrum callback. Trigger: After you start the audio spectrum monitor by calling [startAudioSpectrumMonitor], you are in the state of playing the stream [startPlayingStream]. Caution: The callback notification period is the parameter value set when the [startAudioSpectrumMonitor] is called. Related APIs: Start audio spectrum monitoring via [startAudioSpectrumMonitor]. Monitoring local played audio spectrum by callback [onCapturedAudioSpectrumUpdate].
Properties:
Name Type Description
result object param object
Properties
Name Type Description
audioSpectrums object Remote audio spectrum hash map, key is the streamID, value is the audio spectrum list of the corresponding streamID. Spectrum value range is [0-2^30]
Source:

onRemoteCameraStateUpdate

The callback triggered when the state of the remote camera changes. Description: The callback triggered when the state of the remote camera changes. Use cases: Developers of 1v1 education scenarios or education small class scenarios and similar scenarios can use this callback notification to determine whether the camera device of the remote publishing stream device is working normally, and preliminary understand the cause of the device problem according to the corresponding state. Trigger: When the state of the remote camera device changes, such as switching the camera, by monitoring this callback, it is possible to obtain an event related to the far-end camera, which can be used to prompt the user that the video may be abnormal. Caution: This callback will not be called back when the remote stream is play from the CDN, or when custom video acquisition is used at the peer.
Properties:
Name Type Description
result object param object
Properties
Name Type Description
streamID string Stream ID.
state ZegoRemoteDeviceState Remote camera status.
Source:

onRemoteMicStateUpdate

The callback triggered when the state of the remote microphone changes. Description: The callback triggered when the state of the remote microphone changes. Use cases: Developers of 1v1 education scenarios or education small class scenarios and similar scenarios can use this callback notification to determine whether the microphone device of the remote publishing stream device is working normally, and preliminary understand the cause of the device problem according to the corresponding state. Trigger: When the state of the remote microphone device is changed, such as switching a microphone, etc., by listening to the callback, it is possible to obtain an event related to the remote microphone, which can be used to prompt the user that the audio may be abnormal. Caution: This callback will not be called back when the remote stream is play from the CDN, or when custom audio acquisition is used at the peer (But the stream is not published to the ZEGO RTC server.).
Properties:
Name Type Description
result object param object
Properties
Name Type Description
streamID string Stream ID.
state ZegoRemoteDeviceState Remote microphone status.
Source:

onRemoteSoundLevelUpdate

The remote playing streams audio sound level callback. Description: The remote playing streams audio sound level callback. Trigger: After you start the sound level monitor by calling [startSoundLevelMonitor], you are in the state of playing the stream [startPlayingStream]. Caution: The callback notification period is the parameter value set when the [startSoundLevelMonitor] is called. Related APIs: Start sound level monitoring via [startSoundLevelMonitor]. Monitoring local captured audio sound by callback [onCapturedSoundLevelUpdate] or [onCapturedSoundLevelInfoUpdate].
Properties:
Name Type Description
result object param object
Properties
Name Type Description
soundLevels Object Remote sound level hash map, key is the streamID, value is the sound level value of the corresponding streamID, value ranging from 0.0 to 100.0.
Source:

onRemoteSpeakerStateUpdate

The callback triggered when the state of the remote speaker changes. Description: The callback triggered when the state of the remote microphone changes. Use cases: Developers of 1v1 education scenarios or education small class scenarios and similar scenarios can use this callback notification to determine whether the speaker device of the remote publishing stream device is working normally, and preliminary understand the cause of the device problem according to the corresponding state. Trigger: When the state of the remote speaker device changes, such as switching the speaker, by monitoring this callback, you can get events related to the remote speaker. Caution: This callback will not be called back when the remote stream is play from the CDN.
Properties:
Name Type Description
result object param object
Properties
Name Type Description
streamID string Stream ID.
state ZegoRemoteDeviceState Remote speaker status.
Source:

onRoomExtraInfoUpdate

The callback triggered when there is an update on the extra information of the room. Description: After the room extra information is updated, all users in the room will be notified except update the room extra information user. Use cases: Extra information for the room. When to call /Trigger: When a user update the room extra information, other users in the same room will receive the callback. Restrictions: None. Related APIs: Users can update room extra information through [setRoomExtraInfo] function.
Properties:
Name Type Description
result object param object
Properties
Name Type Description
roomID string Room ID where the user is logged in, a string of up to 128 bytes in length.
roomExtraInfoList Array.<ZegoRoomExtraInfo> List of the extra info updated.
Source:

onRoomOnlineUserCountUpdate

The callback triggered every 30 seconds to report the current number of online users. Description: This method will notify the user of the current number of online users in the room.. Use cases: Developers can use this callback to show the number of user online in the current room. When to call /Trigger: After successfully logging in to the room. Restrictions: None. Caution: 1. This function is called back every 30 seconds. 2. Because of this design, when the number of users in the room exceeds 500, there will be some errors in the statistics of the number of online people in the room.
Properties:
Name Type Description
result object param object
Properties
Name Type Description
roomID string Room ID where the user is logged in, a string of up to 128 bytes in length.
count number Count of online users.
Source:

onRoomStateUpdate

The callback triggered when the room connection state changes. Description: This callback is triggered when the connection status of the room changes, and the reason for the change is notified. Use cases: Developers can use this callback to determine the status of the current user in the room. When to trigger: Users will receive this notification when they call [loginRoom], [logoutRoom], [switchRoom] functions. 2. This notification may also be received when the user device's network conditions change (SDK will automatically log in to the room again when the connection is disconnected, refer to https://doc-zh.zego.im/faq/reconnect ). Restrictions: None. Caution: If the connection is being requested for a long time, the general probability is that the user's network is unstable. Related APIs: [loginRoom]、[logoutRoom]、[switchRoom]
Properties:
Name Type Description
result object param object
Properties
Name Type Description
roomID string Room ID, a string of up to 128 bytes in length.
state ZegoRoomState Changed room state
errorCode number Error code, please refer to the error codes document https://doc-en.zego.im/en/5548.html for details.
extendedData string Extended Information with state updates. When the room login is successful, the key "room_session_id" can be used to obtain the unique RoomSessionID of each audio and video communication, which identifies the continuous communication from the first user in the room to the end of the audio and video communication. It can be used in scenarios such as call quality scoring and call problem diagnosis.
Source:

onRoomStreamExtraInfoUpdate

The callback triggered when there is an update on the extra information of the streams published by other users in the same room. Description: All users in the room will be notified by this callback when the extra information of the stream in the room is updated. Use cases: Users can realize some business functions through the characteristics of stream extra information consistent with stream life cycle. When to call /Trigger: When a user publishing the stream update the extra information of the stream in the same room, other users in the same room will receive the callback. Restrictions: None. Caution: Unlike the stream ID, which cannot be modified during the publishing process, the stream extra information can be updated during the life cycle of the corresponding stream ID. Related APIs: Users who publish stream can set extra stream information through [setStreamExtraInfo].
Properties:
Name Type Description
result object param object
Properties
Name Type Description
roomID string Room ID where the user is logged in, a string of up to 128 bytes in length.
streamList Array.<ZegoStream> List of streams that the extra info was updated.
Source:

onRoomStreamUpdate

The callback triggered when the number of streams published by the other users in the same room increases or decreases. Description: When other users in the room start streaming or stop streaming, the streaming list in the room changes, and the developer will be notified through this callback. Use cases: This callback is used to monitor stream addition or stream deletion notifications of other users in the room. Developers can use this callback to determine whether other users in the same room start or stop publishing stream, so as to achieve active playing stream [startPlayingStream] or take the initiative to stop the playing stream [stopPlayingStream], and use it to change the UI controls at the same time. When to trigger: 1. When the user logs in to the room for the first time, if there are other users publishing streams in the room, the SDK will trigger a callback notification with `updateType` being [ZegoUpdateTypeAdd], and `streamList` is an existing stream list. 2. The user is already in the room. if another user adds a new push, the SDK will trigger a callback notification with `updateType` being [ZegoUpdateTypeAdd]. 3. The user is already in the room. If other users stop streaming, the SDK will trigger a callback notification with `updateType` being [ZegoUpdateTypeDelete]. 4. The user is already in the room. If other users leave the room, the SDK will trigger a callback notification with `updateType` being [ZegoUpdateTypeDelete]. Restrictions: None.
Properties:
Name Type Description
result object param object
Properties
Name Type Description
roomID string Room ID where the user is logged in, a string of up to 128 bytes in length.
updateType ZegoUpdateType Update type (add/delete).
streamList Array.<ZegoStream> Updated stream list.
extendedData string Extended information with stream updates.
Source:

onRoomUserUpdate

The callback triggered when the number of other users in the room increases or decreases. Description: When other users in the room are online or offline, which causes the user list in the room to change, the developer will be notified through this callback. Use cases: Developers can use this callback to update the user list display in the room in real time. When to trigger: 1. When the user logs in to the room for the first time, if there are other users in the room, the SDK will trigger a callback notification with `updateType` being [ZegoUpdateTypeAdd], and `userList` is the other users in the room at this time. 2. The user is already in the room. If another user logs in to the room through the [loginRoom] or [switchRoom] functions, the SDK will trigger a callback notification with `updateType` being [ZegoUpdateTypeAdd]. 3. If other users log out of this room through the [logoutRoom] or [switchRoom] functions, the SDK will trigger a callback notification with `updateType` being [ZegoUpdateTypeDelete]. 4. The user is already in the room. If another user is kicked out of the room from the server, the SDK will trigger a callback notification with `updateType` being [ZegoUpdateTypeDelete]. Restrictions: If developers need to use ZEGO room users notifications, please ensure that the [ZegoRoomConfig] sent by each user when logging in to the room has the [isUserStatusNotify] property set to true, otherwise the callback notification will not be received. Related APIs: [loginRoom]、[logoutRoom]、[switchRoom]
Properties:
Name Type Description
result object param object
Properties
Name Type Description
roomID string Room ID where the user is logged in, a string of up to 128 bytes in length.
updateType ZegoUpdateType Update type (add/delete).
userList Array.<ZegoUser> List of users changed in the current room.
Source:

onVideoDeviceStateChanged

The callback triggered when there is a change to video devices (i.e. new device added or existing device deleted). Description: By listening to this callback, users can update the video capture using a specific device when necessary. When to trigger: This callback is triggered when a video device is added or removed from the system. Restrictions: None
Properties:
Name Type Description
result object param object
Properties
Name Type Description
updateType ZegoUpdateType Update type (add/delete)
deviceInfo ZegoDeviceInfo Audio device information
Source: