logo
On this page

Class

ZegoAudioEffectPlayerZegoCopyrightedMusic
ZegoExpressEngineZegoExpressPlayer
ZegoExpressRangeAudioZegoLocalStream
ZegoRealTimeSequentialDataManagerZegoStreamCompositor
ZegoStreamView

ZegoAudioEffectPlayer

Audio effect player

Details

Detailed description: When you need to play short sound effects, such as applause, cheers, etc., you can use the sound effect player to achieve.

Methods

start

start
start(audioEffectID: string, options?: ZegoAudioEffectPlayOptions, onStart?: Function, onEnd?: Function): void
Start playing sound effects.

Parameters

NameTypeDescription
audioEffectIDstringID of the sound resource.
optionsZegoAudioEffectPlayOptionsOption settings for sound playback.
onStartFunctionCallback method for the start of sound playback.
onEndFunctionCallback method for the end of sound playback.

Details

Start playing the sound at the specified sound ID. The sound effect ID can be a preloaded sound effect [loadAudioEffect] or an online audio resource specified by providing the parameter [option.path] to load and play.

  • Use cases: When you need to play short sound effects, such as applause, cheers, etc., you can use this interface to achieve.
  • When to call /Trigger: Callable after [createAudioEffectPlayer].

Related interfaces: Stop playing the sound effect Interface [stop].

  • Caution:
  1. The same sound effect ID cannot be played repeatedly until the [onEnd] callback is triggered before the sound effect of the sound effect ID is played.
  2. Pausing the audio interface [pause] will not end the audio playback and will not trigger the [onEnd] callback.
  • Available since: 2.15.0

stop

stop
stop(audioEffectID?: string): boolean
Stop playing sound effects.

Parameters

NameTypeDescription
audioEffectIDstringThe ID of the sound effect resource. If no parameter is passed, all stoppable sound effects will be stopped.

Details

End playing sound effects.

  • When to call /Trigger: The specified [audioEffectID] is already [start] .

Related interfaces: Ending playing a sound effect will trigger the [onEnd] callback method of the start playing sound effect interface [start].

  • Caution: none.
  • Available since: 2.15.0

Return

Whether the interface call is successful.

pause

pause
pause(audioEffectID?: string): boolean
Start playing sound effects.

Parameters

NameTypeDescription
audioEffectIDstringThe ID of the sound effect resource. If no parameter is passed, all pauseable sound effects will be paused.

Details

Pauses the specified sound effect [audioEffectID].

  • When to call /Trigger: The specified [audioEffectID] has been [started].

Related interfaces: Start playing audio interface [start] , resume playing interface [resume].

  • Available since: 2.15.0

Return

Whether the interface call is successful.

resume

resume
resume(audioEffectID?: string): boolean
Resume playing sound.

Parameters

NameTypeDescription
audioEffectIDstringThe ID of the sound effect resource. If no parameters are passed, all recoverable sound effects will be restored.

Details

Resume playing the specified sound effect [audioEffectID].

  • When to call /Trigger: The specified [audioEffectID] is in the [pause] state.

Related interfaces: Start playing audio interface [start] , pause playing interface [pause].

  • Available since: 2.15.0

Return

Whether the interface call is successful.

setVolume

setVolume
setVolume(audioEffectID: string, volume: number): boolean
Setting the playback volume of a single sound effect will set both the local playback volume and the streaming volume.

Parameters

NameTypeDescription
audioEffectIDstringID of the sound resource.
volumenumberThe volume value, the value range: the range is [0,100], the default value: 100.

Details

Setting the playback volume of a single sound effect will set both the local playback volume and the streaming volume.

  • Use cases: Adjust the volume of the playing sound effect.
  • When to call /Trigger: Callable after [createAudioEffectPlayer].
  • Available since: 2.15.0

Return

Whether the interface call is successful.

getTotalDuration

getTotalDuration
getTotalDuration(audioEffectID: string): number
Get the total duration of the specified sound effect resource.

Parameters

NameTypeDescription
audioEffectIDstringThe ID of the sound effect resource.

Details

Get the total length of the specified sound effect resource, in milliseconds.

  • When to call /Trigger: It must be called after loading the resource, otherwise the return value is 0.

Related interfaces: Start playing the audio interface [start] and load the audio interface [loadAudioEffect].

  • Available since: 2.15.0

Return

The total duration of the audio, in milliseconds.

getCurrentProgress

getCurrentProgress
getCurrentProgress(audioEffectID: string): number
Get the current playback progress.

Parameters

NameTypeDescription
audioEffectIDstringThe ID of the sound effect resource.

Details

Get the current playback progress of the specified sound effect. The unit is milliseconds.

  • When to call /Trigger: The sound effect needs to have been played via [start], otherwise the return value is 0.

Related interfaces: Start playing the audio interface [start] .

  • Available since: 2.15.0

Return

Sound effect playback progress, in milliseconds.

seekTo

seekTo
seekTo(audioEffectID: string, time: number): boolean
Set the playback progress.

Parameters

NameTypeDescription
audioEffectIDstringThe ID of the sound effect resource.
timenumberThe duration of the specified playback progress. The value range is [0, the total duration] .

Details

Get the current playback progress of the specified sound effect. The unit is milliseconds.

Use case: Load an audio resource with multiple sound effects, and play the sound effects at the corresponding position through this interface.

When to call/

  • Trigger: The specified [audioEffectID] has been [started] and has not finished playing.

Related interfaces: Start playing the audio interface [start] .

  • Available since: 2.15.0

Return

Identifies whether the call was successful.

ZegoCopyrightedMusic

Copyrighted Music

Details

Detailed description: It is often used in KTV singing scenes. Users can use genuine music-related functions by creating copyrighted music instance objects.

Methods

getInstance

static
getInstance
getInstance(engine: any): ZegoCopyrightedMusic
NameTypeDescription
engineany-

destroyInstance

destroyInstance
destroyInstance(): void

initCopyrightedMusic

initCopyrightedMusic
initCopyrightedMusic(config: ZegoCopyrightedMusicConfig): Promise<number>
Initialize the copyright music module.

Parameters

NameTypeDescription
configZegoCopyrightedMusicConfigCopyright music configuration.

Details

Initialize the copyright music for subsequent use of copyright music functions.

  • When to call: After the engine instance calls the login room [loginRoom].
  • Caution: Real user information must be passed in, otherwise song resources cannot be obtained for playback. 2. The user ID and user name set when initializing copyrighted music need to be consistent with the user ID and user name set when logging into the room.
  • Available since: 2.24.5

Return

Error code, please refer to the common error code document for details. https://docs.zegocloud.com/article/6707

on

on
on<K extends keyof ZegoCopyrightedMusicEvent >(event: K, callBack: ZegoCopyrightedMusicEvent[K]): boolean
Register callback event.

Parameters

NameTypeDescription
eventKListener event name.
callBackZegoCopyrightedMusicEvent[K]Callback.

Details

The interface used to handle the SDK's initiative to notify developers of callbacks. By registering different events, you can receive callbacks of different functions. The event callback that can be monitored can be viewed in ZegoCopyrightedMusicEvent.

Use case: Callback processing for registering business events related to copyrighted music functions.

Timing of calling: After calling the interface createCopyrightedMusic to create the instance and before calling the interface loginRoom to log in to the room.

The same event can be registered multiple, the same registered event will be triggered in sequence according to the order of registration.

Related interface: call interface off to cancel the corresponding callback event processing.

Return

Whether the registration is successful.

sendExtendedRequest

sendExtendedRequest
sendExtendedRequest(command: string, params: any): Promise<ZegoCopyrightedMusicSendExtendedRequestResponse>
Send an extension feature request.

Parameters

NameTypeDescription
commandstringRequest commands. For specific supported commands, please refer to https://doc-zh.zego.im/online-ktv-web/client-api/send-extended-request.
paramsanyRequest parameters, each request command has corresponding request parameters, please refer to https://doc-zh.zego.im/online-ktv-web/client-api/send-extended-request.

Details

Send an extended function request to access the copyright song library to obtain related song lists and list song information.

  • Use cases: Used to get a list of songs.

  • When to call: After initializing copyrighted music [initCopyrightedMusic] successfully.

  • Available since: 2.24.5

Return

Promise returns the request result asynchronously.

requestResource

requestResource
Send an extension feature request.

Parameters

NameTypeDescription
configZegoCopyrightedMusicRequestConfigGet the configuration of sharing song resources.
typeZegoCopyrightedMusicResourceTypeCopyright music resource type. 0 is the normal song, 1 is the accompaniment, and 2 is the climactic segment.

Details

You can get the basic information of the song (duration, song title, singer, etc.), and the most important resource id that can be used for local playback, as well as some related authentication information.

  • Use cases: Obtain copyrighted songs for local playback and sharing.

  • When to call: After initializing copyrighted music [initCopyrightedMusic].

  • Caution: This interface triggers billing. Each resource has a unique resource ID.

  • Related APIs: After a user in the room calls this interface to obtain a music resource successfully, other users in the room can call the [getSharedResource] interface to obtain the music resource once for free.

  • Available since: 2.24.5

Return

Promise returns the request result asynchronously.

getSharedResource

getSharedResource
Get shared song resources.

Parameters

NameTypeDescription
configZegoCopyrightedMusicRequestConfigGet the configuration of sharing song resources.
typeZegoCopyrightedMusicResourceTypeCopyright music resource type. 0 is the normal song, 1 is the accompaniment, and 2 is the climactic segment.

Details

You can get the basic information of the song (duration, song title, singer, etc.), and the most important resource id that can be used for local playback, as well as some related authentication information.

  • Use cases: Obtain copyrighted songs for local playback and sharing.

  • When to call: After initializing copyrighted music [initCopyrightedMusic].

  • Caution: Each resource has a unique resource ID.

  • Related APIs: After a user in the room calls the [requestResource] interface to obtain a music resource successfully, other users in the room can call this interface to obtain the music resource once for free.

  • Available since: 2.24.5

Return

Promise returns the request result asynchronously.

getLrcLyric

getLrcLyric
getLrcLyric(songID: string, vendorID: ZegoCopyrightedMusicVendorID): Promise<ZegoCopyrightedMusicGetLrcLyricResponse>
Get the lyrics in lrc format.

Parameters

NameTypeDescription
songIDstringThe ID of the song or accompaniment, the song and accompaniment of a song share the same ID.
vendorIDZegoCopyrightedMusicVendorIDcopyright party.

Details

Get the lyrics in lrc format, and support line-by-line parsing of lyrics.

  • Use cases: Used to display lyrics line by line.
  • When to call: After initializing copyrighted music [initCopyrightedMusic] successfully.
  • Available since: 2.24.5

Return

Promise returns the lyrics result in lrc format asynchronously.

getKrcLyricByToken

getKrcLyricByToken
getKrcLyricByToken(krcToken: string): Promise<ZegoCopyrightedMusicGetKrcLyricByTokenResponse>
Get lyrics in krc format.

Parameters

NameTypeDescription
krcTokenstringGet the krcToken obtained from the music resource [requestResource]. For details, please refer to the lyrics resource interface description https://doc-zh.zego.im/online-ktv-electron/client-api/apis-to-obtain-songs-and-lyrics#2_2.

Details

Get lyrics in krc format, support word by word parsing of lyrics.

  • Use cases: Used to display lyrics verbatim.
  • Caution: After initializing copyrighted music [initCopyrightedMusic] successfully.
  • Available since: 2.24.5

Return

Promise returns the request result asynchronously.

download

download
download(resourceID: string): Promise<ZegoCopyrightedMusicDownloadResponse>
Download a song or accompaniment.

Parameters

NameTypeDescription
resourceIDstringThe resource ID corresponding to the song or comp.

Details

Download a song or accompaniment, it can be played only after the download is successful.

  • Use cases: After obtaining the copyright song or accompaniment authorization, use this interface to load the corresponding song or accompaniment resource.
  • When to call: After calling the get resource interface [requestResource] or [getSharedResource] to get the resourceID successfully.
  • Caution: Loading songs or accompaniment resources is affected by the network.
  • Available since: 2.24.5

Return

Promise returns the request result asynchronously.

clearCache

clearCache
clearCache(): void
Clear song cache.

When using this module, some cache files may be generated, which can be cleared through this interface.

  • Use cases: Used for caching of songs.
  • When to call /Trigger: After creating copyrighted music [createCopyrightedMusic].
  • Available since: 2.24.5

startScore

startScore
startScore(params: ZegoStartScoreParams): Promise<number>
Start Scoring.

Parameters

NameTypeDescription
paramsZegoStartScoreParamsStart scoring task related parameters.

Details

To start the scoring interface, you need to specify the resourceID of the media stream, song player, and song resource for the microphone collection. The SDK will start the scoring task based on this information.

  • Use cases: Can be used to display singing scores on views.
  • When to call: It can be called after getting the verbatim lyrics of krc and playing the accompaniment resource of copyright music.

Cautions: The H5 player playing the accompaniment must start playing to call this interface to start scoring, otherwise there may be a problem that the scoring is not aligned with the progress of the song.

Related interfaces: stopScore End scoring interface, used to end the scoring task. Only one scoring task can be performed at a time, and the current task needs to be completed before the next one can be performed.

  • Available since: 2.26.0

Return

Asynchronously returns the call result status code, 0 means the call is normal.

stopScore

stopScore
stopScore(resourceID: string): number
Stop Scoring.

Parameters

NameTypeDescription
resourceIDstringThe resource ID for the accompaniment or climactic clip.

Details

Ending the current rating will stop the [OnCurrentPitchValueUpdate] callback, but the average or total score can still be obtained normally.

  • Use cases: When grading is in progress, this interface can be called to end grading.
  • When to call: Callable while scoring is in progress.

Related interfaces: Start scoring interface startScore .

  • Available since: 2.26.0

Return

Status code, 0 means the call is normal.

pauseScore

pauseScore
pauseScore(resourceID: string): number
pause scoring.

Parameters

NameTypeDescription
resourceIDstringThe resource ID for the accompaniment or climactic clip.

Details

Pause scoring in progress.

  • Use cases: Called when a pause is required during singing.
  • When to call: Callable while scoring is in progress.

Related interfaces: Resume scoring interface resumeScore .

  • Available since: 2.26.0

Return

Status code, 0 means the call is normal.

resumeScore

resumeScore
resumeScore(resourceID: string): number
resume scoring.

Parameters

NameTypeDescription
resourceIDstringThe resource ID for the accompaniment or climactic clip.

Details

Pause scoring in progress.

  • Use cases: During the singing process, it is necessary to resume singing and scoring after a break.
  • When to call: After calling start scoring interface startScore and suspending scoring.

Related interfaces: Pause scoring interface pauseScore.

  • Available since: 2.26.0

Return

Status code, 0 means the call is normal.

resetScore

resetScore
resetScore(resourceID: string): number
reset the score.

Parameters

NameTypeDescription
resourceIDstringThe resource ID for the accompaniment or climactic clip.

Details

Reset the score that has been scored for this scoring task.

  • Use cases: I sang part of this scoring task but want to start over and re-score.
  • When to call: After calling the scoring interface startScore.
  • Available since: 2.26.0

Return

Status code, 0 means the call is normal.

getPreviousScore

getPreviousScore
getPreviousScore(resourceID: string): Promise<number>
Get the score of the previous sentence.

Parameters

NameTypeDescription
resourceIDstringThe resource ID for the accompaniment or climactic clip.

Details

The return value is to get the score of the previous sentence.

  • Use cases: Can be used to display the score of each sentence on the view.
  • When to call: It can be called after playing the copyright accompaniment or climax clip and starting to score.
  • Available since: 2.26.0

Return

The return value is to get the score of the previous sentence.

getAverageScore

getAverageScore
getAverageScore(resourceID: string): Promise<number>
Get the average rating.

Parameters

NameTypeDescription
resourceIDstringThe resource ID for the accompaniment or climactic clip.

Details

Get the average rating.

  • Use cases: Can be used to display the average rating on the view.
  • When to call: It can be called after playing the copyright accompaniment or climax clip and starting to score.
  • Available since: 2.26.0

Return

Returns the average rating.

getTotalScore

getTotalScore
getTotalScore(resourceID: string): Promise<number>
Get the total score.

Parameters

NameTypeDescription
resourceIDstringThe resource ID for the accompaniment or climactic clip.

Details

Get the total score.

  • Use cases: Can be used to display the total score on the view.
  • When to call: It can be called after playing the copyright accompaniment or climax clip and starting to score.
  • Available since: 2.26.0

Return

Return the score.

getFullScore

getFullScore
getFullScore(resourceID: string): Promise<number>
Get full marks.

Parameters

NameTypeDescription
resourceIDstringThe resource ID for the accompaniment or climactic clip.

Details

Get full marks.

  • Use cases: Can be used to display full marks on views.
  • When to call: It can be called after playing the copyright accompaniment or climax clip and starting to score.
  • Available since: 2.26.0

Return

Return the score.

getStandardPitch

getStandardPitch
getStandardPitch(resourceID: string): Promise<ZegoCopyrightedMusicGetStandardPitchResponse>
Get standard pitch data.

Parameters

NameTypeDescription
resourceIDstringThe resource ID for the accompaniment or climactic clip.

Details

Get standard pitch data.

  • Use cases: Can be used to display standard pitch lines on a view.
  • When to call: It can be called after calling requestResource to request the corresponding copyright accompaniment or climax clip.

Cautions: Only accompaniment or climax clip assets have pitchlines.

  • Available since: 2.26.0

Return

Returns the standard pitch data result.

getCurrentPitch

getCurrentPitch
getCurrentPitch(resourceID: string): Promise<number>
Get real-time pitch data.

Parameters

NameTypeDescription
resourceIDstringThe resource ID for the accompaniment or climactic clip.

Details

Get real-time pitch data.

  • Use cases: Can be used to display the pitch buoy position on the view.
  • When to call: It can be called after playing the copyright accompaniment or climax clip and starting to score.
  • Available since: 2.26.0

Return

Returns the real-time pitch value.

setScoringLevel

setScoringLevel
setScoringLevel(level: number): void
Set the scoring difficulty level.

Parameters

NameTypeDescription
levelnumberRate the difficulty level. The value range of level is 0~4. The difficulty of scoring decreases gradually from 0 to 4.

Details

Users can set the scoring difficulty level through this interface.

  • Default value: When this function is not called, the scoring difficulty level defaults to 4, the lowest level of difficulty.
  • When to call: After the call to initialize copyright music is successful, call [startScore] before starting scoring.
  • Available since: 2.26.0

ZegoExpressEngine

Express Video SDK

Details

This class is used to initialize the express SDK engine instance.

Properties

version

version
static version: string

Detailed description: SDK version number.

Methods

setGeoFence

static
setGeoFence
setGeoFence(type: ZegoGeoFenceType, areaList: number[]): void
Set Geo Fence.

Parameters

NameTypeDescription
typeZegoGeoFenceTypeGeo fence type. Description: Used to set the geo fence type.
areaListnumber[]Geo fence area. Description: Used to describe the range of geo fence.

Details

If you need to use the geo fence feature, please call this function to complete the configuration.

  • When to call: Must be set before calling [createEngine] to take effect, otherwise it will fail.
  • Available since: 2.26.0
  • Restrictions: If you need to use the geo fence feature, please contact ZEGO Technical Support.

setEngineOptions

static
setEngineOptions
setEngineOptions(options: any): void
Set engine advanced configuration.

Parameters

NameTypeDescription
optionsanyAdvanced engine configuration.

Details

Set the advanced configuration of the engine.

  • Use cases: Used when special configuration operations are required for the SDK engine, please consult ZEGO technical support for details.
  • When to call: Must be set before calling new to take effect, otherwise it will fail.
  • Available since: 2.26.0 and above.

use

static
use
use(module: any): void
Import module, you can import other modules on demand through this interface.

Parameters

NameTypeDescription
moduleanyFunctional module.

Details

You can use this interface to introduce other functional modules as needed, such as background blur, AI noise reduction and other functional modules.

  • When to call /Trigger: After initializing the ZegoExpressEngine instance.
  • Available since: 2.10.0

presetLogConfig

static
presetLogConfig
presetLogConfig(config: ZegoLogConfig): boolean
Default log configuration

Parameters

NameTypeDescription
configZegoLogConfigLog related advanced configuration
  • Default value: Both the local log and upload level are info.
  • When to call: before initialization.

Usage restriction: None, but it is recommended to call it only once in the entire life cycle.

Unless there is a clear special requirement, please do not call this interface to change the default configuration.

  • Related callbacks: None

Related interface: The difference from setLogConfig is that it can be called before initializing the instance.

Return

Whether the call is successful; failure condition: the input parameter format is wrong

setCloudProxyConfig

static
setCloudProxyConfig
setCloudProxyConfig(proxyList: ZegoProxyInfo[], token: string, enable: boolean): void
Set up cloud proxy configuration.

Parameters

NameTypeDescription
proxyListZegoProxyInfo[]List of proxy server information.
tokenstringAuthentication information.
enablebooleanWhether to enable proxy.
  • When to call: Called before initialization.

Usage restriction: This interface cannot be called to modify the configuration after initializing the instance to avoid unexpected errors.

setLocalProxyConfig

static
setLocalProxyConfig
setLocalProxyConfig(proxyConfig: ZegoLocalProxyConfig, enable: boolean): void
Set local proxy configuration.

Parameters

NameTypeDescription
proxyConfigZegoLocalProxyConfigDomain name and path configuration information of the proxy server.
enablebooleanWhether to enable proxy.
  • When to call: Called before initialization.

Usage restriction: 1. This interface cannot be called to modify the configuration after initializing the instance to avoid unexpected errors. 2. It cannot be used together with setCloudProxyConfiguration.

createStreamCompositor

createStreamCompositor
createStreamCompositor(): void
Create a broadcast station

Create a broadcast station instance object, which is used to combine multiple media streams into one.

  • Use cases: When you need to combine multiple video streams and pictures of local users into one video stream, such as online education, remote conferences, live broadcasts, etc., you can use the broadcast station to achieve this.
  • Caution:
  1. Each broadcast station object can only output one mixed stream.
  2. Mobile terminal is not supported yet.
  • Available since: 3.0.0

uploadLog

uploadLog
uploadLog(): Promise<{ errorCode: number; extendedData: string }>
Upload local logs

Read local logs and upload them. (Before version 3.11.0, you need to contact ZEGO technical support to enable the local storage function for logs in order to use it.)

  • Use cases: When a user has a problem, he can click to upload the offline log saved in the browser by the SDK to the ZEGO background, so that ZEGO technical staff can help and troubleshoot user problems.
  • When to call: After logging into the room.
  • Caution: none.
  • Related APIs: none.
  • Related callbacks: none.
  • Available since: 2.26.0.
  • Restrictions: Token version 04 is required to log in to the room.

"errorCode" is the returned error code, 0 means the upload is successful, and 1102022 means the upload failed; "extendedData" is the description of the error code information.

setSEIConfig

setSEIConfig
setSEIConfig(config: ZegoSEIConfig): void
Set SEI related configuration information

Parameters

NameTypeDescription
configZegoSEIConfigSEI function related configuration.
  • When to call: after initialization.

s: None.

  • Related callbacks: None.

setRoomScenario

setRoomScenario
setRoomScenario(scenario: ZegoScenario): boolean
set room scenario

Parameters

NameTypeDescription
scenarioZegoScenariothe value of scenario

Details

Developers can set the usage scenarios of the room, and the SDK will adopt different optimization strategies for different scenarios to obtain better results; the function of this function is exactly the same as the [scenario] parameter in the initialization engine instance [options] configuration.

  • Use cases: This function is suitable for modifying the settings of various audio and video business scenarios, such as 1v1 audio and video call scenarios and show live broadcast scenarios; this function can be used to switch scenarios under the premise of the same engine instance.
  • Default value: none
  • When to call /Trigger: It must be set before calling [loginRoom], and it will be generated in [createStream] called later, and it will not be generated for the stream that has already been created.
  • Caution: 1.Users in the same room recommend using the same room scene for best results. 2.Setting the scene will affect the audio and video configurations such as audio and video bit rate, frame rate, resolution, encoding type, 3A, ear return, etc. If developers have special needs, they can call other various APIs to set the above configuration after setting the room scene. 3.Calling this function will overwrite the scene specified when [new ZegoExpressEngine] was called or the scene set by the previous call to this function.
  • Available since: Supported version: 1.0.0 and above
  • Restrictions: Once you log in to the room, you are no longer allowed to modify the room scene. If you need to modify the scene, you need to log out of the room first. If you log in to multiple rooms, you need to log out of all rooms before modifying.

Return

true means the setting is successful, false means the setting fails

setEngineConfig

setEngineConfig
setEngineConfig(config: any): void
Set engine advanced configuration.

Parameters

NameTypeDescription
configanyAdvanced engine configuration.

Details

2.21.0 and above.

Detailed description: Set the advanced configuration of the engine.

Business scenario: Used when special configuration operations are required for the SDK engine, please consult ZEGO technical support for details.

destroyEngine

destroyEngine
destroyEngine(): void
destroy Engine.
  • Default value: no default value.

  • When to call: the last API called by the same engine instance.

    After destroying the engine, the instantiated object should be cleared in time, and other interfaces of the engine object should not be called, otherwise unexpected problems may occur.

setTurnServer

setTurnServer
setTurnServer(turnServers: ZegoTurnServer[]): void
Turn server configuration for proxy.

Parameters

NameTypeDescription
turnServersZegoTurnServer[]Domain name and path configuration information of the proxy server.
  • When to call: Called before initiating push or pull streaming.

callExperimentalAPI

callExperimentalAPI
callExperimentalAPI(params: Object): Promise<any>
The error log information alert indicates that the default test environment is all on

Parameters

NameTypeDescription
paramsObjectThe passed-in parameters are in JSON Object. Please consult ZEGO technical support for details.
  • When to call: After initialization.

checkSystemRequirements

checkSystemRequirements
checkSystemRequirements<T extends keyof ZegoCheckSingleType>(checkType?: T, checkLevel: 0 | 1): Promise<ZegoCapabilityDetection>
Support capability detection interface

Parameters

NameTypeDescription
checkTypeTSpecify to check the capabilities that a browser can support, such as: webRTC, VP8, etc. This parameter is not passed by default to check all supported capabilities.
checkLevel0 | 1For the level of detection coding format, 0 means fast detection with high accuracy; 1 means accurate detection with long time consuming and higher accuracy.
  • Default value: none
  • When to call: After initialization, it is called before the flow is created.

Restrictions on use: None

  1. The real support depends not only on the browser, but also on the system, so there is a low probability of inaccurate monitoring.
  2. When you choose to check the camera or microphone capability, the browser will prompt a pop-up box to ask for permission to allow the device.
  3. In the case of using only play stream but not publish stream, you don't need to check the device capability, only need to check "webRTC", "H264" or "VP8". Example: const result = await zg.checkSystemRequirements("webRTC").

Scope of influence: None

  • Related callbacks: None

Related interface: None

  • Platform differences: None

off

off
off<K extends keyof ZegoEvent>(event: K, callBack?: ZegoEvent[K]): boolean
Delete the registered callback event

Parameters

NameTypeDescription
eventKListener event name
callBackZegoEvent[K]Callback, optional
  • When to call: after registration, before exiting the room.
  • Default value: none

Restrictions on use: None

When there are multiple events of the same type, they will all be deleted.

Scope of influence: None

  • Related callbacks: None

Related interface: None

  • Platform differences: None

on

on
on<K extends keyof ZegoEvent>(event: K, callBack: ZegoEvent[K]): boolean
Register callback event

Parameters

NameTypeDescription
eventKListener event name.
callBackZegoEvent[K]Callback.

Details

Supported version: 1.0.0 and above

Detailed description: ZegoEvent includes ZegoRTCEvent and [ZegoRTMEvent](https://doc- en.zego.im/article/api?doc=Express_Video_SDK_APIjavascript_webinterface~ZegoRTMEvent), which is used to handle the API that SDK actively notifies developers of callbacks. By registering events of different events, you can receive callbacks of different functions.

Business scenario: General interface, used to monitor SDK business events.

Timing of calling: After initializing the instance, before calling the interface loginRoom to log in to the room.

The same event can be registered multiple, the same registered event will be triggered in sequence according to the order of registration.

Related interface: call interface off to cancel the corresponding callback event processing.

Return

Whether the registration is successful.

getNetworkTimeInfo

getNetworkTimeInfo
getNetworkTimeInfo(): { timestamp: number; maxDeviation: number; }
Get synchronous network time information.

Get the current network time (NTP), including the timestamp and maximum error of the current network time.

  • Use cases: When performing multi-terminal behavior synchronization, it is necessary to obtain the synchronization network time to calibrate the current time.
  • When to call: After initializing a ZegoExpresEngine instance.
  • Available since: 3.0.0

Return the network timestamp information, timestamp is the synchronized network timestamp, 0 means not yet synchronized; maxDeviation is the maximum error value.

createStream

createStream
deprecated
createStream(source?: ZegoLocalStreamConfig): Promise<MediaStream>
Create push streaming data sources, including camera microphone collection source data, screen sharing data, third-party source data (other source data that can be played on the page)

Parameters

NameTypeDescription
sourceZegoLocalStreamConfigParameter configuration related to the source of creating a MediaStream, If not upload, the default is to create the media stream of the camera

Details

Create media stream and set push stream related parameters, including camera capture streams, screen sharing capture streams, local or online media streams and other types.

  • Use cases: Used to enable functions such as camera capture or screen sharing.
  • Default value: The default is the camera capture stream, and the default is the high-definition format.
  • When to call: It can be called after initializing and calling the interface checkSystemRequirements to check that the returned result is supported.
  • Caution: 1. The understanding of the video width and height is different between the mobile terminal and the PC terminal. The two are exactly the opposite. The same resolution is horizontal screen on the PC terminal and vertical screen on the mobile terminal.
  1. The interface must be called under the secure domain name (https, localhost, 127.0.0.1).
  2. When pushing a third-party stream, the input corresponding to the <video> tag must be loaded successfully (oncanplay callback of media tag) before calling this interface.
  3. Set the start bitrate parameter startBitrate to "target" (supported by chrome kernel only), the bitrate will increase rapidly when streaming, and if the network is poor, freezes or screens may occur, so it is recommended to use the default slow increase method.
  4. If there is a need to temporarily open and close the audio or video, it is recommended to push the audio and video stream first, and then set the enable corresponding to the unnecessary audio or video track to false, and to turn on the audio or video track after pushing the stream, you can call replaceTrack interface.
  5. When the screen sharing setting source.screen.audio is true (only supported by windows), only the system sound will be pushed, not the microphone sound.
  6. Although the API supports setting the resolution, many devices do not support custom resolutions. It is recommended to use several resolutions preset by the parameter source.camera.videoQuality or source.screen.videoQuality.
  7. camera.channelCount and custom.channelCount are only supported by chrome kernel browser.
  • Related callbacks: Publishing stream quality callback The content of the quality message of publishQualityUpdate will be related to the setting parameters; the media stream will be automatically destroyed when the screen sharing interrupt callback screenSharingEnded is triggered.
  • Related APIs: Destroy the created media stream interface destroyStream and start pushing the stream interface startPublishingStream.
  • Available since: 1.0.0 and above.
Deprecated
Deprecated since 3.0.0, please refer to Upgrade guide v3.0.0+.

Return

Promise to return the streaming object asynchronously. Creation failure returns error code: 1103064, which means media stream-related device permissions. 1103065 indicates that the specified device cannot be used to capture media streams, and the camera or microphone may be occupied by other applications. 1103066 Indicates that the related constraint parameters for creating the stream are incorrect, possibly the specified device ID is invalid. 1103061 Indicates that the acquisition of the media stream failed. For the specific failure reason, please refer to the document "getUserMedia exceptions" (https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#exceptions).

createZegoStream

createZegoStream
createZegoStream(source?: ZegoStreamOptions): Promise<ZegoLocalStream>
Create an instance of the push object ZegoLocalStream. The integrated functions of ZegoLocalStream include camera microphone capture, screen sharing capture, third-party source data (other source data that can be played on the page), and playback preview of the collected stream.

Parameters

NameTypeDescription
sourceZegoStreamOptionsParameter configuration related to the source of creating a MediaStream, If not upload, the default is to create the media stream of the camera

Details

Create an instance of ZegoLocalStream, a streaming object, and set the relevant parameters of the capture, streaming bitrate, and playback preview container. Capture related parameter settings include camera capture stream, screen sharing capture stream, local or online media stream, etc.

  • Use cases: Used to enable functions such as camera capture or screen sharing.
  • Default value: The default is the camera capture stream, and the default is the high-definition format.
  • When to call: It can be called after initializing and calling the interface checkSystemRequirements to check that the returned result is supported.
  • Caution: 1. The understanding of the video width and height is different between the mobile terminal and the PC terminal. The two are exactly the opposite. The same resolution is horizontal screen on the PC terminal and vertical screen on the mobile terminal.
  1. The interface must be called under the secure domain name (https, localhost, 127.0.0.1).
  2. When pushing a third-party stream, the input corresponding to the <video> tag must be loaded successfully (oncanplay callback of media tag) before calling this interface.
  3. Set the start bitrate parameter startBitrate to "target" (supported by chrome kernel only), the bitrate will increase rapidly when streaming, and if the network is poor, freezes or screens may occur, so it is recommended to use the default slow increase method.
  4. If there is a need to temporarily open and close the audio or video, it is recommended to push the audio and video stream first, and then Then call [mutePublishStreamVideo] to open and close the video, [mutePublishStreamAudio] to open and close the audio. If you want to update the capture audio or video track after pushing the stream, you can call [start Capture Camera], [startCapture Microphone] and other capture APIs on the ZegoLocalStream instance, and combine it with [updatePublishingStream] to update the audio and video in the push stream.
  5. When the screen sharing setting source.screen.audio is true (only supported by windows), only the system sound will be pushed, not the microphone sound.
  6. Although the API supports setting the resolution, many devices do not support custom resolutions. It is recommended to use several resolutions preset by the parameter source.camera.video.quality or source.screen.video.quality.
  7. camera.audio.channelCount and custom.audio.channelCount are only supported by chrome kernel browser.
  • Related callbacks: Publishing stream quality callback The content of the quality message of publishQualityUpdate will be related to the setting parameters; the media stream will be automatically destroyed when the screen sharing interrupt callback screenSharingEnded is triggered.
  • Related APIs: Destroy the created media stream interface destroyStream and start pushing the stream interface startPublishingStream.
  • Available since: 3.0.0 and above.

Return

Promise to return the streaming object asynchronously. Creation failure returns error code: 1103064, which means media stream-related device permissions. 1103065 indicates that the specified device cannot be used to capture media streams, and the camera or microphone may be occupied by other applications. 1103066 Indicates that the related constraint parameters for creating the stream are incorrect, possibly the specified device ID is invalid. 1103061 Indicates that the acquisition of the media stream failed. For the specific failure reason, please refer to the document "getUserMedia exceptions" (https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#exceptions).

updatePublishingStream

updatePublishingStream
updatePublishingStream(zegoStream: ZegoLocalStream, updateType: ZegoStreamUpdateType): Promise<ZegoServerResponse>
Used to update audio and video tracks of ZegoLocalStream instances that are being pushed

Parameters

NameTypeDescription
zegoStreamZegoLocalStreamZegoLocalStream instance object created by createZegoStream
updateTypeZegoStreamUpdateType

Details

Used to update audio and video tracks of ZegoLocalStream instances that are being pushed.

  • Use cases: Call [createZegoStream] to create a ZegoLocalStream instance object. After [startPublishingStream] successfully pushes the stream, you need to update the audio and video being pushed by the ZegoLocalStream instance.

  • Caution: ZegoLocalStream is required to successfully capture audio and video streams for update.

  • Available since: 3.0.0

getPublishingStreamQuality

getPublishingStreamQuality
getPublishingStreamQuality(streamID: string): ZegoPublishStats | null
Get the publishing stream quality.

Parameters

NameTypeDescription
streamIDstringID of stream.

Details

Actively obtain the streaming quality that is being pushed.

  • Use cases: Obtain the quality parameters such as the resolution, frame rate, and bit rate of the current push stream.
  • When to call: [startPublishingStream] After the push stream is successful.
  • Related APIs: Publishing stream quality callback [publishQualityUpdate].
  • Available since: 2.15.0
  • Restrictions: Since the streaming quality parameters of the SDK are updated every 3 seconds, it is recommended that the calling interval of this interface should not be less than 3 seconds.

Return

Publishing stream quality information, if the acquisition fails, it will return null.

getElectronScreenSources

getElectronScreenSources
getElectronScreenSources(): Promise<ZegoElectronScreenSource[]>
Called when screen sharing is required in the electron framework to return screen list data

supported version: 2.11.0

detailed description: called when screen sharing is required in the electron framework to return screen list data.

business scenario: called when screen sharing is required in the electron framework.

call timing: after initialization.

precautions: none.

related callback: none.

related interface: createstream.

Electronic screen source list data

setCaptureAudioFrameCallback

setCaptureAudioFrameCallback
setCaptureAudioFrameCallback(stream: MediaStream|ZegoLocalStream, callback: ((audioData:ZegoAudioFrame)=>void) | null, options?: AudioFrameOptions): Promise<ZegoServerResponse>
Set the callback for streaming raw audio data

Parameters

NameTypeDescription
streamMediaStream|ZegoLocalStreamZegoLocalStream created by createZegoStream or MediaStream created by createStream
callback((audioData:ZegoAudioFrame)=>void) | nullThe callback function that receives audio data. If set to null, the audio data will no longer be called back.
options?AudioFrameOptionsThe option of callback function that receives audio data
  • Default value: None

Timing of calling: After the stream is the stream is collected successfully.

Restrictions on use: None

  1. The stream has an audio.
  2. It is only valid for RTC streams or L3 streams, and cannot operate CDN pull streams.
  3. Chrome browser support 85 above.
  4. Due to browser limitations, data callbacks are only available after interaction with the page.

Scope of influence: None

  • Related callbacks: None

Related interface: None

  • Platform differences: None

destroyStream

destroyStream
destroyStream(localStream: MediaStream | ZegoLocalStream): void
Destroy the created stream data

Parameters

NameTypeDescription
localStreamMediaStream | ZegoLocalStreamThe stream created by createStream or the ZegoLocalStream instance object created by createZegoStream
  • Default value: None
  • When to call: it can only be called after the stream is created.

Restrictions on use: None

In the process of streaming, destroying the streaming will cause the streaming to be interrupted. Please stop the streaming before destroying the streaming, otherwise the peer screen will be stuck.

Scope of influence: None

  • Related callbacks: None

Related interface: create push stream data source createStream.

  • Platform differences: None

checkVideoTrackIsActive

checkVideoTrackIsActive
checkVideoTrackIsActive(stream: MediaStream | ZegoLocalStream): Promise<boolean>
Check whether the video track is active.

Parameters

NameTypeDescription
streamMediaStream | ZegoLocalStreamThe stream created by createStream or the ZegoLocalStream instance object created by createZegoStream.
  • Default value: None
  • When to call: it can only be called after the stream is created.

Restrictions on use: None

Only valid for local capture streams generated by createStream.

Scope of influence: None

  • Related callbacks: None

Related interface: create push stream data source createStream.

  • Platform differences: None

checkAudioTrackIsActive

checkAudioTrackIsActive
checkAudioTrackIsActive(stream: MediaStream): Promise<boolean>
Check whether the audio track is active.

Parameters

NameTypeDescription
streamMediaStreamThe stream created by createStream or the ZegoLocalStream instance object created by createZegoStream.
  • Default value: None
  • When to call: it can only be called after the stream is created.

Restrictions on use: None

Only valid for local capture streams generated by createStream.

Scope of influence: None

  • Related callbacks: None

Related interface: create push stream data source createStream.

  • Platform differences: None

startPublishingStream

startPublishingStream
startPublishingStream(streamID: string, localStream: MediaStream | ZegoLocalStream, publishOption?: ZegoWebPublishOption): boolean
Start publishing stream

Parameters

NameTypeDescription
streamIDstringStream ID, a string of up to 256 characters in length.
Precautions:
1. The stream ID is defined by yourself.
2. It needs to be globally unique within the entire AppID. If it appears in the same AppID and different users push a stream with the same stream name, the user who pushed the stream later will fail to push the stream.
3. Only numbers, English characters and '-', '_' are supported.
localStreamMediaStream | ZegoLocalStreamThe stream created by createStream or the ZegoLocalStream instance object created by createZegoStream.
publishOptionZegoWebPublishOptionPush pull additional parameters (authentication, video coding), optional.
  • Default value: publishOption.videoCodec uses H.264 to push streaming by default. If you have special needs, you can choose VP8. For more scenarios, please consult ZEGO's pre-sales engineers.
  • When to call: After the stream is successfully created.
  • Related callbacks: Push quality callback PublishQualityUpdate, the thrill state callback PublisherstateUpdate (can be judged by this interface to determine if the stream is successful).

Related interface: End the stream by calling the interface StoppublishingStream.

Return

true means that the client sends the request successfully, and the stream is successfully pushed to the server and needs to be judged through the stream status callback interface.

stopPublishingStream

stopPublishingStream
stopPublishingStream(streamID: string): boolean
Stop pushing the local stream to the remote end (Zego server)

Parameters

NameTypeDescription
streamIDstringPush stream ID, consistent with push stream ID
  • Default value: None

Timing of calling: after successful push.

Restrictions on use: None

Stopping streaming will not cause the rendered <video> screen to be paused. Developers need to destroy the <video> by themselves.

Scope of influence: None

  • Related callbacks: push stream quality callback publishQualityUpdate, push stream state callback publisherStateUpdate.

Related interface: startPublishingStream.

  • Platform differences: None

sendSEI

sendSEI
sendSEI(streamID: string, inData: Uint8Array): boolean
Sends Supplemental Enhancement Information.

Parameters

NameTypeDescription
streamIDstringstreamID
inDataUint8ArraySEI data

Details

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].
  • Caution: 1. Supported browsers: Chrome 86 and above, Firefox 117 and above, Safari 15.4 and above, Android WeChat browser.
  1. 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.
  2. SEI has high performance requirements, and simultaneous SEI operation on multiple streams may have an impact
  • Related APIs: After the pusher sends the SEI, the puller can obtain the SEI content by monitoring the callback of [on] event "PlayerRecvSEI".
  • Related callbacks: none.
  • Available since: 2.16.0
  • Restrictions: Do not exceed 30 times per second, and the SEI data length is limited to 4096 bytes.

setVideoConfig

setVideoConfig
setVideoConfig(localStream: MediaStream | ZegoLocalStream, constraints: ZegoPublishStreamConfig): Promise<ZegoServerResponse>
Modify push streaming parameters

Parameters

NameTypeDescription
localStreamMediaStream | ZegoLocalStreamThe stream created by createStream or the ZegoLocalStream instance object created by createZegoStream.
constraintsZegoPublishStreamConfigFlow constraints
  • Default value: The default video capture resolution is 640 * 480, frame rate is 15, and bitrate is 800 kbps.

Timing of calling: After calling the interface createStream or createZegoStream to create a stream successfully. 2.15.0 and earlier versions can call this interface only after the stream is pushed successfully.

Restrictions on use: None

The modified localStream must be obtained by calling the createStream or createZegoStream method of the SDK.

Scope of influence: None

  • Related callbacks: push stream quality callback publishQualityUpdate.

Related interface: None

  • Platform differences: None

setAudioConfig

setAudioConfig
setAudioConfig(localStream: MediaStream | ZegoLocalStream, constraints: ZegoPublishStreamAudioConfig): Promise<ZegoServerResponse>
Modify the relevant parameters of push streaming audio

Parameters

NameTypeDescription
localStreamMediaStream | ZegoLocalStreamThe stream created by createStream or the ZegoLocalStream instance object created by createZegoStream.
constraintsZegoPublishStreamAudioConfigFlow constraints
  • Default value: None

Timing of calling: After calling the interface createStream or createZegoStream to create a stream successfully. 2.15.0 and earlier versions can call this interface only after the stream is pushed successfully.

Restrictions on use: None

The modified localStream must be obtained by calling the createStream or createZegoStream method of the SDK.

Scope of influence: None

  • Related callbacks: push stream quality callback publishQualityUpdate.

Related interface: None

  • Platform differences: None

replaceTrack

replaceTrack
deprecated
replaceTrack(localStream: MediaStream, mediaStreamTrack: MediaStreamTrack): Promise<ZegoServerResponse>
Replace the audio and video tracks of the media stream

Parameters

NameTypeDescription
localStreamMediaStreamStream created by stream
mediaStreamTrackMediaStreamTrackAudio and video track
  • Default value: None

Timing of calling: This interface can be called only after the flow is successfully created.

Restrictions on use: None

The localStream to be replaced must be obtained by calling the createStream method of the SDK.

Scope of influence: None

  • Related callbacks: None

Related interface: None

  • Platform differences: None
Deprecated
Deprecated since 3.0.0, please refer to Upgrade guide v3.0.0+.

addTrack

addTrack
deprecated
addTrack(localStream: MediaStream, track: MediaStreamTrack): Promise<ZegoServerResponse>
Add an audio or video track to a media stream.

Parameters

NameTypeDescription
localStreamMediaStreamStream created by stream.
trackMediaStreamTrackVideo track.
  • Default value: None

Timing of calling: This interface can be called only after the flow is successfully created.

Restrictions on use: None

The localStream to be replaced must be obtained by calling the createStream method of the SDK.

Scope of influence: None

Related interface: removeTrack

Deprecated
Deprecated since 3.0.0, please refer to Upgrade guide v3.0.0+.

removeTrack

removeTrack
deprecated
removeTrack(localStream: MediaStream, track: MediaStreamTrack): Promise<ZegoServerResponse>
Remove video track from media stream.

Parameters

NameTypeDescription
localStreamMediaStreamStream created by stream.
trackMediaStreamTrackVideo track.

Details

Supported version: 2.22.0

Detailed description: Remove video track from media stream.

Timing of calling: This interface can be called only after the flow is successfully created.

The localStream to be replaced must be obtained by calling the createStream method of the SDK.

Related interface: addTrack

Deprecated
Deprecated since 3.0.0, please refer to Upgrade guide v3.0.0+.

setCaptureVolume

setCaptureVolume
setCaptureVolume(localStream: MediaStream | ZegoLocalStream, volume: number): Promise<ZegoServerResponse>
After the stream is created, the volume can be adjusted through this interface

Parameters

NameTypeDescription
localStreamMediaStream | ZegoLocalStreamThe mediaStream or ZegoLocalStream instance object whose volume needs to be modified
volumenumberVolume size, 0-100
  • Default value: None
  • When to call: After the flow is successfully created.

Restrictions on use: None

This interface can only be called after the stream is successfully created. After mixing, it is only valid for the collected audio tracks. Please use the setMixingAudioVolume interface to adjust the volume of the mixing part.

Scope of influence: None

  • Related callbacks: None

Related interface: None

  • Platform differences: None

setDummyCaptureImagePath

setDummyCaptureImagePath
setDummyCaptureImagePath(filePath: string, localStream: MediaStream | ZegoLocalStream): Promise<boolean>
Set the path of the still picture to be pushed off

Parameters

NameTypeDescription
filePathstringPicture path
localStreamMediaStream | ZegoLocalStreamThe stream object that needs to send pictures when the stream or ZegoLocalStream instance object is closed
  • When to call: After the flow is successfully created.
  • Caution: This API can only be called after the stream is created successfully. The higher the static image resolution, the more performance is consumed. Therefore, it is recommended to select the required image size according to the required streaming resolution.

setStreamExtraInfo

setStreamExtraInfo
setStreamExtraInfo(streamID: string, extraInfo: string): Promise<ZegoServerResponse>
Set additional information for the stream

Parameters

NameTypeDescription
streamIDstringStream ID
extraInfostringStream additional information; extraInfo is a json format string
  • Default value: None

Timing of calling: after successful push.

Restrictions on use: None

Only strings are supported.

Scope of influence: None

  • Related callbacks: Users who log in to the room for the first time can obtain additional stream information through roomStreamUpdate, and users who have already pulled streams in the room can obtain updated stream additional information through the stream additional information update callback streamExtraInfoUpdate.

Related interface: None

  • Platform differences: None

enableVideoCaptureDevice

enableVideoCaptureDevice
enableVideoCaptureDevice(localStream: MediaStream | ZegoLocalStream, enable?: boolean): Promise<boolean>
Turn on/off the video capture device.

Parameters

NameTypeDescription
localStreamMediaStream | ZegoLocalStreamCreate the camera media stream obtained by the stream or ZegoLocalStream instance object created.
enablebooleanIdentifies start or stop collection; true means start collection; false means stop collection; the default is true.
  • When to call: after the stream is created successfully.
  • Caution:
  1. The premise of opening/closing the streaming screen is that the media stream must be a camera stream.
  2. If the track is replaced through the [replaceTrack] or [addTrack] interface, it is not supported to call this interface to stop the camera capture, and you can call the [MediaStreamTrack.stop] method to stop the camera capture.

Usage restrictions: Closing or opening the camera on hardware is a time-consuming operation, and there is a certain performance overhead when users operate frequently. It is generally recommended to use [mutePublishStreamVideo].

  • Related callbacks: Calling the stop camera interface will trigger the camera status callback [remoteCameraStatusUpdate] of the corresponding stream on the streaming end.
  • Related APIs: Turn on/off the sending stream video data interface [mutePublishStreamVideo] The response is faster and does not affect the video capture state.

Return

Promise returns a boolean indicating whether the call was successful.

addPublishCdnUrl

addPublishCdnUrl
addPublishCdnUrl(streamID: string, targetURL: string): Promise<ZegoServerResponse>
Notify the instant server to forward the stream to the CDN

Parameters

NameTypeDescription
streamIDstringStream ID
targetURLstringCDN retweet address, the supported retweet address format is rtmp
  • Default value: None

Timing of calling: after successful push.

Restrictions on use: None

It is recommended to use the server-side dynamic retweet CDN to add the retweet CDN address API instead of the client API. This interface call may fail. If it returns a success, it only means that the instant server is notified of success, and it cannot be judged whether the instant server retweets the CDN successfully.

Scope of influence: None

  • Related callbacks: None

Related interface: Notify the instant server to stop forwarding the stream to CDN removePublishCdnUrl.

  • Platform differences: None

removePublishCdnUrl

removePublishCdnUrl
removePublishCdnUrl(streamID: string, targetURL: string): Promise<ZegoServerResponse>
Notify the instant server to stop forwarding the stream to the CDN

Parameters

NameTypeDescription
streamIDstringStream ID
targetURLstringCDN retweet address, the supported retweet address format is rtmp
  • Default value: None
  • When to call: After the retweet is successful

Restrictions on use: None

It is recommended to use the server-side dynamic retweet CDN to add the retweet CDN address API instead of the client API. This interface call may fail. If it returns a success, it only means that the instant server is notified of success, and it cannot be judged whether the instant server retweets the CDN successfully.

Scope of influence: None

  • Related callbacks: None

Related interface: notify the instant server to push the stream to CDN addPublishCdnUrl.

  • Platform differences: None

mutePublishStreamVideo

mutePublishStreamVideo
mutePublishStreamVideo(localStream: MediaStream | ZegoLocalStream, mute: boolean, retain?: boolean): boolean
Close/open the streaming screen being pushed

Parameters

NameTypeDescription
localStreamMediaStream | ZegoLocalStreamThe stream created by createStream or the ZegoLocalStream instance object created by createZegoStream.
mutebooleanWhether to stop sending the video stream; true means not sending the video stream; false means sending the video stream; the default is true.
retainbooleanWhether to keep the preview screen, boolean value. true to keep, false not to keep, the default is false.
  • When to call: After the flow is successfully created.

    The prerequisite for opening/closing the stream screen is that the original stream must have a video track, and the stream cannot be pure audio when it is created.

  • Related callbacks: pull streaming camera status callback remoteCameraStatusUpdate.

Related interface: Turn on/off the streaming sound mutePublishStreamAudio that is being pushed.

Return

Identifies whether the push screen is successfully closed

mutePublishStreamAudio

mutePublishStreamAudio
mutePublishStreamAudio(localStream: MediaStream, mute: boolean): boolean
Turn on/off the streaming sound that is being pushed, including the sound of the microphone and mixed background music

Parameters

NameTypeDescription
localStreamMediaStreamCreate stream obtained stream
mutebooleanWhether to stop sending audio streams; true means not sending audio streams; false means sending video streams; the default is true.
  • When to call: After the flow is successfully created.
  1. The premise of turning on/off streaming sound is that the original stream must have an audio track, and it cannot be pure video when creating the stream.
  2. This interface will turn off all streaming sounds, including microphones, mixed-stream background music and other sounds, while muteMicrophone will only turn off the microphone sounds.
  • Related callbacks: pull streaming microphone status callback remoteMicStatusUpdate.

Related interface: Close/open the streaming video mutePublishStreamVideo that is being pushed; close/open the microphone sound interface muteMicrophone.

setEffectsBeauty

setEffectsBeauty
setEffectsBeauty(localStream: MediaStream | ZegoLocalStream, enable: boolean, options?: ZegoEffectsBeautyParam): Promise<ZegoServerResponse>
Turn beauty effect on or off

Parameters

NameTypeDescription
localStreamMediaStream | ZegoLocalStreamThe stream created by createStream or the ZegoLocalStream instance object created by createZegoStream.
enablebooleanWhether to enable beauty, true means on, false means off.
optionsZegoEffectsBeautyParamBeauty options, including smoothIntensity (smoothing), whitenIntensity (whitening), rosyIntensity (rosy), sharpenIntensity (sharpening) four parameters, can be used to achieve beauty effects. The four intensity parameters range from 0 to 100, and the default value is 50. The options parameter is not required.

Details

You can switch the beautification and adjust the beautification parameters through this interface to achieve a natural beautification effect.

  • Use cases: Portrait beautify on the camera screen.
  • When to call: After calling the interface createStream or createZegoStream to obtain the media stream.
  • Caution: 1. The beauty effect is bound to the corresponding MediaStream, and the beauty effect of the active stream will not be changed when useVideoDevice and replaceTrack are called.
  1. The beautification process takes up resources and consumes performance. When you do not need to use the beautification, you need to call setEffectsBeauty(localStream,false) to close it in time.
  2. When calling destroyStream to destroy the stream, the SDK will close the beautifying effect. In other cases, the SDK will not actively close the beautifying process, and you need to call setEffectsBeauty(localStream,false) to close it.
  3. The browser of the mobile device does not support enabling beauty.
  4. Function setEffectsBeauty is asynchronous. You cannot start streaming during the opening process. If you need to enable beauty before publishing stream, you need to wait for the beauty interface to complete asynchronously before calling the startPublishingStream interface.
  • Related callbacks: none.
  • Available since: 2.13.0

setLowlightEnhancement

setLowlightEnhancement
setLowlightEnhancement(localStream: MediaStream | ZegoLocalStream, mode: ZegoLowlightEnhancementMode): Promise<ZegoServerResponse>
Set low light enhancement.

Parameters

NameTypeDescription
localStreamMediaStream | ZegoLocalStreamThe stream created by createStream or the ZegoLocalStream instance object created by createZegoStream.
modeZegoLowlightEnhancementModeLow light enhanced mode.

Details

According to the set low-light enhancement mode, the brightness of the image captured by the camera is enhanced, which is compatible with the beauty function. Users can watch the effect while previewing and toggle the low-light enhancement mode in real time.

  • Use cases: The environment on the streaming end is dark, or the frame rate set by the camera is high, which causes the picture to be dark, and the subject cannot be displayed or recognized normally.
  • Default value: close.
  • When to call: After calling createstream or createZegoStream to create the preview stream.
  • Caution: The interface compatibility is the same as setEffectsBeauty, but not compatible with mobile browsers.
  • Available since: 2.18.0

enableDualStream

enableDualStream
enableDualStream(localStream: MediaStream | ZegoLocalStream): void
enable dual stream

Parameters

NameTypeDescription
localStreamMediaStream | ZegoLocalStreamThe stream created by createStream or the ZegoLocalStream instance object created by createZegoStream.

Details

supported version: 2.18.0 and above.

detailed description: you can switch the size flow through this interface.

business scenario: Different terminals are required to display video streams of different quality or to maintain a smooth connection to the microphone in a poor network environment.

call timing: after successfully calling the create stream interface, before pushing the stream interface.

precautions: none.

related callback: none.

setLowStreamParameter

setLowStreamParameter
setLowStreamParameter(localStream: MediaStream | ZegoLocalStream, param: { width: number; height: number; frameRate: number; bitRate: number }): void
set low stream parameter

Parameters

NameTypeDescription
localStreamMediaStream | ZegoLocalStreamThe stream created by createStream or the ZegoLocalStream instance object created by createZegoStream.
param{ width: number; height: number; frameRate: number; bitRate: number }low stream parameters, resolution, frame rate and bitrate.

Details

supported version: 2.18.0 and above.

detailed description: you can set small flow parameters through this interface.

business scenario: Different terminals are required to display video streams of different quality or to maintain a smooth connection to the microphone in a poor network environment.

call timing: after successfully calling the create stream interface, before pushing the stream interface.

precautions: None.

related callback: none.

enableHardwareEncoder

enableHardwareEncoder
enableHardwareEncoder(enable: boolean): void
On/off hardware encoding.

Parameters

NameTypeDescription
enablebooleanWhether to enable hardware coding; true means enable hard coding; false means turn off hard coding; the default is false.
  • When to call: The settings can only take effect before pushing the stream. If the settings are set after the stream is pushed, it can take effect when the stream is restarted after the push is stopped.
  • Caution: Since the hard-coding support of a small number of devices is not particularly good, the SDK uses the software coding method by default. If the developer finds that the device heats up when the audio and video streams are pushed to a larger resolution when testing some models, consider calling this function to enable hard coding.

enableAutoSwitchDevice

enableAutoSwitchDevice
enableAutoSwitchDevice(config: ZegoAutoSwitchDeviceConfig): void
Turn on or off automatic switching of related devices

Parameters

NameTypeDescription
configZegoAutoSwitchDeviceConfigRelated configuration of device automatic switching

Details

Pass in the relevant configuration to enable or disable the automatic switching of related devices. After the device is unplugged, it supports automatic switching of other available devices currently in use. The SDK disables automatic device switching by default.

  • Use cases: After the SDK is created and initialized, the compatible operation of device plugging and unplugging.
  • Available since: 2.20.0 and above.

initBackgroundModule

initBackgroundModule
initBackgroundModule(segmentation: Segmentation, assetsURL: string): Promise<ZegoServerResponse>
Initialize the background processing module.

Parameters

NameTypeDescription
segmentationSegmentationbackground segmentation mode.
assetsURLstringresource file path.

Details

Initialize the background processing module.

  • Use cases: Replace the real background with a custom image.
  • Default value: None.
  • When to call /Trigger: After new ZegoExpressEngine.
  1. Currently only supports the use of the PC terminal, the mobile terminal is not currently supported.
  • Available since: 2.24.0

setBackgroundBlurOptions

setBackgroundBlurOptions
setBackgroundBlurOptions(localStream: MediaStream | ZegoLocalStream, options: BackgroundBlurOptions): Promise<boolean>
Set parameters for background blur of the stream.

Parameters

NameTypeDescription
localStreamMediaStream | ZegoLocalStreamThe stream created by createStream or the ZegoLocalStream instance object created by createZegoStream.
optionsBackgroundBlurOptionsParameters for background blur processing.

Details

Set parameters for background blur of the stream.

  • Use cases: Blur the real scene around the user.
  • Default value: None
  • When to call /Trigger: After calling the interface the initBackgroundModule successfully and calling the interface createStream or createZegoStream to create a stream successfully.
  1. Currently only supports the use of the PC terminal, the mobile terminal is not currently supported;
  • Available since: 2.24.0

setVirtualBackgroundOptions

setVirtualBackgroundOptions
setVirtualBackgroundOptions(localStream: MediaStream | ZegoLocalStream, options: BackgroundVirtualOptions): Promise<boolean>
Set virtual background related processing parameters.

Parameters

NameTypeDescription
localStreamMediaStream | ZegoLocalStreamThe stream created by createStream or the ZegoLocalStream instance object created by createZegoStream.
optionsBackgroundVirtualOptionsparameters for virtual background processing.

Details

Set parameters for virtual background processing

  • Use cases: Process virtual background for streaming
  • Default value: None
  • When to call /Trigger: After calling the interface initBackgroundModule and calling the interface createStream to create a stream successfully.
  1. Currently only supports the use of the PC terminal, the mobile terminal is not currently supported;
  2. Before use, you need to call the ZegoExpressEngine.use method to import the virtual background module.
  • Available since: 2.24.0

setTransparentBackgroundOptions

setTransparentBackgroundOptions
setTransparentBackgroundOptions(localStream: MediaStream): Promise<boolean>
Set transparent background related processing parameters.

Parameters

NameTypeDescription
localStreamMediaStreammedia stream.

Details

Set parameters for transparent background processing

  • Use cases: Process transparent background for streaming
  • Default value: None
  • When to call /Trigger: After calling the interface initBackgroundModule and calling the interface createStream or createZegoStream to create a stream successfully.
  1. Currently only supports the use of the PC terminal, the mobile terminal is not currently supported;
  2. Before use, you need to call the ZegoExpressEngine.use method to import the virtual background module.
  • Available since: 2.24.0

enableBackgroundProcess

enableBackgroundProcess
enableBackgroundProcess(localStream: MediaStream | ZegoLocalStream, enable: boolean, segmentation: Segmentation): Promise<ZegoServerResponse>
Turn on background processing.

Parameters

NameTypeDescription
localStreamMediaStream | ZegoLocalStreamThe stream created by createStream or the ZegoLocalStream instance object created by createZegoStream.
enablebooleanturn background processing on or off.
segmentationSegmentationbackground segmentation mode.

Details

Perform background processing on stream.

  • Use cases: Perform background processing on the pushed stream.
  • Default value: None
  • When to call /Trigger: When to call /Trigger: After calling the interface createStream or createZegoStream to create a stream successfully.
  1. Currently only supports the use of the PC terminal, the mobile terminal is not currently supported;
  • Available since: 2.24.0

setVoiceChangerParam

setVoiceChangerParam
setVoiceChangerParam(localStream: MediaStream | ZegoLocalStream, voiceParam: number): Promise<ZegoServerResponse>
Sound modification processing.

Parameters

NameTypeDescription
localStreamMediaStream | ZegoLocalStreamThe stream created by createStream or the ZegoLocalStream instance object created by createZegoStream.
voiceParamnumberThe pitch parameter voiceParam has a value range of [-12.0, 12.0]. The larger the value, the sharper the sound. Setting it to 0.0 will turn off the voice changer.

Details

Customize the voice changing effect through parameter settings.

  • Use cases: Switch voice changer reduction before or during streaming.
  • Default value: None
  • When to call /Trigger: After calling the interface createStream or createZegoStream to create a stream successfully.
  1. Currently only supports voice changer reduction for a specific stream, and does not support simultaneous noise reduction for multiple streams; 2.The pitch parameter voiceParam has a value range of [-12.0, 12.0]. The larger the value, the sharper the sound. Setting it to 0.0 will turn off the voice changer.
  • Available since: 2.23.0

setVoiceChangerPreset

setVoiceChangerPreset
setVoiceChangerPreset(preset: ZegoVoiceChangerPreset, localStream: MediaStream | ZegoLocalStream): Promise<ZegoServerResponse>
Sound modification processing.

Parameters

NameTypeDescription
presetZegoVoiceChangerPresetPreset value for changing sound.
localStreamMediaStream | ZegoLocalStreamThe stream created by createStream or the ZegoLocalStream instance object created by createZegoStream.

Details

Perform voice changer reduction processing on the pushed media stream.

  • Use cases: Switch voice changer reduction before or during streaming.
  • Default value: None
  • When to call /Trigger: After calling the interface createStream or createZegoStream to create a stream successfully.
  1. Currently only supports voice changer reduction for a specific stream, and does not support simultaneous noise reduction for multiple streams;
  • Available since: 2.23.0

setReverbPreset

setReverbPreset
setReverbPreset(localStream: MediaStream | ZegoLocalStream, preset: ZegoReverbPreset): Promise<ZegoServerResponse>
Set reverb via preset enum.

Parameters

NameTypeDescription
localStreamMediaStream | ZegoLocalStreamMedia streams or ZegoLocalStream instance object created by createZegoStream that require reverb processing.
presetZegoReverbPresetReverb preset enumeration value.

Details

You can set the preset reverb effect by calling this function.

  • Use cases: It is often used in live broadcast, chat room and KTV and other scenarios.
  • Default value: None
  • When to call /Trigger: After calling the interface createStream or createZegoStream to create a stream successfully.
  1. Currently, only one specific stream is supported for audio mixing, and simultaneous reverberation for multiple streams is not supported.
  2. The effect of using this function and [setVoiceChangerPreset] at the same time may be different from the expected effect. If you need to use it at the same time, it is recommended to enable the voice changer first, and then enable the reverberation.
  • Available since: 3.0.0

enableVirtualStereo

enableVirtualStereo
enableVirtualStereo(localStream: MediaStream | ZegoLocalStream, enable: boolean, angle: number): Promise<ZegoServerResponse>
Enable or disable the virtual stereo effect when streaming.

Parameters

NameTypeDescription
localStreamMediaStream | ZegoLocalStreamMedia streams or ZegoLocalStream instance object created by createZegoStream that require reverb processing.
enablebooleantrue means to enable virtual stereo, and false means to disable virtual stereo.
anglenumberThe angle of the sound source in the virtual stereo, the range is -1 ~ 360, 90 is the front, 0 / 180 / 270 correspond to the rightmost / leftmost / directly behind respectively; especially, when setting -1, it is a full-scale virtual stereo effect.

Details

You can turn on/off the virtual stereo effect when streaming by calling this function.

  • Use cases: It is often used in live broadcast, chat room and KTV and other scenarios.
  • Default value: None
  • When to call: After calling the interface createStream or createZegoStream to create a stream successfully.
  1. Currently, only one specific stream is supported for audio mixing, and simultaneous reverberation for multiple streams is not supported.
  2. It is necessary to call [createStream] or [createZegoStream] to set the parameters of the two-channel virtual stereo to take effect.
  3. The effects of the virtual stereo and reverb functions conflict, and the effects may not meet expectations, so do not use them in combination.
  4. The virtual stereo function is not supported on Mac Safari and mobile device browsers.
  • Available since: 3.0.0

enableAiDenoise

enableAiDenoise
enableAiDenoise(localStream: MediaStream | ZegoLocalStream, enable: boolean): Promise<ZegoServerResponse>
Incoming media stream, turn AI noise reduction on or off

Parameters

NameTypeDescription
localStreamMediaStream | ZegoLocalStreamAI noise reduction incoming media stream the ZegoLocalStream instance object created by createZegoStream
enablebooleanTurn on/off AI noise reduction

Details

Perform AI noise reduction processing on the pushed media stream.

  • Use cases: Switch AI noise reduction before or during streaming.
  • Default value: None
  • When to call /Trigger: After calling the interface createStream or createZegoStream to create a stream successfully.
  1. Currently using the AI noise reduction function requires a special editing package for technical support;
  2. Currently only supports the use of the PC terminal, the mobile terminal is not currently supported;
  3. Currently only supports AI noise reduction for a specific stream, and does not support simultaneous noise reduction for multiple streams;
  • Available since: 2.19.0

setAiDenoiseMode

setAiDenoiseMode
setAiDenoiseMode(localStream: MediaStream | ZegoLocalStream, mode: AiDenoiseMode): Promise<ZegoServerResponse>
Incoming media stream, turn AI noise reduction on or off

Parameters

NameTypeDescription
localStreamMediaStream | ZegoLocalStreamAI noise reduction incoming media stream the ZegoLocalStream instance object created by createZegoStream
modeAiDenoiseModethe ai denoise mode

Details

Perform AI noise reduction processing on the pushed media stream.

  • Use cases: Switch AI noise reduction before or during streaming.
  • Default value: None
  • When to call /Trigger: After calling the interface createStream or createZegoStream to create a stream successfully.
  1. Currently using the [setAiDenoiseMode] requires a special editing package for technical support;
  2. Currently only supports the use of the PC terminal, the mobile terminal is not currently supported;
  • Available since: 3.3.0

setStreamAlignmentProperty

setStreamAlignmentProperty
setStreamAlignmentProperty(streamID: string, alignment: number): Promise<boolean>
Turn on or off the mixed flow precise alignment function.

Parameters

NameTypeDescription
streamIDstringThe streamID of the push stream.
alignmentnumberWhether to enable alignment, 0 is off, 1 is on.
  • Default value: If this interface is not adjusted, the default is not aligned.
  • When to call: After the push is successful.

Related interface: Start the mixing interface startMixerTask. After the mixing task turns on the precise alignment function, the aligned streams will be aligned.

Return

Asynchronously returns a Boolean value to identify whether the call is successful.

startPlayingStream

startPlayingStream
startPlayingStream(streamID: string, playOption?: ZegoWebPlayOption): Promise<MediaStream>
Start playing stream

Parameters

NameTypeDescription
streamIDstringStream ID, required.
playOptionZegoWebPlayOptionPull flow additional parameters, optional.

Details

Supported version: 1.0.0 and above.

Detailed description: call the streaming interface to obtain the streaming address.

Business scenario: Required when pulling streams.

Calling time: after receiving the new pull stream, that is, after the roomStreamUpdate callback.

  1. Before pulling the stream, make sure that the stream has been successfully pushed (pushed to the ZEGO server), that is, the stream is pulled after the roomStreamUpdate callback.

Related Tonance: Padd Quality Pick-up PlayqualityUpdate, drawing Status Tune PlayerstateUpdate (can be judged by this callback to determine if the draw is successful).

Related interface: Call the interface [stopPlayingStream] to stop.

Return

Promise returns the streaming media object asynchronously.

stopPlayingStream

stopPlayingStream
stopPlayingStream(streamID: string): void
Stop pulling remote streams (Zego server)

Parameters

NameTypeDescription
streamIDstringStream ID,Required
  • Default value: None

Timing of calling: After the stream is successfully pulled.

Restrictions on use: None

The player will not be destroyed after the streaming is stopped, and the player must be destroyed by the developer.

Scope of influence: None

  • Related callbacks: pull stream quality callback playQualityUpdate, pull stream state callback playerStateUpdate.

Related interface: start streaming startPlayingStream.

  • Platform differences: None

mutePlayStreamVideo

mutePlayStreamVideo
mutePlayStreamVideo(streamID: string, mute: boolean): Promise<boolean>
Stop or resume pulling video stream

Parameters

NameTypeDescription
streamIDstringstream ID
mutebooleanWhether to pull the video stream, true means stop drawing; false means resume drawing
  • Default value: None

Timing of calling: After the stream is successfully pulled.

Restrictions on use: None

  1. The premise of stopping or resuming the video stream is that the original stream must have a video track, and the stream cannot be pure audio.
  2. It is only valid for RTC streams or L3 streams, and cannot operate CDN pull streams.

Scope of influence: None

  • Related callbacks: None

Related interface: Stop or resume pulling the audio stream mutePlayStreamAudio.

  • Platform differences: None

setAudioFrameCallback

setAudioFrameCallback
setAudioFrameCallback(streamID: string, callback: ((audioData:ZegoAudioFrame)=>void) | null, options?: AudioFrameOptions): Promise<ZegoServerResponse>
Set the callback for streaming raw audio data.

Parameters

NameTypeDescription
streamIDstringstream ID
callback((audioData:ZegoAudioFrame)=>void) | nullThe callback function that receives audio data. If set to null, the audio data will no longer be called back.
options?AudioFrameOptionsThe option of callback function that receives audio data
  • Default value: None

Timing of calling: After the stream is pulled successfully or the stream is collected successfully.

Restrictions on use: None

  1. The stream has an audio.
  2. It is only valid for RTC streams or L3 streams, and cannot operate CDN pull streams.
  3. Chrome browser support 85 above.
  4. Due to browser limitations, data callbacks are only available after interaction with the page.

Scope of influence: None

  • Related callbacks: None

Related interface: None

  • Platform differences: None

setPlayStreamVideoType

setPlayStreamVideoType
setPlayStreamVideoType(streamID: string, streamType: number): Promise<boolean>
Set the play video stream type

Parameters

NameTypeDescription
streamIDstringstream ID
streamTypenumberplay stream type, 0 is small flow, 1 is large flow, 2 is automatic
  • Default value: None

Timing of calling: After the stream is successfully pulled.

Restrictions on use: None

None

Scope of influence: None

  • Related callbacks: None

Related interface: None

  • Platform differences: None

muteAllPlayAudioStreams

muteAllPlayAudioStreams
muteAllPlayAudioStreams(mute: boolean): Promise<boolean>
Whether the pull stream receives all audio data (including newly pulled streams in the room later)

Parameters

NameTypeDescription
mutebooleanStop or resume pulling all audio streams, true means stop pulling; false means resume pulling.

Details

Supported version: 3.3.0

Detailed description: During the real-time audio and video interaction process, local users can use this function to control whether to receive the audio data of all remote users when pulling streams (including those pushed by users who newly join the room after calling this function). audio stream). By default, users can receive audio data pushed by all remote users after joining the room. This reduces hardware and network overhead when developers do not receive audio receipts.

Business scenario: When developers need to quickly close and restore remote audio, they can call this function. Compared with re-pulling streams, it can greatly reduce time consumption and improve interactive experience.

Timing of calling: After initializing the engine.

Related interface: You can call the [mutePlayStreamAudio] function to control whether to receive a single piece of audio data.

muteAllPlayVideoStreams

muteAllPlayVideoStreams
muteAllPlayVideoStreams(mute: boolean): Promise<boolean>
Whether the pull stream receives all audio data (including newly pulled streams in the room later)

Parameters

NameTypeDescription
mutebooleanStop or resume pulling all video streams, true means stop pulling; false means resume pulling.

Details

Supported version: 3.3.0

Detailed description: During the real-time audio and video interaction process, the local user can use this function to control whether to receive the video data of all remote users when pulling the stream (including those pushed by users who newly join the room after calling this function). video streaming). By default, users can receive video data pushed by all remote users after joining the room. Reduces hardware and network overhead when developers do not receive video receipts.

Business scenario: When developers need to quickly close and restore remote video, they can call this function. Compared with re-pulling streams, it can greatly reduce time consumption and improve interactive experience.

Timing of calling: After initializing the engine.

Related interface: You can call the [mutePlayStreamVideo] function to control whether to receive a single piece of video data.

mutePlayStreamAudio

mutePlayStreamAudio
mutePlayStreamAudio(streamID: string, mute: boolean): Promise<boolean>
Stop or resume pulling audio streams

Parameters

NameTypeDescription
streamIDstringstream ID
mutebooleanWhether to pull the audio stream, true means stop drawing; false means resume drawing
  • Default value: None

Timing of calling: After the stream is successfully pulled.

Restrictions on use: None

  1. The prerequisite for stopping or resuming the audio stream is that the original stream must have an audio track, and the stream cannot be pure video.
  2. It is only valid for RTC streams or L3 streams, and cannot operate CDN pull streams.

Scope of influence: None

  • Related callbacks: None

Related interface: Stop or resume pulling the video stream mutePlayStreamVideo.

  • Platform differences: None

getPlayingStreamQuality

getPlayingStreamQuality
getPlayingStreamQuality(streamID: string): ZegoPlayStats | null
Get the playing stream quality.

Parameters

NameTypeDescription
streamIDstringID of stream.

Details

Actively obtain the stream quality that is being playing.

  • Use cases: Obtain the quality parameters such as the resolution, frame rate, and bit rate of the current playing stream.
  • When to call: [startPlayingStream] After the push stream is successful.
  • Related APIs: Pull streaming quality callback [playQualityUpdate].
  • Available since: 2.15.0
  • Restrictions: Since the streaming quality parameters of the SDK are updated every 3 seconds, it is recommended that the calling interval of this interface should not be less than 3 seconds.

Return

Playing stream quality information, if the acquisition fails, it will return null.

createLocalStreamView

createLocalStreamView
deprecated
createLocalStreamView(localStream: MediaStream): ZegoStreamView
Create a local media stream player component instance object.

Parameters

NameTypeDescription
localStreamMediaStreamLocal media stream, obtained through the createStream interface.

Details

Creates an instance object of the Media Stream Player component for playing the preview stream.

  • Use cases: You need to play media streaming images such as camera and screen sharing on the interface.
  • When to call /Trigger: You need to call the interface createstream to obtain the media stream object as an input parameter.
  • Caution: Only one instance object of the media stream player component can be created corresponding to each media stream object.
  • Available since: 2.17.0
Deprecated
Deprecated since 3.0.0, please refer to Upgrade guide v3.0.0+.

Return

The media stream player component instance.

createRemoteStreamView

createRemoteStreamView
createRemoteStreamView(remoteStream: MediaStream): ZegoStreamView
Create a remote media stream player component instance object.

Parameters

NameTypeDescription
remoteStreamMediaStreamThe remote media stream, obtained through the [startPlayingStream] interface.

Details

Create a media stream player component instance object for playing the pull stream.

  • Use cases: The pulled remote media streaming screen needs to be displayed on the page.
  • When to call /Trigger: You need to call the interface [startPlayingStream] to get the media stream object as an input parameter.
  • Caution: Only one instance object of the media stream player component can be created corresponding to each media stream object.
  • Available since: 2.17.0

Return

The media stream player component instance.

startAutoMixerTask

startAutoMixerTask
startAutoMixerTask(task: ZegoAutoMixerTask): Promise<ZegoServerResponse>
Start auto mixer task

Parameters

NameTypeDescription
taskZegoAutoMixerTaskAutomatic mixed flow task object.

Details

Local users can call this function to start the automatic mixing task to mix all streams in the room. Currently, only audio streams are automatically mixed. After starting the automatic mixing, the audio of all streams in the room will be automatically mixed, and the push streams initiated in this room will also be automatically mixed into the final output stream.

  • Use cases: It is often used in voice chat room scenarios when the client needs to initiate an automatic streaming task.
  • When to call: After creating the engine, if the target room has been created, you can call this function to start automatic streaming in the target room.
  • Caution: Before starting the next automatic stream mixing task in the same room, please call the [stopAutoMixerTask] function to end the previous automatic stream mixing task first, so as to avoid the situation where the audience is still pulling the output stream of the previous automatic stream mixing task when a host has started the next automatic stream mixing task to mix with other hosts. If the user does not actively end the current automatic stream mixing task, the task will automatically end after the room no longer exists or the input stream does not exist for 90 seconds.

Security 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 APIs: You can call the [stopAutoMixerTask] function to stop the automatic stream mixing task.
  • Available since: 3.5.0 and above.

startMixerTask

startMixerTask
startMixerTask(mixStreamConfig: ZegoMixStreamConfig): Promise<ZegoServerResponse>
Start mixer task

Parameters

NameTypeDescription
mixStreamConfigZegoMixStreamConfigMixed flow parameter configuration

Details

Combine multiple streams into one stream according to the calling requirements. Since the actual action is operated on the server side, there is no restriction on browser performance, and the delay between each stream is low, which can ensure the synchronization of the pictures and sounds of multiple streams being mixed.

  • Use cases: It is usually used in the scenario where multiple anchors are connected to the PK. The audio and video streams of multiple anchors are mixed into one stream, and the audience only needs to pull this stream.
  • When to call: After calling the interface startPublishingStream to publish the streams successfully.
  • Caution: The corresponding AppID enables the muxing function; the mixed stream must exist on the ZEGO server.

Security 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 APIs: Use the interface stopMixerTask to stop server-side mixing. Failure to stop the mixing function in time will affect billing.
  • Available since: 1.5.2 and above.
  • Restrictions: Before mixing, you need to ensure that the stream still exists, and avoid triggering the muxing and stream deletion operations at the same time, so as to avoid the muxing failure. if the muxing stream stops pushing the stream, you need to perform the muxing process again, otherwise the peer screen will be stuck.

stopAutoMixerTask

stopAutoMixerTask
stopAutoMixerTask(task : { taskID: string; roomID: string; }): Promise<ZegoServerResponse>
Stop server-side mixer task

Parameters

NameTypeDescription
task{ taskID: string; roomID: string; }The taskID of the task corresponding to the stop mixing task and the roomID of the room.

Details

Local users can call this function to end the automatic stream mixing task.

  • Use cases: It is often used in voice chat room scenarios when the client needs to initiate an automatic streaming task.
  • When to call: After calling the interface startAutoMixerTask and mixing successfully.

Security 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 APIs: startAutoMixerTask
  • Available since: 3.5.0 and above.

stopMixerTask

stopMixerTask
stopMixerTask(taskID: string): Promise<ZegoServerResponse>
Stop server-side mixer task

Parameters

NameTypeDescription
taskIDstringMixed-flow task ID (customized by the customer, must be unique), required, the maximum length is 256 characters, only supports numbers, English characters and'~','!','@','#','$', '','^','&','*','(',')','_','+','=','-',',';',''', ' ,','

Details

used to stop the server-side mixed-flow task corresponding to taskID.

  • Use cases: It is usually used in the scenario where multiple anchors are connected to the microphone PK, and the muxing is stopped after the use of the muxing screen is finished.
  • When to call: After calling the interface startMixerTask and mixing successfully.
  • Caution: You must initiate a stop muxing when you close the page, to avoid abnormally closing the muxing without stopping, which will affect the billing; if the muxing stream stops pushing, you need to do the muxing process again, otherwise the peer screen will be stuck.

Security 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 APIs: startMixerTask
  • Available since: 1.5.2 and above.

setMixerTaskConfig

setMixerTaskConfig
setMixerTaskConfig(config: ZegoMixStreamAdvance): Promise<ZegoServerResponse>
Mixed flow advanced configuration

Parameters

NameTypeDescription
configZegoMixStreamAdvanceMixed flow advanced function settings.

Details

Advanced settings for muxing function, you can set the video background and video encoding format.

  • Use cases: 1. Set the background of mixed flow picture; 2. Video coding conversion to be compatible with the playback of some browsers.
  • When to call: It must be called before startMixerTask is used to take effect and stream is successfully published.

Security 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 APIs: startMixerTask
  • Available since: 1.5.2 and above.

startMixingAudio

startMixingAudio
startMixingAudio(streamID: string | MediaStream | ZegoLocalStream, mediaList: Array<HTMLMediaElement>): boolean
Start Mixing Audio

Parameters

NameTypeDescription
streamIDstring | MediaStream | ZegoLocalStreamThe stream ID or MediaStream object or ZegoLocalStream instance object that needs to be mixed.
mediaListArray<HTMLMediaElement>1. Local array of <audio> or <video> objects.
2. The operation of the sound effect (including pause/resume) needs to be completed by operating the <audio> or <video> object.

Details

Mix the sound being played by the HTMLMediaElement object into the push stream corresponding to the streamID, that makes the stream being published contain mixed sound.

  • Use cases: usually used for background music and sound effects.
  • When to call: After calling the interface createStream or createZegoStream to create a stream successfully. 2.15.0 and earlier versions can call this interface only after the stream is pushed successfully.
  • Caution: - You need to make sure that the HTMLMediaElement loads properly. For example, to avoid cross-domain resource load failure, set the property crossOrigin = 'anonymous' on HTMLMediaElement
  • Since version 86 of the Chrome browser, the local audio tag is set to mute, and the mixed background sound cannot be heard on the streaming end.
  • Affected by the Safari browser policy, if the audio tag is set to mute, it will automatically pause after playback and multiple audios cannot be mixed too.

Security 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.

  • Impacts on other APIs: Most interfaces can be called after logging in to the room.
  • Related APIs: You can call the interface stopMixingAudio to stop mixing.
  • Available since: 1.7.0 and above.
  • Restrictions: Do not include more than 6 in the mix, and the length of the mediaList should not be greater than 6, otherwise performance problems will occur and the page will freeze.

stopMixingAudio

stopMixingAudio
stopMixingAudio(streamID: string | MediaStream, mediaList?: Array<HTMLMediaElement>): boolean
Stop mixing audio

Parameters

NameTypeDescription
streamIDstring | MediaStreamThe stream ID or MediaStream object being mixed.
mediaListArray<HTMLMediaElement>1. Local array of <audio> or <video> objects, optional.
2. The operation of the sound effect (including pause/resume) needs to be completed by operating the <audio> or <video> object.

Details

Control the pause of one or more music through the mediaList passed in, and stop all mixing of the stream if this parameter is not passed in.

  • Use cases: Usually used to control the pause of background music and sound effects.
  • When to call: After calling startMixingAudio. After version 2.16.0, the preview stage operation mixing is supported.
  • Caution: It is checked that "customCapture" is false through the capability check interface checkSystemRequirements, that is, the browser does not support obtaining the MediaStream of the media element, and this interface cannot be used.

Security 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.

  • Impacts on other APIs: Most interfaces can be called after logging in to the room.
  • Related APIs: startMixingAudio
  • Available since: 1.7.0 and above.

setMixingAudioVolume

setMixingAudioVolume
setMixingAudioVolume(streamID: string | MediaStream, volume: number, media: HTMLMediaElement): boolean
Set the mixing volume

Parameters

NameTypeDescription
streamIDstring | MediaStreamstream ID or MediaStream object.
volumenumbervolume, the range is 0~100, 100 represents the original volume.
mediaHTMLMediaElementMedia tags < video > or < audio >.

Details

Adjust the mixing volume of the media element through the incoming volume value and media element.

  • Use cases: Usually used to adjust the volume of background music or sound effects.
  • When to call: After calling startMixingAudio. 2.16.0 and later versions support the preview stage to manipulate mixes.
  • Caution: Since version 86 of the Chrome browser, the local audio tag is set to mute, and there is no sound in the mixed audio at playing stream end.

Security 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.

  • Impacts on other APIs: Most interfaces can be called after logging in to the room.
  • Related APIs: startMixingAudio
  • Available since: 1.18.0 and above.

enableLiveAudioEffect

enableLiveAudioEffect
enableLiveAudioEffect(player: HTMLMediaElement, enable: boolean, mode: ZegoLiveAudioEffectMode): Promise<ZegoServerResponse>
Enables or disables the sound enhancement.

Parameters

NameTypeDescription
playerHTMLMediaElementH5 audio or video tag element object.
enablebooleanWhether to enable live sound effects.
modeZegoLiveAudioEffectModeLive sound effect mode.

Details

After turning on the live sound effects, the sense of space is enhanced and the sound of musical instruments is enhanced and prominent.

  • When to call: After initializing a ZegoExpresEngine instance.

Cautions:

  1. In order to enhance the on-site sound experience, we recommend configuring dual channel encoding. Developers can achieve this configuration by setting the parameter [ZegoCaptureMicrophone. channelCount] to 2 when using the [startCaptureMicrophone] interface. If dual channel encoding is not configured, the performance of certain songs may be significantly reduced, as the effects of the left and right channels may cancel out each other when synthesizing a single channel, resulting in less noticeable effects.
  2. This interface can only be effective for one h5 player. When the effect is turned on for a new audio tag, the effect will be turned off for other h5 players that have the effect turned on.
  • Available since: 3.0.0

Return

Return the call result asynchronously.

setAudioChangerParam

setAudioChangerParam
setAudioChangerParam(player: HTMLMediaElement, pitch: number, mode: ZegoLiveAudioEffectMode): Promise<ZegoServerResponse>
The incoming audio is altered.

Parameters

NameTypeDescription
playerHTMLMediaElementH5 audio or video tag element object.
pitchnumberTone value, range [-12.0, 12.0], the higher the value, the sharper the sound. Set 0.0 to turn off the tone processing.
modeZegoLiveAudioEffectModeLive sound effect mode.

Details

It is generally used in chat rooms and karaoke scenes to realize the adjustment of the accompaniment.

  • When to call: After initializing a ZegoExpresEngine instance.

Cautions: If the audio change setAudioChangerParam interface is used at the same time as the enableLiveAudioEffect interface, this interface takes effect for only one h5 player. When the new audio tag is enabled or setAudioChangerParam and enableLiveAudioEffect are passed to different h5 players, the h5 player whose effects are enabled first will be disabled. That is, the setAudioChangerParam and enableLiveAudioEffect cannot take effect on multiple audio devices.

  • Available since: 3.0.0

Return

Return the call result asynchronously.

createAudioEffectPlayer

createAudioEffectPlayer
createAudioEffectPlayer(localStream: MediaStream | ZegoLocalStream): ZegoAudioEffectPlayer
Create a audio effect player instance.

Parameters

NameTypeDescription
localStreamMediaStream | ZegoLocalStreamThe stream created by createStream or the ZegoLocalStream instance object created by createZegoStream.

Details

Create a audio effect player instance.

  • Use cases: When you need to play short sound effects, such as applause, cheers, etc., you can use the sound effect player to achieve.
  • When to call /Trigger: You need to call the interface createstream or createZegoStream to obtain the media stream object as an input parameter.
  • Caution:
  1. Only one valid player instance object can be created corresponding to each media stream object.
  2. In version 2.15.0, you need to complete the push stream before you can operate the player corresponding to the stream. Version 2.16.0 and later supports the audio player that operates the stream before pushing the stream.
  • Available since: 2.15.0

Return

The sound player instance object.

loadAudioEffect

loadAudioEffect
loadAudioEffect(audioEffectID: string, path: string): Promise<string>
Load sound resources.

Parameters

NameTypeDescription
audioEffectIDstringID of the sound resource.
pathstringSpecifies the request path of the online sound effect file. The following audio formats are supported: MP3, AAC, and other audio formats supported by the browser.

Details

Load sound resources.

  • Use cases: In the scenario of frequently playing the same sound effect, the SDK provides the function of preloading the sound effect file into the memory in order to reduce the waste of network and performance resources of repeatedly reading and decoding the file.
  • When to call /Trigger: Callable after [createAudioEffectPlayer].

Related interfaces: Play audio effect interface [ZegoAudioEffectPlayer.start], release audio interface [unloadEffect].

  • Caution:
  1. Online audio files need to comply with the Same-origin policy.
  2. The following audio formats are supported: MP3, AAC and other audio formats supported by the browser.
  • Available since: 2.15.0

Return

Asynchronously returns the sound resource ID.

unloadAudioEffect

unloadAudioEffect
unloadAudioEffect(audioEffectID: string): boolean
Unload the sound resource.

Parameters

NameTypeDescription
audioEffectIDstringID of the sound resource.

Details

Unload the sound resource for the specified sound ID.

  • Use cases: After the sound effect is used up, related resources can be released through this interface.
  • When to call /Trigger: Callable after [loadAudioEffect].

Related interfaces: Load the audio interface [loadAudioEffect] .

  • Caution: none.
  • Available since: 2.15.0

Return

Whether the interface call is successful.

enumDevices

enumDevices
enumDevices(): Promise<ZegoDeviceInfos>
Obtain the device hardware information and provide the device id parameter for operating the hardware device interface.
  • Default value: None
  • When to call: after initialization, before creating a stream.

Restrictions on use: None

  1. This interface needs to be called under the secure domain name (https, localhost, 127.0.0.1).
  2. Before calling this interface, you need to obtain device permissions. You can call checkSystemRequirements("camera") to authorize camera permissions, and call checkSystemRequirements("microphone") to authorize camera permissions.
  3. If the interface cannot be completely trusted, it is necessary to downgrade the situation where the device information cannot be obtained, for example: prompting the customer to change the browser.
  4. Some platform browsers (such as: Safari, iOS) may obtain an empty device name. It is recommended to call this interface again to obtain the correct device name.
  5. After the page is refreshed, the device ID may change and needs to be obtained again.
  6. Some browsers can obtain the device ID only after calling the createStream interface to obtain permission.
  7. safari does not support getting speaker information.

Scope of influence: None

  • Related callbacks: None

Related interfaces: createStream, useAudioDevice, useVideoDevice.

  • Platform differences: None

getCameras

getCameras
getCameras(): Promise<ZegoDeviceInfo[]>
Get the list of camera devices and provide the device id parameter for operating the hardware device interface.
  • Default value: None
  • When to call: after initialization, before creating a stream.

Restrictions on use: None

  1. Due to the browser's security and privacy protection, the page needs to call this interface in a secure environment (https, localhost, 127.0.0.1). See Privacy and security.
  2. If the page device permission is not granted, calling this method will temporarily open the camera to trigger the browser's camera device permission application. On browsers such as Chrome 81+, Firefox, Safari, etc., accurate device information cannot be obtained without media device permissions.

Scope of influence: None

  • Related callbacks: None

Related interfaces: createStream, useVideoDevice, createZegoStream.

  • Platform differences: None

Return camera device list information.

getMicrophones

getMicrophones
getMicrophones(): Promise<ZegoDeviceInfo[]>
Get the list of microphone devices and provide the device id parameter for operating the hardware device interface.
  • Default value: None
  • When to call: after initialization, before creating a stream.

Restrictions on use: None

  1. Due to the browser's security and privacy protection, the page needs to call this interface in a secure environment (https, localhost, 127.0.0.1). See Privacy and security.
  2. If the page device permission is not granted, calling this method will temporarily turn on the microphone to trigger the browser's request for the microphone device permission. On browsers such as Chrome 81+, Firefox, Safari, etc., accurate device information cannot be obtained without media device permissions.
  3. In Windows Chrome, there will be a microphone device whose deviceID is 'communications'. This microphone is an encapsulation made by Chrome based on a real microphone. The microphone will be limited by Windows' sound communication configuration. Avoid using the device for business purposes.

Scope of influence: None

  • Related callbacks: None

Related interfaces: createStream,createZegoStream, useAudioDevice.

  • Platform differences: None

Returns audio input device list information.

getSpeakers

getSpeakers
getSpeakers(): Promise<ZegoDeviceInfo[]>
Get the list of speaker devices and provide the device id parameter for operating the hardware device interface.
  • Default value: None
  • When to call: after initialization, before creating a stream.

Restrictions on use: None

  1. Due to the browser's security and privacy protection, the page needs to call this interface in a secure environment (https, localhost, 127.0.0.1). See Privacy and security.
  2. When the page device permission is not granted, calling this method will temporarily turn on the microphone to trigger the browser's speaker device permission request. On browsers such as Chrome 81+, Firefox, Safari, etc., accurate device information cannot be obtained without media device permissions.
  3. Safari does not support getting speaker information.

Scope of influence: None

  • Related callbacks: None

Related interfaces: Specifies the audio output device interface [useAudioOutputDevice].

  • Platform differences: None

Returns audio output device list information.

useFrontCamera

useFrontCamera
useFrontCamera(localStream: MediaStream | ZegoLocalStream, enable: boolean): Promise<ZegoServerResponse>
Switch camera

Parameters

NameTypeDescription
localStreamMediaStream | ZegoLocalStreamThe stream created by createStream or the ZegoLocalStream instance object created by createZegoStream.
enablebooleanWhether to use the front camera; "true" means use the front camera; "false" means use the rear camera。
  • Default value: None

Timing of calling: After the stream is created successfully, and the stream type must be the camera type to collect the stream.

Restrictions on use: None

If the camera switch fails, the original stream will be retained and an error will be returned.

Scope of influence: None

  • Related callbacks: None

Related interface: None

  • Platform differences: None

useVideoDevice

useVideoDevice
useVideoDevice(localStream: MediaStream | ZegoLocalStream, deviceID: string): Promise<ZegoServerResponse>
Switch camera

Parameters

NameTypeDescription
localStreamMediaStream | ZegoLocalStreamThe stream created by createStream or the ZegoLocalStream instance object created by createZegoStream.
deviceIDstringCamera device ID that needs to be switched
  • Default value: None

Timing of calling: After the stream is created successfully, and the stream type must be the camera type to collect the stream.

Restrictions on use: None

If the camera switch fails, the original stream will be retained and an error will be returned.

Scope of influence: None

  • Related callbacks: None

Related interface: switch the microphone useAudioDevice.

  • Platform differences: None

useAudioDevice

useAudioDevice
useAudioDevice(localStream: MediaStream | ZegoLocalStream, deviceID: string): Promise<ZegoServerResponse>
Switch microphone

Parameters

NameTypeDescription
localStreamMediaStream | ZegoLocalStreamThe stream created by createStream or the ZegoLocalStream instance object created by createZegoStream.
deviceIDstringThe ID of the microphone device that needs to be switched
  • Default value: None

Timing of calling: After the stream is created successfully, and the stream type must be the camera type to collect the stream.

Restrictions on use: None

If you fail to switch the microphone, the original stream will be retained and an error will be returned.

Scope of influence: None

  • Related callbacks: None

Related interface: switch the microphone useVideoDevice.

  • Platform differences: None

useAudioOutputDevice

useAudioOutputDevice
useAudioOutputDevice(media: HTMLMediaElement, deviceID: string): Promise<boolean>
Switch the audio output device.

Parameters

NameTypeDescription
mediaHTMLMediaElementMedia tag element, <audio> or <video>.
deviceIDstringAudio output device ID.
  • When to call: after using [getSpeakers] to get the list of audio output devices.

caution: This interface is currently only supported by the Chrome browser.

Related interface: Get the speaker list interface [getSpeakers].

Return

Promise returns a Boolean ID indicating whether the call was successful.

setSoundLevelDelegate

setSoundLevelDelegate
setSoundLevelDelegate(bool: boolean, interval?: number, options?: SoundLevelDelegateOptions): void
Set whether to monitor the sound wave and the sound wave callback interval

Parameters

NameTypeDescription
boolbooleanTurn on or off the sound wave callback
intervalnumberThe time interval to call back, the default is 1000ms, optional
optionsSoundLevelDelegateOptionsSetting Options.
  • Default value: None
  • When to call: After initializing the instance.

Restrictions on use: None

None

Scope of influence: None

Related callback: soundLevelUpdate callback.

Related interface: None

  • Platform differences: None

isMicrophoneMuted

isMicrophoneMuted
isMicrophoneMuted(): boolean
Get microphone mute status

Get the microphone mute status.

  • Use cases: Used to determine whether the host’s own microphone is turned on.
  • When to call /Trigger: After calling loginRoom interface to log in the room successfully
  • Related APIs: Call muteMicrophone to turn the microphone sound interface off / on.
  • Available since: 2.8.0 and above

muteMicrophone

muteMicrophone
muteMicrophone(mute: boolean): boolean
mute microphone

Parameters

NameTypeDescription
mutebooleanWhether to mute the microphone; true means to mute the microphone; false means to turn on the microphone; if not set, the default is false.
  • When to call: After initializing the instance.

    The premise of whether to mute the microphone is that the original stream must have an audio track, and it cannot be pure video when creating the stream.

Related interface: Call isMicrophoneMuted interface to get microphone mute status; Call the mutePublishStreamAudio interface to turn off / on the sound being pushed.

  • Platform differences: None

createRangeAudioInstance

createRangeAudioInstance
createRangeAudioInstance(): ZegoExpressRangeAudio
Create a range voice instance object.

Often used in voice game scenarios, users can use range voice-related functions through the created range voice instance objects.

  • Use cases: Often used in shooting games and meta-universe game scenes, users can use the range voice-related functions through the created range voice instance objects.
  • When to call /Trigger: Called after creating the ZegoExpressEngine instance and before calling the interface loginRoom to log in to the room.
  • Caution: Use range voice function can no longer use startPublishingStream, startPlayingStream these push-pull stream interfaces and related callbacks.
  • Available since: 2.10.0

Range Audio Module Instance

createRealTimeSequentialDataManager

createRealTimeSequentialDataManager
createRealTimeSequentialDataManager(roomID: string): ZegoRealTimeSequentialDataManager
Create real-time sequential data instance objects

Parameters

NameTypeDescription
roomIDstringroom ID

Details

Create real-time sequential data instance objects.

  • Use cases: it is often used in remote control scenarios. Users can use real-time sequential data related functions through the created real-time sequential data instance object.
  • When to call /Trigger: call after creating ZegoExpressEngine instance.
  • Available since: 2.12.2

Return

Real-time Sequential Data instance object

destroyRealTimeSequentialDataManager

destroyRealTimeSequentialDataManager
destroyRealTimeSequentialDataManager(manager: ZegoRealTimeSequentialDataManager): void
destroy real-time sequential data instance objects

Parameters

NameTypeDescription
managerZegoRealTimeSequentialDataManagerreal-time sequential data object

Details

Destroy real-time sequential data instance objects.

  • Use cases: it is often used in remote control scenarios. Users can use real-time sequential data related functions through the created real-time sequential data instance object.
  • When to call /Trigger: call after creating ZegoExpressEngine instance and createRealTimeSequentialDataManager.
  • Available since: 2.12.2

createCopyrightedMusic

createCopyrightedMusic
createCopyrightedMusic(): ZegoCopyrightedMusic
Create a copyrighted music instance object.

Create a copyright music instance object.

  • Use cases: Often used in online KTV chorus scenarios, users can use related functions by creating copyrighted music instance objects.
  • When to call /Trigger: After initializing the engine instance.
  • Caution: The SDK only supports creating one instance, calling this function multiple times returns the same object.
  • Available since: 2.24.5

The media stream player component instance.

destroyCopyrightedMusic

destroyCopyrightedMusic
destroyCopyrightedMusic(): void
Destroy a copyrighted music instance object.

Destroy a copyright music instance object.

  • When to call /Trigger: After initializing the engine instance.
  • Available since: 2.24.5

enableMultiRoom

enableMultiRoom
enableMultiRoom(enable: boolean): boolean
turn on multi room mode

Parameters

NameTypeDescription
enablebooleanWhether to open, true means open, false means closed.

Details

do you need to open multiple rooms, the same user can join multiple rooms at the same time, push and pull streams, send real-time messages and receive message callbacks in multiple rooms at the same time

  • Use cases: super small class scenario for cross room continuous learning and online education
  • Default value: multiple rooms mode is not turned on by default
  • When to call: you need to call it before you first log in to the room after initializing SDK.
  • Related APIs: loginRoom, logoutRoom, startPublishingStream
  • Available since: 2.8.0 and above
  • Restrictions: It can only be called once in a complete life cycle

setLogConfig

setLogConfig
setLogConfig(config: ZegoLogConfig): boolean
Advanced log configuration

Parameters

NameTypeDescription
configZegoLogConfigLog related advanced configuration
  • Default value: Both the local log and upload level are info.
  • When to call: After initialization, it is called before any other interfaces.

Usage restriction: None, but it is recommended to call it only once in the entire life cycle.

Unless there is a clear special requirement, please do not call this interface to change the default configuration.

  • Related callbacks: None

Related interface: None

Return

Whether the call is successful; failure condition: the input parameter format is wrong

setDebugVerbose

setDebugVerbose
setDebugVerbose(enable: boolean): void
The error log information alert indicates that the default test environment is all on

Parameters

NameTypeDescription
enablebooleanWhether to open the debug mode; the default SDK will automatically determine
  • Default value: The default value of the test environment is “true”, which can be turned off manually.
  • When to call: After initialization, call immediately.

Restrictions on use: None

It is recommended to keep the default behavior and try not to use this interface.

Scope of influence: All SDK internal errors will be prompted by a pop-up, interrupting the entire process.

  • Related callbacks: None

Related interface: None

  • Platform differences: None

getVersion

getVersion
getVersion(): string
Get the current SDK version
  • Default value: None

Call timing: It can be called at any timing after initialization.

Restrictions on use: None

None

Scope of influence: None

  • Related callbacks: None

Related interface: None

  • Platform differences: None

Is a string, such as "1.0.0. Identification"

loginRoom

loginRoom
loginRoom(roomID: string, token: string, user: ZegoUser, config?: ZegoRoomConfig): Promise<boolean>
Login room

Parameters

NameTypeDescription
roomIDstringRoom ID, generated by developer, a string with a maximum length of 128 bytes. Only supports numbers, English characters and'~','!','@','#','$','','^','&','*','(',')', '_','+','=','-',',';',''',',','.','<','>','/'.
tokenstringThe login verification token is obtained by registering the project in the instant console to obtain the key plus the specified algorithm. The testing phase can be bypassed through the instantaneous interface, and the formal environment must be implemented by the user.
userZegoUserLogin user information.
config?ZegoRoomConfigRoom related configuration,optional.

Details

Log in to the room and share the stream, message, user and other information changes with the room user.

  • Use cases: Log in to the room to obtain interface permissions for audio, video or message interaction with other users.

Calling time: after initialization and token acquisition.

Cautions:

  1. Token is the key to log in to the room and needs to be implemented by the developer. To ensure security, the token must be generated on the developer's own server.
  2. The default is single room mode, the same user (ie UserID) cannot log in to two and more rooms at the same time.
  3. If you want to monitor the changes of other users in the room, the "userUpdate" parameter under the config object must be set to "true".
  4. If the room does not exist, loginRoom will create and log in the room.

Privacy protection statement: 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.

Scope of influence: Most interfaces can be called after logging in to the room.

Related callback: Room status callback roomstatechanged, please use roomstateupdate before 2.16.0

Related interface: You can call the logoutRoom interface to exit the room.

Return

Promise returns the login result asynchronously, true means login is successful, false means login failed.

switchRoom

switchRoom
switchRoom(fromRoomID: string, toRoomID: string, config: ZegoSwitchRoomConfig): Promise<boolean>
switch room

Parameters

NameTypeDescription
fromRoomIDstringThe currently logged in room ID, generated by developer, a string with a maximum length of 128 bytes. Only supports numbers, English characters and'~','!','@','#','$','','^','&','*','(',')', '_','+','=','-',',';',''',',','.','<','>','/'.
toRoomIDstringRoom ID to be switched (must be an unlogged room ID), generated by developer, a string with a maximum length of 128 bytes. Only supports numbers, English characters and'~','!','@','#','$','','^','&','*','(',')', '_','+','=','-',',';',''',',','.','<','>','/'.
configZegoSwitchRoomConfigRoom related configuration, token required.

Details

Switch rooms, quickly switch from the current room to another room..

  • Use cases: Convenient to realize the switch between different rooms, such as switching from live room to 1v1 room.

Calling time: After successfully logging into the room.

Cautions:

  1. Token is the key to log into the toRoomID room, which needs to be implemented by the developer. In order to ensure security, the token must be generated on the developer's own server side.
  2. fromRoomID must be the logged in room ID, and toRoomID must be the logged in room ID, If the room does not exist, a new room will be created.
  3. Switching room will stop all push and pull streams in the current room, but will not stop the preview. If you want to stop the preview, you can call destroyStream to destroy the preview stream.
  4. If CDN manual retweet is set, it will not stop automatically when switching rooms, and the user needs to manually stop CDN retweet.

Privacy protection statement: 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.

Scope of influence: Most interfaces can be called after logging in to the room.

Related callback: Room status callback roomstatechanged, please use roomstateupdate before 2.16.0

Related interface: You can call the logoutRoom interface to exit the room.

Return

Promise returns the login result asynchronously, true means login is successful, false means login failed.

logoutRoom

logoutRoom
logoutRoom(roomID?: string): void
Exit the room and no longer accept various state in the room

Parameters

NameTypeDescription
roomID?stringKeep the same as the roomID of the login room, optional
  • Default value: None

Timing of calling: After logging in to the room successfully.

Restrictions on use: None

None

Scope of influence: Most of the interfaces can no longer be called after exiting the room.

Related callback: Room status callback roomstatechanged, please use roomstateupdate before 2.16.0.

Related interface: call loginRoom interface login number room.

  • Platform differences: None

renewToken

renewToken
renewToken(token: string, roomID?: string): boolean
Update room permission token

Parameters

NameTypeDescription
tokenstringSpecify the token generated by the algorithm, that is, the we provides different language versions of the SDK to generate the token;
roomIDstringRoom ID, a string with a maximum length of 128 bytes. Only supports numbers, English characters and'~','!','@','#','$','','^','&','*','(',')', '_','+','=','-',',';',''',',','.','<','>','/',
  • Default value: none

Calling time: After logging in to the room, actively change the user's permissions in the room; After logging in to the room, the token is about to expire and the callback is received;

Restrictions on use: None

The token is the key to log in to the room. This needs to be implemented by the customer. To ensure security, the token must be generated on the server.

Scope of influence: the expiration time contained in the token, the tokenWillExpire callback will be triggered 30s before the expiration

Related callback: the room token is about to expire, the callback tokenWillExpire

Related interface: none

  • Platform differences: None

Return

true: Call succeeded, false: Call failed (SDK Preliminary format verification)

setRoomExtraInfo

setRoomExtraInfo
setRoomExtraInfo(roomID: string, key: string, value: string): Promise<ZegoServerResponse>
Set room extra information

Parameters

NameTypeDescription
roomIDstringroom ID
keystringAdditional message key
valuestringAdditional message value
  • Default value: None

Timing of calling: after successfully logging in to the room.

Usage restriction: For the usage restriction of this interface, please refer to https://doc-en.zego.im/article/7616 or contact ZEGO technical support.

At present, only one key-value pair is allowed to be set in the room additional message, and the maximum length of key is 10 bytes, and the maximum length of value is 100 bytes.

Security 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.

Scope of influence: Most interfaces can be called after logging in to the room.

Related callback: roomExtraInfoUpdate callback for room additional information.

Related interface: None

  • Platform differences: None

sendBarrageMessage

sendBarrageMessage
sendBarrageMessage(roomID: string, message: string): Promise<ZegoServerResponse>
Send room barrage message, the message is not guaranteed to be reliable

Parameters

NameTypeDescription
roomIDstringRoom ID
messagestringMessage content, the length does not exceed 1024 bytes

Details

Send a barrage message to all users in the room corresponding to roomID. The message is not guaranteed to be reliable.

  • Use cases: users in the room send barrage messages to interact.
  • When to call: After calling the interface loginRoom to log in to the room successfully.
  • Related callbacks: Users in the room can receive messages through the room barrage message notification callback IMRecvBarrageMessage.
  • Available since: 1.0.0 and above.
  • Restrictions: Please refer to the   /real-time-video-web/best-practice/restrictions   Or contact ZEGO technical support.

Security 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.

sendBroadcastMessage

sendBroadcastMessage
sendBroadcastMessage(roomID: string, message: string): Promise<ZegoServerResponse>
Send broadcast message (messages are guaranteed to be reliable)

Parameters

NameTypeDescription
roomIDstringRoom ID.
messagestringMessage content, the length does not exceed 1024 bytes.

Details

Send a text message to all users in the room corresponding to roomID.

  • Use cases: Users in the room send messages to chat and interact, for example, the chat room.
  • When to call: After calling the interface loginRoom to log in to the room successfully.
  • Impacts on other APIs: Most interfaces can be called after logging in to the room.

Related callback: Users in other rooms can receive messages through the broadcast message notification callback IMRecvBroadcastMessage.

  • Available since: 1.0.0 and above.
  • Restrictions: For restrictions on the use of this interface, please refer to /real-time-video-web/best-practice/restrictions or contact ZEGO technical support.

Security 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.

sendCustomCommand

sendCustomCommand
sendCustomCommand(roomID: string, message: string, toUserIDList: string[]): Promise<ZegoServerResponse>
send custom command, the message is reliable

Parameters

NameTypeDescription
roomIDstringRoom ID.
messagestringCustom message content, the length does not exceed 1024 bytes.
toUserIDListstring[]Target user uerId array. Passing in an empty array means it is sent to all users in the room.

Details

Send a custom message to the designated user in the room corresponding to roomID, and the message is guaranteed to be reliable.

  • Use cases: Chat with individual users privately.
  • When to call: after successfully logging in to the room.
  • Impacts on other APIs: Most interfaces can be called after logging in to the room.
  • Related callbacks: Users in the room can receive messages by listening to the custom command signaling callback IMRecvCustomCommand.
  • Available since: 1.0.0 and above.
  • Restrictions: For restrictions on the use of this interface, please refer to /real-time-video-web/best-practice/restrictions or contact ZEGO technical support.

Security 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.

sendTransparentMessage

sendTransparentMessage
sendTransparentMessage(roomID: string, message: ZegoRoomSendTransparentMessage): Promise<ZegoServerResponse>
Sends a transparent message in room.

Parameters

NameTypeDescription
roomIDstringRoom ID.
messageZegoRoomSendTransparentMessageZegoRoomSendTransparentMessage

Details

Send point-to-point signaling to other users who have logged into the same room.

  • Use cases: Generally used for remote control signaling or message sending between users.
  • When to call: after successfully logging in to the room.
  • Impacts on other APIs: Most interfaces can be called after logging in to the room.
  • Related callbacks: When sending a message, Mode is specified for ZegoRoomTransparentMessageModeOnlyClient or ZegoRoomTransparentMessageModeClientAndServer can pass [recvRoomTransparentMessage] received sends the message content.
  • Available since: 3.11.0 and above.
  • 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 contact ZEGO technical support.

Security 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.

ZegoExpressPlayer

Zego Web Express SDK Player Plug-in

Details

Detailed description: Web player plug-in, used to playing live CDN streams.

Business scenario: playing CDN streams for live streaming.

Properties

played

played
played: boolean

Read-only, Player playback status. If true, it means the CDN resource is being played.

paused

paused
paused: boolean

Read-only, player paused status, true means the player is not currently rendering CDN resources.

volume

volume
volume: number

Read-only, the volume currently set by the player. The value range is [0,100] and can be modified through the [setVolume] interface.

currentTime

currentTime
currentTime: number

read only, The current playback time, that is, the pts value of the current rendering frame, is accurate to the last two decimal places, and the unit is seconds. Use event callback [onTimeUpdate] to monitor changes in playback time.

muted

muted
muted: boolean

Read-only, whether the current playback status is muted. If true, it means the player is muted.

mediainfo

mediainfo
mediainfo: MediaInfo

Read-only, currently playing media resource information, changes to this attribute can be learned by listening to the callback [onMediaInfoUpdate].

src

src
src: string
  • Use cases:

  • Required:

  • Default value:

  • Recommended value:

  • Value range:

  • Caution:

  • Privacy reminder:

  • Platform differences:

Methods

ZegoExpressPlayer

static
ZegoExpressPlayer
Player plug-in constructor

Parameters

NameTypeDescription
engineZegoExpressEngineEngine instance object for Zego Web Express SDK
configZegoExpressPlayerConfigInitial configuration of player plug-in

Details

Instantiate the player plug-in.

  • Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.

Return

Player instance

verify

verify
verify(token: string, userID: string): Promise<boolean>
Player authentication

Parameters

NameTypeDescription
tokenstringEnter the token, which is consistent with the token generation method for room login.
userIDstringThe user userID is consistent with the userID that generated the token and is used for player authentication.

Details

Player authentication

  • Use cases: After initializing the player plug-in, if the SDK does not log in to the room, the player plug-in needs to be authenticated.
  • When to call /Trigger: Called after the player is instantiated and before other interfaces are used.
  • Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.

Return

Authentication result, if the return result is true, it means the authentication is successful, if it is false, it means the authentication fails.

play

play
play(): void
The player starts playing

Start playing CDN resources.

  • Use cases: After the player initializes and specifies the CDN resource, it starts playing the CDN resource.
  • When to call /Trigger: Called after the player is instantiated and authenticated.
  • Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.

pause

pause
pause(): void
The player starts playing

Pause CDN resource playback.

  • Use cases: When playing CDN resources, pause the playback.
  • Caution: When pausing playback, in order to synchronize with the latest CDN live broadcast progress as much as possible, the player will drop frames during the pause process.
  • When to call /Trigger: Called after the player starts pulling CDN resources.
  • Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.

resume

resume
resume(): void
The player re-pulls the current CDN live stream.

The player re-pulls the current CDN live stream.

  • Use cases: Such as CDN resource exceptions and other scenarios, used when CDN resources need to be re-pulled.
  • When to call /Trigger: Called after the player pulls CDN resources.
  • Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.

stop

stop
stop(): void
Stop playing the resource and no longer load the currently specified media

Stop playing CDN resources.

  • Use cases: After the player starts playing CDN resources, it stops playing the resources.
  • When to call /Trigger: Called after the player is instantiated and authenticated.
  • Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.

fullScreen

fullScreen
fullScreen(): void
Player plays in full screen

The player plays in full screen.

  • Use cases: The player plays CDN resources in full screen.
  • When to call /Trigger: Called after the player starts pulling CDN resources.
  • Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.

destroy

destroy
destroy(): void
Destroy player

Destroy the player and release the memory and CPU resources occupied by the player.

  • Use cases: At the end of the player life cycle, when the player is no longer needed to play media resources, the player instance needs to be consumed.
  • When to call /Trigger: Called after the player is instantiated.
  • Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.

setVolume

setVolume
setVolume(): void
Player volume settings

Set the volume of the player, the value range is [0, 100].

  • Use cases: The player sets the volume of the current playing resource.
  • When to call /Trigger: Called after player instantiation and authentication.
  • Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.

getPlayQuality

getPlayQuality
getPlayQuality(): QualityStats
Player get quality

The player plays in full screen.

  • Use cases: The player plays CDN resources in full screen.
  • When to call /Trigger: Called after the player starts pulling CDN resources.
  • Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.

setMuted

setMuted
setMuted(mute: boolean): void
Player settings playback mute switch

Parameters

NameTypeDescription
mutebooleanSet the mute status. When the value is true, it means turning on muting. When it is false, it means turning off muting.

Details

Set the volume of the player, the value range is [0, 100].

  • Use cases: The player sets the volume of the current playing resource.
  • When to call /Trigger: Called after player instantiation and authentication.
  • Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.

setBufferInterval

setBufferInterval
setBufferInterval(intervals: BufferIntervals): void

Parameters

NameTypeDescription
intervalsBufferIntervalsbuffer intervals

Details

set buffer interval.

  • When to call /Trigger: Called after the player starts pulling CDN resources.
  • Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.

enableSoundLevelMonitor

enableSoundLevelMonitor
enableSoundLevelMonitor(enable: boolean, millisecond?: number, options?: SoundLevelDelegateOptions): void
Set whether to monitor the sound wave and the sound wave callback interval

Parameters

NameTypeDescription
enablebooleanTurn on or off the sound wave callback
millisecondnumberThe time interval to call back, the default is 1000ms, optional
optionsSoundLevelDelegateOptionsSetting Options.
  • Default value: None
  • When to call: After initializing the instance.

Restrictions on use: Using MSE (Media Source Extensions) decoding method to play audio on Safari browser cannot obtain sound waves. If you need to obtain sound waves, avoid using MSE decoding method on Safari browser.

None

Scope of influence: None

Related callback: onSoundLevelUpdate callback.

Related interface: None

  • Platform differences: None

onCanPlay

onCanPlay
onCanPlay(): void
Player CDN resource playable callback

The resource metadata has been parsed and the media file can be played. You can cancel rendering of the Loading control in this callback to prompt the user that the video can start playing.

  • Use cases: You can listen to this callback to prompt the user that the current CDN resource can start playing.
  • When to call /Trigger: Called after the player sets the CDN resource.
  • Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.

onPlay

onPlay
onPlay(): void
Player rendering (play resource) starts callback

The callback when the player starts playing CDN resources. When this callback is triggered, it means that the player has started rendering audio and video resources.

  • Use cases: You can listen to this callback to determine whether the CDN resource has started rendering, and make related UI changes, such as removing video masks, etc.
  • When to call /Trigger: Called after the player sets the CDN resource.
  • Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.

onPaused

onPaused
onPaused(): void
Player rendering pause callback

The player pauses the callback of rendering CDN resources. When this callback is triggered, it means that the player pauses the rendering of audio and video resources.

  • Use cases: You can listen to this callback to determine whether the CDN resource has started rendering, and make related UI changes, such as turning on the video mask or rendering the play button.
  • When to call /Trigger: Called after the player sets the CDN resource.
  • Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.

onLoaded

onLoaded
onLoaded(): void
CDN resource loading end callback

This callback will be triggered when the player ends loading to the CDN media resource.

  • Use cases: Use this callback to determine whether the CDN resource has been loaded.
  • When to call /Trigger: Called after the player sets the CDN resource.
  • Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.

onTimeUpdate

onTimeUpdate
onTimeUpdate(): void
Callback for current playback time change

The current playback time, that is, this callback is triggered when the pts of the current rendering frame changes. The trigger frequency is up to 0.01s. The actual trigger frequency is affected by the frame rate, sampling rate and other factors of the CDN media resource.

  • Use cases: You can listen to this callback to obtain the playback progress of the current live broadcast resource.
  • When to call /Trigger: Called after the player sets the CDN resource.
  • Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.

onWaiting

onWaiting
onWaiting(): void
Playback has stopped due to temporary lack of data.

The player pauses rendering due to lack of CDN media data, waiting for enough data to be loaded. For related callbacks, please refer to [onPlaying].

  • Use cases: You can render UI interfaces such as the Loading control in this callback to prompt the user that the video is loading.
  • When to call /Trigger: Called after the player sets the CDN resource.
  • Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.

onPlaying

onPlaying
onPlaying(): void
Playback loads enough data that playback can be resumed.

Player loads enough data and starts to resume playback. Usually after [onWaiting] is triggered, when the player buffers enough data, it unbuffers and resumes playback. If the player has been paused at this time, rendering will not automatically resume.

  • Use cases: You can render UI interfaces such as the Loading control in this callback to prompt the user that the video is loading.
  • When to call /Trigger: Called after the player sets the CDN resource.
  • Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.

onError

onError
onError(err: ZegoExpressPlayerError): void
Player error callback

Parameters

NameTypeDescription
errZegoExpressPlayerErrorError codes and error messages

Details

When the player triggers an error, it will call back the error code and error information.

  • Use cases: You can listen to this callback and perform related business processing when the player triggers an error.
  • When to call /Trigger: Called after the player is initialized and authenticated.
  • Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.

onMediaInfoUpdate

onMediaInfoUpdate
onMediaInfoUpdate(mediaInfo: MediaInfo): void
Playback CDN resource media information update callback

Parameters

NameTypeDescription
mediaInfoMediaInfoMedia information of CDN resources parsed by the player

Details

The CDN resource media information update callback parsed by the player. As the media data in the CDN resource is gradually parsed, this callback may be triggered multiple times.

  • Use cases: You can listen to this callback to record relevant media information data and perform related business operations.
  • When to call /Trigger: Called after the player starts playing CDN resources.
  • Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.

onResetPlayQuality

onResetPlayQuality
onResetPlayQuality(quality: QualityStats): void
A callback when the player resets the streaming quality statistics

Parameters

NameTypeDescription
qualityQualityStatsThe streaming quality statistics of the player

Details

This callback is triggered when the player resets the streaming quality statistics and throws the last streaming quality statistics.

  • Use cases: You can listen for this callback to get accurate streaming quality statistics before the player reset. Resetting stream quality statistics is triggered when resources are reloaded (e.g., setting src, calling resume).
  • When to call: After the player is instanced.
  • Available since: Player plug-in version 1.3.1 and above, rely on Express SDK version 3.0.0 and above.

onRecvSEI

onRecvSEI
onRecvSEI(byte: Uint8Array): void
A callback when the player receives SEI data

Parameters

NameTypeDescription
byteUint8ArraySEI data

Details

This callback is triggered when the player receives SEI data.

  • Use cases: You can listen for the callback to get the SEI data for the video.
  • When to call: After the player is instanced.
  • Available since: Player plug-in version 1.3.0 and above, rely on Express SDK version 3.0.0 and above.

onSoundLevelUpdate

onSoundLevelUpdate
onSoundLevelUpdate(soundLevel: number): void
Sound wave callback for playing audio

Parameters

NameTypeDescription
soundLevelnumberThe locally collected sound wave values range from 0.0 to 100.0.

Details

By enabling SoundLevelMonitor to retrieve sound waves, this callback will be triggered when playing sound.

  • Use cases: You can listen to this callback to obtain real-time playback of sound waves.
  • When to call: After instantiating the player.
  • Available since: Player plugin version 1.5.0 and above.

ZegoExpressRangeAudio

Range Audio

Details

Detailed description: Often used in chicken-eating games and meta-universe game scenarios, users can use the range voice-related functions through the created range voice instance objects.

Methods

getInstance

static
getInstance
getInstance(engine: any, logger: any): ZegoExpressRangeAudio
NameTypeDescription
engineany-
loggerany

setVoiceChangerParam

setVoiceChangerParam
web setVoiceChangerParam(voiceParam: number): Promise<ZegoServerResponse>

Parameters

NameTypeDescription
voiceParamnumberVoice change custom parameter value.The value range is [-12.0, 12.0]. The larger the value, the sharper the sound. Setting it to 0.0 will turn off the voice changer.

Details

Perform voice change processing on pushed media streams with custom parameter settings.

  • Use cases: Switch voice changer reduction before or during streaming.
  • Default value: None
  1. Currently only supports voice changer reduction for a specific stream, and does not support simultaneous noise reduction for multiple streams;
  • Available since: 3.0.0

setVoiceChangerPreset

setVoiceChangerPreset
web setVoiceChangerPreset(preset: ZegoVoiceChangerPreset): Promise<ZegoServerResponse>

Parameters

NameTypeDescription
presetZegoVoiceChangerPresetPreset value for changing sound

Details

Perform voice changer reduction processing on the pushed media stream.

  • Use cases: Switch voice changer reduction before or during streaming.
  • Default value: None
  • When to call /Trigger: After calling the interface createStream to create a stream successfully.
  1. Currently only supports voice changer reduction for a specific stream, and does not support simultaneous noise reduction for multiple streams;
  • Available since: 2.24.0

enableAudioSourceUpdateChecker

enableAudioSourceUpdateChecker
enableAudioSourceUpdateChecker(update: boolean, config?: ZegoRangeAudioUserUpdateCheckConfig): void
Whether to check for changes to users in range.

Parameters

NameTypeDescription
updatebooleanwhether to check.
config?ZegoRangeAudioUserUpdateCheckConfigCheck for in range user change configuration

Details

Whether to check for changes to users in range.

  • When to call /Trigger: After calling interface createRangeAudioInstance to create ZegoExpressRangeAudio instance.
  • Related callbacks: audioSourceWithinRangeUpdate.
  • Available since: 2.22.0

on

on
on<K extends keyof ZegoRangeAudioEvent >(event: K, callBack: ZegoRangeAudioEvent[K]): boolean
Register callback event.

Parameters

NameTypeDescription
eventKListener event name.
callBackZegoRangeAudioEvent[K]Callback.

Details

The interface used to handle the SDK's initiative to notify developers of callbacks. By registering different events, you can receive callbacks of different functions. The event callback that can be monitored can be viewed in ZegoRangeAudioEvent.

Use case: Used to register the callback processing of business events related to the range audio function.

Timing of calling: After calling the interface createRangeAudioInstance to create the instance and before calling the interface loginRoom to log in to the room.

The same event can be registered multiple, the same registered event will be triggered in sequence according to the order of registration.

Related interface: call interface off to cancel the corresponding callback event processing.

Return

Whether the registration is successful.

off

off
off<K extends keyof ZegoRangeAudioEvent >(event: K, callBack?: ZegoRangeAudioEvent[K]): boolean
Unregister callback events.

Parameters

NameTypeDescription
eventKListener event name.
callBackZegoRangeAudioEvent[K]Callback.

Details

The interface used to handle the SDK's initiative to notify developers of callbacks. By registering different events, you can receive callbacks of different functions. Used to delete the registered callback event of the same type.

Use case: It is used for callback processing of business events related to logoff range voice function.

call timing: after calling the interface createrangeaudioinstance to create an instance.

  • Caution: if there is no callback method to log off, all callbacks of this event will be logged off.

Return

Whether the unregister was successful.

setAudioReceiveRange

setAudioReceiveRange
setAudioReceiveRange(range: number): void
Set the maximum range of audio reception distances.

Parameters

NameTypeDescription
rangenumberAudio range, the value must be greater than or equal to 0.

Details

Set the maximum distance range of the audio reception, the sound source sound exceeding the range will be undesirable, and the situation that is not set is default the unlimited range.

  • Use cases: Set the hearing range of the listener in the range voice.
  • Default value: Not set, the default is unlimited, that is, hears the sound of everyone in the room.
  • Caution: This range only applies to speakers from different teams.
  • When to call /Trigger: Call Interface CreateRangeAudioInStance Create a ZegoExpressRangeAudio instance.
  • Available since: 2.10.0

updateSelfPosition

updateSelfPosition
updateSelfPosition(position: number[], axisForward: number[], axisRight: number[], axisUp: number[]): void
Update the position and orientation of the listener.

Parameters

NameTypeDescription
positionnumber[]The coordinates of themselves in the world coordinate system, the parameter is the number array of length 3, and the three values ​​represent the front, right, and coordinate values.
axisForwardnumber[]The unit vector of the forward axis of its own coordinate system. The parameter is the number array of length 3, and the three values ​​represent the front, right, and coordinate values.
axisRightnumber[]The unit vector of the right axis of the own coordinate system. The parameter is the number array of length 3, and the three values ​​represent the front, right, and coordinate values.
axisUpnumber[]The unit vector of the up axis in its own coordinate system. The parameter is the number array of length 3, and the three values ​​represent the front, right, and coordinate values.

Details

Its own position and orientation, so that the SDK can calculate the distance between the user and the audio source and the stereo effect of the left and right ears.

  • Use cases: When the character operated by the user in the game moves on the world map, the position information and head orientation of the character are updated.
  • Caution: If you don't call updateSelfPosition to set the position information before calling enableSpeaker to turn on the speakers, you can't receive voices from people other than the squad.
  • When to call /Trigger: After creating a ZEGOEXPRESSRANGEAUDIO instance, call the interface EnableSpeaker before.
  • Available since: 2.10.0

updateAudioSource

updateAudioSource
updateAudioSource(userID: string, position: number[]): void
Add or update sound source position information.

Parameters

NameTypeDescription
userIDstringSpeaker user ID.
positionnumber[]The coordinator in the world coordinate system is the number array of length 3, and the three values ​​represent the front, right, and coordinate values.

Details

Set the position of the audio source corresponding to the userID on the world map so that the SDK can calculate the distance and orientation of the listener to the audio source.

  • Use cases: Update the position of the voice user in the game map coordinates.
  • When to call /Trigger: Called after logging in to the room, the recorded audio source information will be cleared after logging out of the room.
  • Available since: 2.10.0

enableSpatializer

enableSpatializer
enableSpatializer(enable: boolean): void
Switch Spatializer.

Parameters

NameTypeDescription
enablebooleanWhether to enable, the default value is true

Details

After the 3D sound effect is turned on, the sound effect in the actual space will be simulated according to the position of the speaker equivalent to the listener. You can intuitively feel the change in the sound volume and the difference between the left and right sound when the distance and orientation of the sound source change. When enable is true, 3D sound is turned on. When false, 3D sound is turned off.

  • Use cases: Voice recognition function in first-person shooter games or social scene games.
  • Default value: Before calling this interface, the default is to turn off 3D sound effects.

Use restrictions: The 3D sound effect only works on the sound of others other than the squad.

  • When to call /Trigger: After calling the interface createRangeAudioInstance to initialize the instance.

Related interface: After turning on the 3D sound effect, you can call updateSelfPositon and updateAudioSource to update the position and orientation to change the stereo effect.

  • Available since: 2.10.0

enableMicrophone

enableMicrophone
enableMicrophone(enable: boolean): void
Switch microphone.

Parameters

NameTypeDescription
enablebooleanWhether to enable, the default value is true

Details

When enable is true, turn on the microphone and push audio stream, when it is false, turn off the microphone and stop pushing audio stream.

  • Use cases: The user turns on or off the microphone to communicate in the room.
  • Default value: Before calling the interface, the microphone is turned off by default.
  • When to call /Trigger: Call the interface createRangeAudioInstance to create an instance and call the interface loginRoom after successfully logging in to the room.

Related callback: get the change of microphone switch state by callback microphoneStateUpdate.

  • Available since: 2.10.0

selectMicrophone

selectMicrophone
selectMicrophone(deviceID: string): Promise<boolean>
Specifies the microphone device.

Parameters

NameTypeDescription
deviceIDstringMicrophone device ID.

Details

Specify the device used to turn on the microphone by passing in the deviceID of the microphone device. The deviceID can be obtained through the [ZegoExpressEngine.getMicrophones] interface.

  • Use cases: Switch the microphone device used.
  • Default value: Before calling the interface, the microphone device specified by the system is used by default.
  • When to call /Trigger: After calling the interface createRangeAudioInstance to create an instance.

Related interface: Get the microphone device list interface [getMicrophones] .

  • Available since: 2.17.0

Return

Asynchronously returns a boolean value indicating whether the switching device was successful.

selectSpeaker

selectSpeaker
selectSpeaker(deviceID: string): void
Specifies the speaker device.

Parameters

NameTypeDescription
deviceIDstringSpeaker device ID.

Details

Specify the device used for range voice playback audio by passing in the deviceID of the speaker device. The deviceID can be obtained through the ZegoExpressEngine.getMicrophones interface.

  • Use cases: Speaker device used by range voice switching.
  • Default value: Before calling the interface, the speaker device specified by the system is used by default.
  • Caution: This interface is currently only supported by the Chrome browser.
  • When to call /Trigger: After calling the interface createRangeAudioInstance to create an instance.

Related interface: Get the microphone device list interface getSpeakers.

  • Available since: 2.19.0

enableSpeaker

enableSpeaker
enableSpeaker(enable: boolean): void
Switch speaker.

Parameters

NameTypeDescription
enablebooleanWhether to enable, the default value is true

Details

When enable is true, it starts to pull and play the audio stream that can be pulled, and when it is false, it stops pulling and playing the audio stream.

  • Use cases: The user chooses whether to receive other people's voices.
  • Default value: Before calling the interface, the default is to turn off receiving audio.
  • When to call /Trigger: Call interface createrangeaudioinstance to create an instance and interface loginroom to log in to the room successfully.
  • Available since: 2.10.0

setRangeAudioCustomMode

setRangeAudioCustomMode
setRangeAudioCustomMode(speakMode: ZegoRangeAudioSpeakMode, listenMode: ZegoRangeAudioListenMode): void
High-level customization mode for setting range voices.

Parameters

NameTypeDescription
speakModeZegoRangeAudioSpeakModeRange voice mode, mode is 0 means listen to everyone, 1 means only within the range, and 2 means only in range.
listenModeZegoRangeAudioListenModeRange voice listening mode, mode is 0 means listen to everyone, 1 means only within range, and 2 means only in range.

Details

Voice Mode and Listen Mode can be set separately to control voice and listen behavior in worlds and squads.

  • Use cases: The user can decide who can listen to his voice by selecting the voice mode, and can also decide whose voice to listen to by selecting the listening mode.
  • Default value: When this interface is not called, the "speak to all" mode and the "listen to all" mode are used by default, that is, the "world" mode.
  • When to call /Trigger: After initializing the instance through createRangeAudioInstance.
  • Related APIs: When you want to listen to the sound from the world, you need to set the sound receiving range [setAudioReceiveRange]. When you want to speak and listen in the team, you need to set [setTeamID] to join the corresponding team.
  • Available since: 2.24.0
  • Restrictions:
  1. Cannot be used with [setRangeAudioMode].
  2. Incompatible with versions before 2.24.0.

setRangeAudioMode

setRangeAudioMode
setRangeAudioMode(mode: ZegoRangeAudioMode): void
Set the range audio mode.

Parameters

NameTypeDescription
modeZegoRangeAudioModeListening mode: if the mode is 0, it means everyone is listening, and if it is 1, it means only the team

Details

Set the listening mode, which can be set to "Everyone" mode or "Team only" mode.

  • Use cases: Users want to communicate only within the squad or with everyone in the room.
  • Default value: When the interface settings are not adjusted, the default is "World Mode", and you can communicate with everyone.
  • When to call /Trigger: After initializing the instance through createRangeAudioInstance.
  • Related APIs: You need to adjust the interface setTeamID to join the corresponding team to hear the voice in the team.
  • Available since: 2.10.0

setTeamID

setTeamID
setTeamID(teamID?: string): void
Set the team ID.

Parameters

NameTypeDescription
teamIDstringTeam ID, String of maximum length of 64 bytes.

Details

After setting the team ID, you will be able to communicate with other users in the same team in the room, and the sound will not change with the distance.

  • Use cases: The user wants to join the team to communicate or exit the team.
  • Default value: The default value is undefined, which means not to join the team.
  • When to call /Trigger: After initializing the instance through createRangeAudioInstance.
  • Caution: The maximum length of the parameter TeamID is 64 bytes.
  • Related APIs: When the interface setRangeAudioMode is set to team mode, only the team can communicate.
  • Available since: 2.10.0

setPositionUpdateFrequency

setPositionUpdateFrequency
setPositionUpdateFrequency(frequency: number): void
Set how often the location is updated in real-time inside the SDK.

Parameters

NameTypeDescription
frequencynumberUpdate frequency, the value must be greater than 15ms.

Details

Set the frequency of real-time location update within the SDK. Minimum 15 ms.

  • Use cases: After updating the position, the audio fade sensitivity is very demanding.
  • Default value: The default is 100 ms.
  • When to call /Trigger: After initializing the instance via createRangeAudioInstance.
  • Available since: 2.19.0

setRangeAudioVolume

setRangeAudioVolume
setRangeAudioVolume(volume: number): void
Set the local playback volume of the range audio.

Parameters

NameTypeDescription
volumenumberVolume level, the value range is [0,200] .

Details

Sets the local playback volume of the range voice.

  • Default value: 100.
  • When to call /Trigger: After calling interface createRangeAudioInstance to create ZegoExpressRangeAudio instance.
  • Available since: 2.19.0

enableAiDenoise

enableAiDenoise
enableAiDenoise(enable: boolean): boolean
Scope Voice turns AI noise reduction on or off.

Parameters

NameTypeDescription
enablebooleanTurn on/off AI noise reduction

Details

Perform AI noise reduction processing on the microphone sound.

  • Use cases: Switch AI noise reduction before or during streaming.
  • Default value: None
  • When to call /Trigger: After calling the interface createStream to create a stream successfully.
  1. Currently using the AI noise reduction function requires a special editing package for technical support;
  2. Currently only supports the use of the PC terminal, the mobile terminal is not currently supported;
  • Available since: Special packaged version.

Return

Identifies whether the interface call is successful. The reason for the failure may be that the browser does not support or does not use a special package.

isAudioContextRunning

isAudioContextRunning
isAudioContextRunning(): boolean
Determine whether the AudioContext object is enabled.

This interface is mainly to deal with the browser's compatibility with the auto-play strategy. Detect whether the current AudioContext object is enabled through the interface isAudioContextRunning. If it is not enabled, it will not support automatic sound playback.

  • When to call /Trigger: After calling createRangeAudioInstance to create the instance.
  • Related APIs: If the AudioContext object is not enabled, you can re-enable the AudioContext object through the resumeAudioContext interface.
  • Available since: 2.10.0

Is the AudioContext enabled

resumeAudioContext

resumeAudioContext
resumeAudioContext(): Promise<boolean>
Enable the internal AudioContext object.

This interface is mainly to deal with the browser's compatibility with the auto-play strategy. It is detected through the interface isAudioContextRunning that the current AudioContext object is not enabled, and it can be re-enabled through this interface.

  • When to call /Trigger: After calling createRangeAudioInstance to create the instance.
  • Caution: This interface must be called in the JS click event to take effect.
  • Related APIs: Detect that the current AudioContext object is not enabled through the interface isAudioContextRunning.
  • Available since: 2.10.0

Whether the resume is successful

setStreamVocalRange

setStreamVocalRange
setStreamVocalRange(view: ZegoStreamView, range: number): void
Set the streaming audio sending range.

Parameters

NameTypeDescription
viewZegoStreamViewPull stream playback component.
rangenumberAudio range, the value must be greater than or equal to 0.

Details

Set the maximum distance range for audio transmission, and the audio source sound beyond this range will not be heard.

  • Use cases: Set the voice range of the streaming sound source in Range Voice.
  • Default value: Default is 0.
  • When to call /Trigger: Call Interface CreateRangeAudioInStance Create a ZegoExpressRangeAudio instance.
  • Available since: 2.20.2

updateStreamPosition

updateStreamPosition
updateStreamPosition(view: ZegoStreamView, position: number[]): void
Update the position of the pull stream.

Parameters

NameTypeDescription
viewZegoStreamViewThe source of the sound is the ZegoStreamView that plays the RTC pull stream.
positionnumber[]The coordinator in the world coordinate system is the number array of length 3, and the three values ​​represent the front, right, and coordinate values.

Details

Set the position of the sound source corresponding to the streaming sound source on the world map so that the SDK can calculate the distance and orientation between the listener and the sound source.

  • Use cases: Updates the position of the custom sound source in game map coordinates.
  • When to call /Trigger: Called after logging in to the room, the recorded audio source information will be cleared after logging out of the room.
  • Available since: 2.21.0

setCustomSourceVocalRange

setCustomSourceVocalRange
setCustomSourceVocalRange(media: HTMLMediaElement, range: number): void
Set custom sound source send range.

Parameters

NameTypeDescription
mediaHTMLMediaElement<video> or <audio> tag object.
rangenumberAudio range, the value must be greater than or equal to 0.

Details

Set the maximum distance range for audio transmission, the audio source sound beyond this range will not be heard, the default is 0.

  • Use cases: Set the sound range of the custom sound source in Range Speech.
  • Default value: Default is 0.
  • When to call /Trigger: Call Interface CreateRangeAudioInStance Create a ZegoExpressRangeAudio instance.
  • Available since: 2.20.2

updateCustomSourcePosition

updateCustomSourcePosition
updateCustomSourcePosition(media: HTMLMediaElement, position: number[]): void
Add or update custom sound source location information.

Parameters

NameTypeDescription
mediaHTMLMediaElementThe sound source can be passed to play a local or online audio file <video> or <audio> tag object.
positionnumber[]The coordinator in the world coordinate system is the number array of length 3, and the three values ​​represent the front, right, and coordinate values.

Details

Set the position of the sound source corresponding to the custom sound source on the world map so that the SDK can calculate the distance and orientation between the listener and the sound source.

  • Use cases: Updates the position of the custom sound source in game map coordinates.
  • When to call /Trigger: Called after logging in to the room, the recorded audio source information will be cleared after logging out of the room.
  • Available since: 2.21.0

ZegoLocalStream

zego local stream

Details

By calling createZegoStream can generate a ZegoLocalStream instance, ZegoLocalStream integrated audio and video collection, playback API.

  • Use cases: Create a local stream for previewing and pushing streams.

Methods

playAudio

playAudio
playAudio(options?: ZegoLocalAduioOptions): void
Play a audio of the media stream to be pushed or that has been pushed on the page.

Parameters

NameTypeDescription
optionsZegoLocalAduioOptionsSet playback options parameters.

Details

The SDK will create a media stream as needed to play the audio of the media stream that is being pushed or is being pushed.Before calling [startPublishingStream] to push the stream, the media playback content will be synchronized with the newly captured audio; After the successful push stream, ZegoLocalStream calls the capture microphone, screen share or third-party audio source again. The newly captured audio will not be updated synchronously to the audio being pushed. If it needs to be updated, it needs to call [updatePublishingStream] to update.

  • Use cases: Plays the audio of a media stream that is to be pushed or is being pushed.
  • When to call: After creating a ZegoLocalStream instance, and the stream is captured.
  • Related callbacks: When calling the [playAudio] interface to play a video failed, the automatic playback failure event callback [autoplayFailed]of ZegoLocalStream will be triggered.
  • Related APIs: Uninstall media streaming component interface [stopAudio] . Calling [destroyStream] also unloads the playback component.
  • Available since: 3.0.0

playCaptureAudio

playCaptureAudio
playCaptureAudio(options?: ZegoLocalAduioOptions): void
Plays the latest media stream audio that is being captured.

Parameters

NameTypeDescription
optionsZegoLocalAduioOptionsSet playback options parameters.

Details

The SDK will create a media stream to play the latest captured media stream audio as needed.

  • Use cases: Plays the latest media stream audio that is being captured.
  • When to call: After creating a ZegoLocalStream instance, and the audio stream is captured.
  • Related callbacks: When calling the [playCaptureAudio] interface to play a video failed, the automatic playback failure event callback [autoplayCaptureFailed]of ZegoLocalStream will be triggered.
  • Related APIs: Uninstall media streaming component interface [stopPlayCaptureAudio] . Calling [destroyStream] also unloads the playback component.
  • Available since: 3.0.0

playCaptureVideo

playCaptureVideo
playCaptureVideo(container: HTMLElement, options?: ZegoLocalViewOptions): void
Plays a video of the latest media stream being captured on the page.

Parameters

NameTypeDescription
containerHTMLElementSpecify a container tag DOM element, such as div. The SDK will create a <video> element under this element to play the video track.
optionsZegoLocalViewOptionsSet playback options parameters (mirror, display mode, etc.).

Details

Specify a DOM element as a container, and the SDK will create media under the element as needed to play a video of the latest captured media stream.

  • Use cases: The latest media streams that are being collected are displayed on the screen.
  • When to call: Run the [createZegoStream] command to create the ZegoLocalStream instance and start capturing video streams.
  • Caution: A ZegoLocalStream instance where the [createZegoStream] configuration parameter [multiplacePreview] defaults to false. If [multiplacePreview] is false, it can only be mounted to a container using the [playCaptureVideo] method, and cannot be mounted multiple times. When [multiplacePreview] is true, calling [playCaptureVideo] once will perform a mount.
  • Related callbacks: When the [playCaptureVideo] interface fails toplay a video, ZegoLocalStream's Autoplay failure event callback is triggered. [autoplayCaptureFailed].
  • Related APIs: Stop media stream playback interface [stopPlayCaptureVideo], [stopPlayCaptureVideo] will uninstall all the playback components that play the latest collection stream. Calling [destroyStream] also uninstalls the player component.
  • Available since: 3.0.0

playVideo

playVideo
playVideo(container: HTMLElement, options?: ZegoLocalViewOptions): void
Play a video of the media stream to be pushed or that has been pushed on the page.

Parameters

NameTypeDescription
containerHTMLElementSpecify a container tag DOM element, such as div. The SDK will create a<video>element under this element to play video tracks.
optionsZegoLocalViewOptionsSet playback options parameters (mirror, display mode, etc.).

Details

Specify a DOM element as a container, and the SDK will create a media stream under the element to play the video of the media stream to be pushed or already pushed, as needed.Before calling [startPublishingStream] to push stream, the media playback content will be synchronized with the latest video content captured at present; After the successful push, ZegoLocalStream calls the capture camera, screen sharing or third-party video source again, and the newly captured video will not be updated synchronously to the video source being pushed. If it needs to be updated, it needs to call [updatePublishingStream] to update.

  • Use cases: Display media stream content on the interface.
  • When to call: After creating a ZegoLocalStream instance, and the stream is captured.
  • Caution: A ZegoLocalStream playback component can only be mounted on one container through the [playVideo] method, and cannot be mounted on multiple ones at the same time.
  • Related callbacks: When calling the [playVideo] interface to play a video failed, the automatic playback failure event callback [autoplayFailed]of ZegoLocalStream will be triggered.
  • Related APIs: Uninstall media streaming component interface [stopVideo] . Calling [destroyStream] also unloads the playback component.
  • Available since: 3.0.0

stopAudio

stopAudio
stopAudio(): void
Stop playing the audio in the stream to be pushed or being pushed.

Stop playing the audio in the stream to be pushed or being pushed.

  • Use cases: Stop playing the audio in the stream to be pushed or being pushed.
  • When to call: The ZegoLocalStream instance has been created with [createZegoStream] and the stream has been collected and [playAudio] has been executed.
  • Related APIs: Calling [destroyStream] unmount the playback component.
  • Available since: 2.17.0

stopCaptureAudio

stopCaptureAudio
stopCaptureAudio(): Promise<boolean>
Stop capturing audio.

Stop capturing audio and destroy the playback component that is previewing the audio. If it is in a push stream, the audio capture of the preview stream will not stop until the audio in the push stream is stopped and captured successfully. Otherwise, stopping the audio capture fails.

  • Use cases: Stop capturing audio.
  • When to call: The ZegoLocalStream instance has been created with [createZegoStream].
  • Available since: 3.0.0

stopCaptureVideo

stopCaptureVideo
stopCaptureVideo(): Promise<boolean>
Stop capturing video.

Stop capturing video and destroy the playback component that is previewing the video. If it is in a push stream, the video capture of the preview stream will not stop until the video in the push stream is stopped and captured successfully. Otherwise, stopping the video capture fails..

  • Use cases: Stop capturing video.
  • When to call: The ZegoLocalStream instance has been created with [createZegoStream] and the stream has been collected and [playVideo] has been executed.
  • Related APIs: Calling [destroyStream] unmount the playback component.
  • Available since: 3.0.0

stopPlayCaptureAudio

stopPlayCaptureAudio
stopPlayCaptureAudio(): void
Stop playing the audio of the latest captured media stream.

Stop playing the audio of the latest captured media stream.

  • Use cases: Stop playing the audio of the latest captured media stream.
  • When to call: The ZegoLocalStream instance has been created with [createZegoStream] and the stream has been collected and [playCaptureAudio] has been executed.
  • Related APIs: Calling [destroyStream] also unmount the playback component.
  • Available since: 3.0.0

stopPlayCaptureVideo

stopPlayCaptureVideo
stopPlayCaptureVideo(): void
Stop the page from playing all the latest streaming videos that are being captured.

Stop the page from playing all the latest streaming videos that are being captured.

  • Use cases: The latest media streams that are being collected are not displayed on the screen.
  • When to call: The ZegoLocalStream instance has been created with [createZegoStream] and the stream has been collected and [playCaptureVideo] has been executed.
  • Related APIs: Calling [destroyStream] also unmount the playback component.
  • Available since: 3.0.0

stopVideo

stopVideo
stopVideo(): void
Stop playing the video in the stream to be pushed or being pushed.

Stop playing the video in the stream to be pushed or being pushed.

  • Use cases: Stop playing the video in the stream to be pushed or being pushed.
  • When to call: The ZegoLocalStream instance has been created with [createZegoStream] and the stream has been collected and [playVideo] has been executed.
  • Related APIs: Calling [destroyStream] unmount the playback component.
  • Available since: 3.0.0

resumeAudio

resumeAudio
resumeAudio(): void
Restore the audio that is being pushed or is being pushed on the playback page.

When video browser restrictions prevent playback, you can call this interface in the DOM click event to resume playing the video on the page.

  • Use cases: Play the audio that is to be pushed or is being streamed on the page.
  • When to call: The ZegoLocalStream instance has been created with [createZegoStream] and the stream has been collected and [playAudio] has been executed.
  • Available since: 3.0.0

resumeVideo

resumeVideo
resumeVideo(): void
Restore the video that is being pushed or is being pushed on the playback page.

When video browser restrictions prevent playback, you can call this interface in the DOM click event to resume playing the video on the page.

  • Use cases: Display media stream content on the interface.
  • When to call: The ZegoLocalStream instance has been created with [createZegoStream] and the stream has been collected and [playVideo] has been executed.
  • Available since: 3.0.0

startCaptureCamera

startCaptureCamera
startCaptureCamera(options?: ZegoCaptureCamera): ZegoServerResponse
Start capturing camera video stream.

Parameters

NameTypeDescription
optionsZegoCaptureCameraCapture camera configuration parameters.

Details

Start capturing the camera stream, and the video being pushed will not be updated synchronously. If you need to update, you can call [updatePublishingStream].

  • Use cases: Capture the camera stream to preview or update the video in the push stream.

  • When to call: After creating a ZegoLocalStream instance through [createZegoStream].

  • Related APIs: 1. After the push stream is successful, the video of the push stream needs to be updated. You can call [startCaptureCamera] successfully, and then call [updatePublishingStream] to update the microphone captured by [startCaptureCamera] to the video in the push stream. 2.Call [stopCaptureVideo] to stop the video that is currently being captured.

  1. Call [mutePublishStreamVideo] to turn on/off the stream video that is being pushed.
  • Available since: 3.0.0

startCaptureCameraAndMicrophone

startCaptureCameraAndMicrophone
startCaptureCameraAndMicrophone(cameraOptions?: ZegoCaptureCamera, microphoneOptions?: ZegoCaptureMicrophone): ZegoServerResponse
Start capturing camera and microphone stream.

Parameters

NameTypeDescription
cameraOptionsZegoCaptureCameraCapture camera configuration parameters.
microphoneOptionsZegoCaptureMicrophoneCapture microphone configuration parameters.

Details

Start capturing the camera and microphone stream, and the video or audio being pushed will not be updated synchronously. If you need to update, you can call [updatePublishingStream].

  • Use cases: Capture the camera and microphone stream to preview or update the video in the push stream.
  • When to call: After creating a ZegoLocalStream instance through [createZegoStream].
  • Related APIs: 1. After the push stream is successful, the audio and video of the push stream needs to be updated. You can call [startCaptureCameraAndMicrophone] successfully, and then call [updatePublishingStream] to update the custom video and audio captured by [startCaptureCameraAndMicrophone] to the video camera and microphone audio in the push stream. 2.Call [stopCaptureAudio] or [stopCaptureVideo] to stop the audio or video that is currently being captured.
  1. Call [mutePublishStreamAudio] or [mutePublishStreamVideo] to turn on/off the stream audio or video that is being pushed.
  • Available since: 3.0.0

startCaptureCustomAudio

startCaptureCustomAudio
startCaptureCustomAudio(options: ZegoCustomAudio): ZegoServerResponse
Start capturing custom audio stream.

Parameters

NameTypeDescription
optionsZegoCustomAudioCapture custom audio configuration parameters.

Details

Start capturing the custom audio stream, and the audio being pushed will not be updated synchronously. If you need to update, you can call [updatePublishingStream].

  • Use cases: Third-party audio streams come from the same audio capture. Capture again will cause the previous capture to stop. If the audio come from the same audio or video, it is not recommended to call [startCaptureCustomVideoAndAudio] and [startCaptureCustomAudio] multiple times.
  • When to call: After creating a ZegoLocalStream instance through [createZegoStream].
  • Related APIs: 1. After the push stream is successful, the audio of the push stream needs to be updated. You can call [startCaptureCustomAudio] successfully, and then call [updatePublishingStream] to update the custom audio captured by [startCaptureCustomAudio] to the audio in the push stream. 2.Call [stopCaptureAudio] to stop the audio that is currently being captured.
  1. Call [mutePublishStreamAudio] to turn on/off the stream audio that is being pushed.
  • Available since: 3.0.0

startCaptureCustomVideo

startCaptureCustomVideo
startCaptureCustomVideo(options: ZegoCustomVideo): ZegoServerResponse
Start capturing custom video stream.

Parameters

NameTypeDescription
optionsZegoCustomVideoCapture custom video configuration parameters.

Details

Start capturing the custom video stream, and the video being pushed will not be updated synchronously. If you need to update, you can call [updatePublishingStream].

  • Use cases: The custom audio and video stream comes from the captrue the same video. Capture again will cause the previous capture to stop. If the audio and video come from the same video, it is not recommended to call [startCaptureCustomVideoAndAudio] and [startCaptureCustomVideo] multiple times.

  • When to call: After creating a ZegoLocalStream instance through [createZegoStream].

  • Related APIs: 1. After the push stream is successful, the video of the push stream needs to be updated. You can call [startCaptureCustomVideo] successfully, and then call [updatePublishingStream] to update the custom video captured by [startCaptureCustomVideo] to the video in the push stream. 2.Call [stopCaptureVideo] to stop the video that is currently being captured.

  1. Call [mutePublishStreamVideo] to turn on/off the stream video that is being pushed.
  • Available since: 3.0.0

startCaptureCustomVideoAndAudio

startCaptureCustomVideoAndAudio
startCaptureCustomVideoAndAudio(videoOptions: ZegoCustomVideo, audioOptions: ZegoCustomAudio): ZegoServerResponse
Start capturing custom video and audio stream.

Parameters

NameTypeDescription
videoOptionsZegoCustomVideoCapture custom video configuration parameters.
audioOptionsZegoCustomAudioCapture custom audio configuration parameters.

Details

Start capturing the custom video and audio stream, and the video and audio being pushed will not be updated synchronously. If you need to update, you can call [updatePublishingStream].

  • Use cases: Third-party audio and video streams come from the same audio or video collection. Collection again will cause the previous collection to stop. If the audio and video come from the same audio or video, it is not recommended to call [startCaptureCustomVideoAndAudio], [startCaptureCustomVideo] and [startCaptureCustomAudio] multiple times.

  • When to call: After creating a ZegoLocalStream instance through [createZegoStream].

  • Related APIs: 1. After the push stream is successful, the audio and video of the push stream needs to be updated. You can call [startCaptureCustomVideoAndAudio] successfully, and then call [updatePublishingStream] to update the custom video and audio captured by [startCaptureCustomVideoAndAudio] to the audio and video in the push stream. 2.Call [stopCaptureAudio] or [stopCaptureVideo] to stop the audio or video that is currently being captured.

  1. Call [mutePublishStreamAudio] or [mutePublishStreamVideo] to turn on/off the stream audio or video that is being pushed.
  • Available since: 3.0.0

startCaptureMicrophone

startCaptureMicrophone
startCaptureMicrophone(options?: ZegoCaptureMicrophone): ZegoServerResponse
Start capturing microphone audio stream.

Parameters

NameTypeDescription
optionsZegoCaptureMicrophoneCapture microphone configuration parameters.

Details

Start capturing the microphone stream, and the audio being pushed will not be updated synchronously. If you need to update, you can call [updatePublishingStream].

  • Use cases: Capture the microphone stream to preview or update the audio in the push stream.
  • When to call: After creating a ZegoLocalStream instance through [createZegoStream].
  • Related APIs: 1. After the push stream is successful, the audio of the push stream needs to be updated. You can call [startCaptureMicrophone] successfully, and then call [updatePublishingStream] to update the microphone captured by [startCaptureMicrophone] to the audio in the push stream. 2.Call [stopCaptureAudio] to stop the audio that is currently being captured.
  1. Call [mutePublishStreamAudio] to turn on/off the stream audio that is being pushed.
  • Available since: 3.0.0

startCaptureScreen

startCaptureScreen
startCaptureScreen(options?: ZegoCaptureScreenVideo): ZegoServerResponse
Start capturing the screen sharing video stream.

Parameters

NameTypeDescription
optionsZegoCaptureScreenVideoCapture screen sharing configuration parameters.

Details

Start capturing the screen sharing video stream, and the video being pushed will not be updated synchronously. If you need to update, you can call [updatePublishingStream].

  • Use cases: Capture the screen sharing video stream to preview or update the video in the push stream.
  • When to call: After creating a ZegoLocalStream instance through [createZegoStream].
  • Related APIs: 1. After the push stream is successful, the video of the push stream needs to be updated. You can call [startCaptureScreen] successfully, and then call [updatePublishingStream] to update the screen video captured by [startCaptureScreen] to the video in the push stream.
  1. Call [mutePublishStreamVideo] to turn on/off the stream video that is being pushed.
  • Available since: 3.0.0

startCaptureScreenWithAudio

startCaptureScreenWithAudio
startCaptureScreenWithAudio(screenVideoOptions?: ZegoCaptureScreenVideo, screenAudioOptions?: ZegoCaptureScreenAudio): ZegoServerResponse
Start capturing the screen sharing video and sharing audio stream.

Parameters

NameTypeDescription
screenVideoOptionsZegoCaptureScreenVideoCapture screen sharing video configuration parameters.
screenAudioOptionsZegoCaptureScreenAudioCapture screen sharing audio configuration parameters.

Details

Start capturing the screen sharing video and sharing audio stream., and the video being pushed will not be updated synchronously. If you need to update, you can call [updatePublishingStream].

  • Use cases: Capture the screen sharing video and sharing audio stream to preview or update the video and audio in the push stream.
  • When to call: After creating a ZegoLocalStream instance through [createZegoStream].
  • Related APIs: 1. After the push stream is successful, the audio and video of the push stream needs to be updated. You can call [startCaptureScreenWithAudio] successfully, and then call [updatePublishingStream] to update the screen video and audio captured by [startCaptureScreenWithAudio] to the audio and video in the push stream.
  1. Call [mutePublishStreamAudio] or [mutePublishStreamVideo] to turn on/off the stream audio or video that is being pushed.
  • Available since: 3.0.0

getScreenDisplaySurface

getScreenDisplaySurface
getScreenDisplaySurface(): string
Get the shared content type of the screen sharing stream.
  • When to call: after create stream.

caution: This interface is currently only supported by the Chrome browser 107 above and safari 11.1 above.

Related interface: None.

  • Available since: 3.12.0

Detailed description: Get the shared content type of the screen sharing stream.

The shared content type of the screen sharing stream, 'browser' | 'window' | 'monitor'.

setVolume

setVolume
setVolume(volume: number): boolean
Set the volume at which to play the audio that is being pushed or is being streamed.

Parameters

NameTypeDescription
volumenumberVolume level, the value range is [0,100] .

Details

Set the volume at which to play the audio that is being pushed or is being streame.

  • When to call: The ZegoLocalStream instance has been created with [createZegoStream] and the stream has been collected and [playAudio] has been executed.
  • Available since: 3.0.0

Return

Whether the interface is called successfully.

useAudioOutputDevice

useAudioOutputDevice
useAudioOutputDevice(media: HTMLMediaElement, deviceID: string): Promise<boolean>
Switch the audio output device.

Parameters

NameTypeDescription
mediaHTMLMediaElementMedia tag element, <audio> or <video>.
deviceIDstringAudio output device ID.
  • When to call: after using [getSpeakers] to get the list of audio output devices.

caution: This interface is currently only supported by the Chrome browser.

Related interface: Get the speaker list interface [getSpeakers].

  • Available since: 3.8.0

Detailed description: Sets the audio output device for the html media element.

Return

Promise returns a Boolean ID indicating whether the call was successful.

on

on
on<K extends keyof ZegoLocalStreamEvent >(event: K, callback: ZegoLocalStreamEvent[K]): boolean
Register callback event.

Parameters

NameTypeDescription
eventKListener event name.
callbackZegoLocalStreamEvent[K]Callback.

Details

The interface used to handle the SDK's initiative to notify developers of callbacks. By registering different events, you can receive callbacks of different functions. The event callback that can be monitored can be viewed in ZegoLocalStreamEvent.

Use case: Callback processing for registering business events related to the functionality of the ZegoLocalStream media streaming.

Timing of calling: After calling [createZegoStream] to create the ZegoStreamView instance.

The same event can be registered multiple, the same registered event will be triggered in sequence according to the order of registration.

Related interface: call interface off to cancel the corresponding callback event processing.

Return

Whether the registration is successful.

off

off
off<K extends keyof ZegoLocalStreamEvent >(event: K, callback?: ZegoLocalStreamEvent[K]): boolean
Unregister callback events.

Parameters

NameTypeDescription
eventKListener event name.
callbackZegoLocalStreamEvent[K]Callback.

Details

Callback processing for unregistering business events related to the ZegoLocalStream media streaming function.

Use case: Callback processing for business events of the media streaming component.

call timing: After calling [createZegoStream] to create the ZegoStreamView instance.

  • Caution: If the callback function parameter [callback] to be logged off is not passed, all the callback functions of this event will be logged off.

Return

Whether the unregister was successful.

takeStreamSnapshot

takeStreamSnapshot
takeStreamSnapshot(option?: ZegoSnapshotOptions): string
Client screenshot

Parameters

NameTypeDescription
option?ZegoSnapshotOptions

Details

Get the video frame data of the currently played stream to be pushed or in the stream being pushed.

  • Use cases: Take a screenshot of the video that is currently being streamed or is being streamed.
  • When to call /Trigger: The ZegoLocalStream instance has been created with [createZegoStream] and the stream has been collected and [playVideo] has been executed.
  • Available since: 3.0.0

Return

DOMString containing the data URI

ZegoRealTimeSequentialDataManager

Realtime Sequential Data Object

Details

Real time and orderly data, relying on zego RTC service, can provide developers with real-time, orderly and high-frequency data transmission and distribution functions

Methods

startBroadcasting

startBroadcasting
startBroadcasting(streamID: string): Promise<boolean>
start Broadcasting

Parameters

NameTypeDescription
streamIDstringStreaming ID, a string of no more than 256 length, only supports numbers, English characters and'~','!','@','#','$','','^','&', '*','(',')','_','+','=','-',',';',''',',','.','<', '>','/',''

Details

Start broadcasting real-time sequential data channel.

  • Use cases: In the remote control scenario, the control end sends instructions to the controlled end.
  • Caution: Reusable RTC streaming channel.
  • When to call /Trigger: Call Interface createRealTimeSequentialDataManager Create a ZegoRealTimeSequentialDataManager.
  • Available since: 2.12.2

Return

true means that the client sends the request successfully, and the stream is successfully pushed to the server and needs to be judged through the stream status callback interface.

stopBroadcasting

stopBroadcasting
stopBroadcasting(streamID: string): boolean
stop Broadcasting

Parameters

NameTypeDescription
streamIDstringPush stream ID, consistent with broadcasting stream ID

Details

Stop broadcasting real-time sequential data channel.

  • Use cases: In the remote control scenario, the control end stops transmitting instructions to the controlled end.
  • Caution: When the RTC channel is multiplexed, stopping the broadcasting of real-time sequential data channel will not affect the RTC channel.
  • When to call /Trigger: Call Interface createRealTimeSequentialDataManager Create a ZegoRealTimeSequentialDataManager.
  • Available since: 2.12.2

Return

bool

sendRealTimeSequentialData

sendRealTimeSequentialData
sendRealTimeSequentialData(streamID: string, data: ArrayBuffer): boolean
send RealTime Sequential Data

Parameters

NameTypeDescription
streamIDstringstream ID
dataArrayBufferdata

Details

send real-time Sequential Data.

  • Use cases: In the remote control scenario, the control end sends instructions to the controlled end.
  • Caution: Data may be lost in a weak network.
  • When to call /Trigger: Call Interface createRealTimeSequentialDataManager Create a ZegoRealTimeSequentialDataManager, and call startbroadcasting API to broadcast.
  • Available since: 2.12.2

Return

bool

startSubscribing

startSubscribing
startSubscribing(streamID: string): Promise<boolean>
start Subscribing

Parameters

NameTypeDescription
streamIDstringstream ID

Details

Start broadcasting real-time sequential data channel.

  • Use cases: In the remote control scenario, the controlled end receives instructions from the control end.
  • Caution: Reusable RTC streaming channel.
  • When to call /Trigger: Call Interface createRealTimeSequentialDataManager Create a ZegoRealTimeSequentialDataManager.
  • Available since: 2.12.2

Return

bool

stopSubscribing

stopSubscribing
stopSubscribing(streamID: string): boolean
stopSubscribing

Parameters

NameTypeDescription
streamIDstringstream ID

Details

stop broadcasting real-time sequential data channel.

  • Use cases: In the remote control scenario, the controlled end stops receiving instructions from the control end.
  • Caution: When the RTC channel is multiplexed, stopping the broadcasting of real-time sequential data will not affect the RTC channe.
  • When to call /Trigger: Call Interface createRealTimeSequentialDataManager Create a ZegoRealTimeSequentialDataManager.
  • Available since: 2.12.2

Return

bool

on

on
on<K extends keyof ZegoDataChannelEvent>(event: K, callBack: ZegoDataChannelEvent[K]): void
Register callback event.

Parameters

NameTypeDescription
eventKListener event name.
callBackZegoDataChannelEvent[K]Callback.

Details

The interface used to handle the SDK's initiative to notify developers of callbacks. By registering different events, you can receive callbacks of different functions. The event callback that can be monitored can be viewed in ZegoDataChannelEvent.

Use case: Used to register the callback processing of business events related to DataChannel function.

Timing of calling: After calling the interface createRealTimeSequentialDataManagerto create the instance.

The same event can be registered multiple, the same registered event will be triggered in sequence according to the order of registration.

Related interface: call interface off to cancel the corresponding callback event processing.

Return

Whether the registration is successful.

off

off
off<K extends keyof ZegoDataChannelEvent>(event: K, callBack: ZegoDataChannelEvent[K]): void
Unregister callback events.

Parameters

NameTypeDescription
eventKListener event name.
callBackZegoDataChannelEvent[K]Callback.

Details

The interface used to handle the SDK's initiative to notify developers of callbacks. By registering different events, you can receive callbacks of different functions. The event callback that can be monitored can be viewed in ZegoDataChannelEvent.

Use case: Used to unregister the callback processing of business events related to DataChannel function.

Timing of calling: After calling the interface createRealTimeSequentialDataManagerto create the instance.

The same event can be registered multiple, the same registered event will be triggered in sequence according to the order of registration.

Related interface: call interface off to cancel the corresponding callback event processing.

Return

Whether the unregister was successful.

ZegoStreamCompositor

broadcast station

Methods

addImage

addImage
addImage(img: HTMLImageElement, option: ZegoStreamCompositorInputOption): void
Create an image layer for the broadcast station

Parameters

NameTypeDescription
imgHTMLImageElementthe input image
optionZegoStreamCompositorInputOptionProperties of the input layer

Details

Create an image layer for the broadcast station

  • Use cases: Set the display of the image on the output canvas.
  • When to call /Trigger: Calling timing: After create ZegoStreamCompositor.
  • Available since: 3.0.0

removeImage

removeImage
removeImage(img: HTMLImageElement): void
Remove an image layer for the broadcast station

Parameters

NameTypeDescription
imgHTMLImageElementthe input image

Details

Remove an image layer for the broadcast station

  • Use cases: Remove the display of the image on the output canvas.
  • When to call /Trigger: Calling timing: After create the image layer.
  • Available since: 3.0.0

setInputEndpoint

setInputEndpoint
setInputEndpoint(stream: MediaStream | ZegoLocalStream, option: ZegoStreamCompositorInputOption): Promise<void>
Create an input layer for the broadcast station

Parameters

NameTypeDescription
streamMediaStream | ZegoLocalStreamMediaStream or the ZegoLocalStream instance object created by createZegoStream
optionZegoStreamCompositorInputOptionProperties of the input layer

Details

Create an input layer for the broadcast station

  • Use cases: Set the display of the input stream on the output canvas.
  • When to call /Trigger: Calling timing: After create ZegoStreamCompositor.
  • Available since: 3.0.0

setOutputConfig

setOutputConfig
setOutputConfig(config: ZegoStreamCompositorOutputConfig): void
Set the properties of the compositor output

Parameters

NameTypeDescription
configZegoStreamCompositorOutputConfigOutput stream options

Details

Set the properties of the compositor output

  • Use cases: When you need to combine multiple video streams and pictures of local users into one video stream, such as online education, remote conferences, live broadcasts, etc., you can use the broadcast station to achieve this.
  • When to call /Trigger: Calling timing: After create ZegoStreamCompositor.
  • Available since: 3.0.0

startComposingStream

startComposingStream
startComposingStream(): Promise<MediaStream>
Start composing stream

The broadcasting station will merge the contents of all input layers and output audio and video.

  • Use cases: When you need to combine multiple video streams and pictures of local users into one video stream, such as online education, remote conferences, live broadcasts, etc., you can use the broadcast station to achieve this.
  • When to call /Trigger: Calling timing: After create ZegoStreamCompositor.
  • Available since: 3.0.0

stopComposingStream

stopComposingStream
stopComposingStream(): Promise<boolean>
Stop composing stream

The broadcasting station stop composing stream.

  • Use cases: When it is time to end the composition stream.
  • When to call /Trigger: Calling timing: After composing stream.
  • Available since: 3.0.0

ZegoStreamView

Media Stream Player Component

Details

The media stream player component class.

  • Use cases: Play the media stream on the interface.

Methods

play

play
play(container: string | HTMLElement, options?: ZegoStreamViewOptions): void
Play the audio and video of the media stream on the page.

Parameters

NameTypeDescription
containerstring | HTMLElementSpecifies a container where the SDK will create the <video> element to play the video track. The parameter value can be a DOM element object (for example, div) or the ID of the DOM element.
optionsZegoStreamViewOptionsSet playback options parameters (mirror, display mode, muted, etc.).

Details

Specify a DOM element as the container. The SDK will create a <video> element and a <audio> element under the element as needed to play the video and audio of the media stream respectively.

  • Use cases: Display media stream content on the interface.
  • When to call: After creating a ZegoStreamView instance.
  • Caution: - A ZegoStreamView playback component can only be mounted on one container through the play method, and cannot be mounted on multiple ones at the same time.
  • Due to the limitations of the browser's autoplay policy, invoking the play method without any user interaction on the page may cause playback failure. You can use the event callback [autoplayFailed] to catch the error and guide the user toplay interactive
  • Related callbacks: When calling the play interface to play a video failed, the automatic playback failure event callback [autoplayFailed]of ZegoStreamView will be triggered.
  • Related APIs: Uninstall media streaming component interface [stop] . Calling [stopPlayingStream] or [destroyStream] also unloads the playback component.
  • Available since: 2.17.0

playVideo

playVideo
playVideo(container: string | HTMLElement, options?: ZegoStreamViewOptions): void
Play videos of media streaming on the page.

Parameters

NameTypeDescription
containerstring | HTMLElementSpecifies a container where the SDK will create the <video> element to play the video track. The parameter value can be a DOM element object (for example, div) or the ID of the DOM element.
optionsZegoStreamViewOptionsSet playback options parameters (mirror, display mode, muted, etc.).

Details

Specify a DOM element as the container, and the SDK will create a media stream under the element as needed to play videos of the media stream to be pushed or pushed. Before executing the [startPublishingStream] streaming, the media playback content will synchronize the currently latest collected video content; after the streaming is successful, ZegoLocalStream calls the acquisition camera, screen share or third-party video source again, and the newly collected video will not be synchronized to the video source being pushed. If updates are required, [updatePublishingStream] needs to be called to update.

  • Use cases: Display media streaming content on the interface.
  • When to call: After creating a ZegoStreamView instance and starting to collect audio and video streams.
  • Caution: A ZegoStreamView instance can only be mounted on a container through the playVideo method, and cannot be mounted multiple times at the same time.
  • Related callbacks: Calling the [playVideo] interface will trigger the ZegoStreamView's autoplay failure event callback [autoplayFailed] when the video is failed to be played.
  • Related APIs: Stop playing media streaming interface [stopVideo]. Calling [destroyStream] will also uninstall the playback component. [playVideo] and [playAudio] are the [play] methods that differentiate and refine the playback operations of video and audio.
  • Available since: 3.8.0

playAudio

playAudio
playAudio(options?: ZegoStreamViewOptions): void
Play audio from media streams.

Parameters

NameTypeDescription
optionsZegoStreamViewOptionsSet playback options parameters.

Details

Play audio from media streams.

  • Use cases: Just want to play audio from media streams, and I don't need to play videos.
  • When to call: After creating a ZegoStreamView instance.
  • Related callbacks: Calling the [playAudio] interface to play videos fails to play [autoplayFailed] will trigger the ZegoStreamView's autoplay failure event callback [autoplayFailed].
  • Related APIs: Stop playing media streaming interface [stopAudio]. Calling [destroyStream] will also uninstall the playback component. [playVideo] and [playAudio] are the [play] methods that differentiate and refine the playback operations of video and audio.
  • Available since: 3.8.0

stop

stop
stop(): void
Stop showing audio and video on the page.

Uninstall the media streaming component to end displaying audio and video.

  • Use cases: Ends presenting the media stream content on the interface.
  • When to call: After creating a ZegoStreamView instance.
  • Related APIs: Calling [stopPlayingStream] or [destroyStream] also unmount the playback component.
  • Available since: 2.17.0

stopVideo

stopVideo
stopVideo(): void
Stop playing media streaming video.

Stop playing media streaming video.

  • Use cases: Media streaming video content is no longer necessary on the interface.
  • When to call: After creating a ZegoStreamView instance, the stream has been collected and [playVideo] has been executed.
  • Related APIs: Calling [stopPlayingStream] or [destroyStream] will also uninstall the playback component.
  • Available since: 3.8.0

stopAudio

stopAudio
stopAudio(): void
Stop playing audio from media streams.

Stop playing audio from media streams.

  • Use cases: Media streaming video content is no longer necessary on the interface.
  • When to call: After creating a ZegoStreamView instance, the stream has been collected and [playAudio] has been executed.
  • Related APIs: Calling [stopPlayingStream] or [destroyStream] will also uninstall the playback component.
  • Available since: 3.8.0

resume

resume
resume(): void
Resume playing audio and video on the page.

When video browser restrictions prevent playback, you can call this interface in the DOM click event to resume playing the audio and video on the page.

  • Use cases: Display media stream content on the interface.
  • When to call: After creating a ZegoStreamView instance.
  • Available since: 2.17.0

setAudioMuted

setAudioMuted
setAudioMuted(muted: boolean): boolean
Switch audio playback.

Parameters

NameTypeDescription
mutedbooleanWhether to disable, true means disabled, false means resume enabled.

Details

Switch audio playback.

  • Use cases: Stop or resume playing the audio of the media stream.
  • When to call: Called after the [play] method of the ZegoStreamView instance is called to mount the component.
  • Caution: This interface will only stop playing the audio of the media stream, and will not affect the audio transmission content of the media stream. You need to call the [mutePublishStreamAudio] interface to stop sending audio, and call the [mutePlayStreamAudio] interface to stop receiving audio.
  • Available since: 2.17.0

Return

Identifies whether the interface call is successful.

setVideoMuted

setVideoMuted
setVideoMuted(muted: boolean): boolean
Switch video playback.

Parameters

NameTypeDescription
mutedbooleanWhether to disable, true means disabled, false means resume enabled.

Details

Switch video playback.

  • Use cases: Stop or resume video of media stream.
  • When to call: Called after the [play] method of the ZegoStreamView instance is called to mount the component.
  • Caution: This interface will only stop playing the video of the media stream, and will not affect the video transmission content of the media stream. To stop sending videos, you need to call the [mutePublishStreamVideo] interface, and stop receiving videos and call the [mutePlayStreamVideo] interface.
  • Available since: 2.17.0

Return

Identifies whether the interface call is successful.

useAudioOutputDevice

useAudioOutputDevice
useAudioOutputDevice(deviceID: string): Promise<void>
Switch the audio output device.

Parameters

NameTypeDescription
deviceIDstringAudio output device ID.
  • When to call: after using [getSpeakers] to get the list of audio output devices.

caution: This interface is currently only supported by the Chrome browser.

Related interface: Get the speaker list interface [getSpeakers].

setVolume

setVolume
setVolume(volume: number): boolean
Set the audio playback volume.

Parameters

NameTypeDescription
volumenumberVolume level, the value range is [0,100] .

Details

Set the audio playback volume.

  • When to call: After creating a ZegoStreamView instance.
  • Caution: Setting the volume to 0 in Safari may not work, so you can use setAudioMuted to mute the audio.
  • Available since: 2.17.0

Return

Whether the interface is called successfully.

on

on
on<K extends keyof StreamViewEvent >(event: K, callback: StreamViewEvent[K]): boolean
Register callback event.

Parameters

NameTypeDescription
eventKListener event name.
callbackStreamViewEvent[K]Callback.

Details

The interface used to handle the SDK's initiative to notify developers of callbacks. By registering different events, you can receive callbacks of different functions. The event callback that can be monitored can be viewed in StreamViewEvent.

Use case: Callback processing for registering business events related to the function of the media stream component.

Timing of calling: After creating the ZegoStreamView instance.

The same event can be registered multiple, the same registered event will be triggered in sequence according to the order of registration.

Related interface: call interface off to cancel the corresponding callback event processing.

Return

Whether the registration is successful.

off

off
off<K extends keyof StreamViewEvent >(event: K, callback?: StreamViewEvent[K]): boolean
Unregister callback events.

Parameters

NameTypeDescription
eventKListener event name.
callbackStreamViewEvent[K]Callback.

Details

The interface used to handle the SDK's initiative to notify developers of callbacks. By registering different events, you can receive callbacks of different functions. Used to delete the registered callback event of the same type.

Use case: Callback processing for business events of the media streaming component.

call timing: After the zegostreamview instance is created.

  • Caution: If the callback function parameter [callback] to be logged off is not passed, all the callback functions of this event will be logged off.

Return

Whether the unregister was successful.

takeStreamSnapshot

takeStreamSnapshot
takeStreamSnapshot(option?: ZegoSnapshotOptions): string
Client screenshot

Parameters

NameTypeDescription
option?ZegoSnapshotOptions

Details

get the currently rendered video frame data

  • Use cases: Take a screenshot of the currently (push/pull) rendered video screen.
  • When to call /Trigger: After call view.play.
  • Available since: 2.18.0

Return

DOMString containing the data URI

Previous

Function Overview

Next

Interface