logo
On this page

Class

ZegoAudioEffectPlayerZegoCopyrightedMusic
ZegoExpressEngineZegoMediaPlayer
ZegoScreenCaptureSource

ZegoAudioEffectPlayer

Declared in ZegoExpressAudioEffectPlayer.js

Methods

start

start
start(audioEffectID: number, path?: string, config?: ZegoAudioEffectPlayConfig): void
Start playing audio effect.
Declared in ZegoExpressAudioEffectPlayer.js

Parameters

NameTypeDescription
audioEffectIDnumberDescription: ID for the audio effect. The SDK uses audioEffectID to control the playback of sound effects. The SDK does not force the user to pass in this parameter as a fixed value. It is best to ensure that each sound effect can have a unique ID. The recommended methods are static self-incrementing ID or the hash of the incoming sound effect file path.
pathstringThe absolute path of the local resource. <br>Value range: "assets://"、"ipod-library://" and network url are not supported. Set path as nil or "" if resource is loaded already using [loadResource].
configZegoAudioEffectPlayConfigAudio effect playback configuration. <br>Default value: Set NULL will only be played once, and will not be mixed into the publishing stream.

Details

Start playing audio effect. The default is only played once and is not mixed into the publishing stream, if you want to change this please modify [config] param.

  • Use cases: When you need to play short sound effects, such as applause, cheers, etc., you can use this interface to achieve, and further configure the number of plays through the [config] parameter, and mix the sound effects into the push stream.
  • When to call: It can be called after [createAudioEffectPlayer].
  • Available since: 1.16.0
  • Restrictions: None.

stop

stop
stop(audioEffectID: number): void
Stop playing audio effect.
Declared in ZegoExpressAudioEffectPlayer.js

Parameters

NameTypeDescription
audioEffectIDnumberID for the audio effect.

Details

Stop playing the specified audio effect [audioEffectID].

  • When to call: The specified [audioEffectID] is [start].
  • Available since: 1.16.0
  • Restrictions: None.

pause

pause
pause(audioEffectID: number): void
Pause playing audio effect.
Declared in ZegoExpressAudioEffectPlayer.js

Parameters

NameTypeDescription
audioEffectIDnumberID for the audio effect.

Details

Pause playing the specified audio effect [audioEffectID].

  • When to call: The specified [audioEffectID] is [start].
  • Available since: 1.16.0
  • Restrictions: None.

resume

resume
resume(audioEffectID: number): void
Resume playing audio effect.
Declared in ZegoExpressAudioEffectPlayer.js

Parameters

NameTypeDescription
audioEffectIDnumberID for the audio effect.

Details

Resume playing the specified audio effect [audioEffectID].

  • When to call: The specified [audioEffectID] is [pause].
  • Available since: 1.16.0
  • Restrictions: None.

stopAll

stopAll
stopAll(): void
Stop playing all audio effect.
Declared in ZegoExpressAudioEffectPlayer.js

Stop playing all audio effect.

  • When to call: Some audio effects are Playing.
  • Available since: 1.16.0
  • Restrictions: None.

pauseAll

pauseAll
pauseAll(): void
Pause playing all audio effect.
Declared in ZegoExpressAudioEffectPlayer.js

Pause playing all audio effect.

  • When to call: It can be called after [createAudioEffectPlayer].
  • Available since: 1.16.0
  • Restrictions: None.

resumeAll

resumeAll
resumeAll(): void
Resume playing all audio effect.
Declared in ZegoExpressAudioEffectPlayer.js

Resume playing all audio effect.

  • When to call: It can be called after [pauseAll].
  • Available since: 1.16.0
  • Restrictions: None.

seekTo

seekTo
seekTo(audioEffectID: number, millisecond: number): Promise<Object>
Set the specified playback progress.
Declared in ZegoExpressAudioEffectPlayer.js

Parameters

NameTypeDescription
audioEffectIDnumberID for the audio effect.
millisecondnumberPoint in time of specified playback progress.

Details

Set the specified audio effect playback progress. Unit is millisecond.

  • When to call: The specified [audioEffectID] is[start], and not finished.
  • Available since: 1.16.0
  • Restrictions: None.

Return

The result of seek.

setVolume

setVolume
setVolume(audioEffectID: number, volume: number): void
Set volume for a single audio effect. Both the local play volume and the publish volume are set.
Declared in ZegoExpressAudioEffectPlayer.js

Parameters

NameTypeDescription
audioEffectIDnumberID for the audio effect.
volumenumberVolume. <br>Value range: The range is 0 ~ 200. <br>Default value: The default is 100.

Details

Set volume for a single audio effect. Both the local play volume and the publish volume are set.

  • When to call: The specified [audioEffectID] is [start].
  • Available since: 1.16.0
  • Restrictions: None.

setVolumeAll

setVolumeAll
setVolumeAll(volume: number): void
Set volume for all audio effect. Both the local play volume and the publish volume are set.
Declared in ZegoExpressAudioEffectPlayer.js

Parameters

NameTypeDescription
volumenumberVolume. <br>Value range: The range is 0 ~ 200. <br>Default value: The default is 100.

Details

Set volume for all audio effect. Both the local play volume and the publish volume are set.

  • When to call: It can be called after [createAudioEffectPlayer].
  • Available since: 1.16.0
  • Restrictions: None.

setPlaySpeed

setPlaySpeed
setPlaySpeed(audioEffectID: number, speed: number): void
Set the playback speed for a given audio effect. Both the local play speed and the publish speed are set. (separate settings are not supported).
Declared in ZegoExpressAudioEffectPlayer.js

Parameters

NameTypeDescription
audioEffectIDnumberID for the audio effect.
speednumberThe speed of play. <br>Value range: The range is 0.5 ~ 2.0. <br>Default value: The default is 1.0.

Details

Set the playback speed for a given audio effect. Both the local play speed and the publish speed are set. (separate settings are not supported).

  • When to call: The specified [audioEffectID] is [start].
  • Available since: 2.18.0
  • Restrictions: None.

getTotalDuration

getTotalDuration
getTotalDuration(audioEffectID: number): number
Get the total duration of the specified audio effect resource.
Declared in ZegoExpressAudioEffectPlayer.js

Parameters

NameTypeDescription
audioEffectIDnumberID for the audio effect.

Details

Get the total duration of the specified audio effect resource. Unit is millisecond.

  • When to call: You should invoke this function after the audio effect resource already loaded, otherwise the return value is 0.
  • Related APIs: [start], [loadResource].
  • Available since: 1.16.0
  • Restrictions: It can be called after [createAudioEffectPlayer].

Return

The total duration of audio effect resource. Unit is millisecond.

getCurrentProgress

getCurrentProgress
getCurrentProgress(audioEffectID: number): number
Get current playback progress.
Declared in ZegoExpressAudioEffectPlayer.js

Parameters

NameTypeDescription
audioEffectIDnumberID for the audio effect.

Details

Get current playback progress of the specified audio effect. Unit is millisecond.

  • When to call: You should invoke this function after the audio effect resource already loaded, otherwise the return value is 0.
  • Related APIs: [start], [loadResource].
  • Available since: 1.16.0
  • Restrictions: None.

Return

Current playback progress.

loadResource

loadResource
loadResource(audioEffectID: number, path: string): Promise<Object>
Load audio effect resource.
Declared in ZegoExpressAudioEffectPlayer.js

Parameters

NameTypeDescription
audioEffectIDnumberID for the audio effect.
pathstringthe absolute path of the audio effect resource and cannot be nil or "". <br>Value range: "assets://"、"ipod-library://" and network url are not supported.

Details

Load audio effect resource.

  • Use cases: In a scene where the same sound effect is played frequently, the SDK provides the function of preloading the sound effect file into the memory in order to optimize the performance of repeatedly reading and decoding the file.
  • When to call: It can be called after [createAudioEffectPlayer].
  • Available since: 1.16.0
  • Restrictions: Preloading supports loading up to 15 sound effect files at the same time, and the duration of the sound effect files cannot exceed 30s, otherwise an error will be reported when loading.

Return

load audio effect resource result.

unloadResource

unloadResource
unloadResource(audioEffectID: number): void
Unload audio effect resource.
Declared in ZegoExpressAudioEffectPlayer.js

Parameters

NameTypeDescription
audioEffectIDnumberID for the audio effect loaded.

Details

Unload the specified audio effect resource.

  • When to call: After the sound effects are used up, related resources can be released through this function; otherwise, the SDK will release the loaded resources when the AudioEffectPlayer instance is destroyed.
  • Related APIs: [loadResource].
  • Available since: 1.16.0
  • Restrictions: None.

getIndex

getIndex
getIndex(): number
Get audio effect player index.
Declared in ZegoExpressAudioEffectPlayer.js

Get audio effect player index.

  • When to call: It can be called after [createAudioEffectPlayer].
  • Available since: 1.16.0
  • Restrictions: None.

Audio effect player index.

onAudioEffectPlayStateUpdate

onAudioEffectPlayStateUpdate
onAudioEffectPlayStateUpdate(audioEffectID: number, state: ZegoAudioEffectPlayState, errorCode: number): void
Audio effect playback state callback.
Declared in ZegoExpressAudioEffectPlayer.js

Parameters

NameTypeDescription
audioEffectIDnumberThe ID of the audio effect resource that triggered this callback.
stateZegoAudioEffectPlayStateThe playback state of the audio effect.
errorCodenumberError code, please refer to the error codes document https://docs.zegocloud.com/en/5548.html for details.

Details

This callback is triggered when the playback state of a audio effect of the audio effect player changes.

  • Trigger: This callback is triggered when the playback status of the audio effect changes.
  • Available since: 1.16.0
  • Restrictions: None.

ZegoCopyrightedMusic

Declared in ZegoExpressCopyrightedMusic.js

Methods

initCopyrightedMusic

initCopyrightedMusic
initCopyrightedMusic(config: ZegoCopyrightedMusicConfig): Promise<Object>
Initialize the copyrighted music module.
Declared in ZegoExpressCopyrightedMusic.js

Parameters

NameTypeDescription
configZegoCopyrightedMusicConfigthe copyrighted music configuration.

Details

Initialize the copyrighted music so that you can use the function of the copyrighted music later.

  • When to call: After call [createCopyrightedMusic] and [loginRoom].
  • Caution: 1. The real user information must be passed in, otherwise the song resources cannot be obtained for playback. 2. The user ID set when initializing copyrighted music needs to be the same as the user ID set when logging in to the room.
  • Available since: 2.13.0

Return

Callback for copyrighted music init.

getCacheSize

getCacheSize
getCacheSize(): number
Get cache size.
Declared in ZegoExpressCopyrightedMusic.js

When using this module, some cache files may be generated, and the size of the cache file can be obtained through this interface. Use case: Used to display the cache size of the App.

  • When to call: After initializing the copyrighted music [createCopyrightedMusic].
  • Available since: 2.13.0

Get cache size.

clearCache

clearCache
clearCache(): void
Clear cache.
Declared in ZegoExpressCopyrightedMusic.js

When using this module, some cache files may be generated, which can be cleared through this interface. Use case: Used to clear the cache of the App.

  • When to call: After initializing the copyrighted music [createCopyrightedMusic].
  • Available since: 2.13.0

sendExtendedRequest

sendExtendedRequest
sendExtendedRequest(command: string, params: string): Promise<Object>
Send extended feature request.
Declared in ZegoExpressCopyrightedMusic.js

Parameters

NameTypeDescription
commandstringrequest command, details about the commands supported.
paramsstringrequest parameters, each request command has corresponding request parameters.

Details

Initialize the copyrighted music so that you can use the function of the copyrighted music later. Use case: Used to get a list of songs.

  • When to call: After initializing the copyrighted music success [initCopyrightedMusic].
  • Available since: 2.13.0

Return

Send the extension function to request the result callback.

getLrcLyricWithVendorID

getLrcLyricWithVendorID
getLrcLyricWithVendorID(songID: string, vendorID: ZegoCopyrightedMusicVendorID): Promise<Object>
Get lyrics in lrc format.
Declared in ZegoExpressCopyrightedMusic.js

Parameters

NameTypeDescription
songIDstringthe ID of the song or accompaniment, the song and accompaniment of a song share the same ID.
vendorIDZegoCopyrightedMusicVendorIDCopyright music resource song copyright provider.

Details

Get lyrics in lrc format, support parsing lyrics line by line. Use case: Used to display lyrics line by line.

  • When to call: After initializing the copyrighted music success [initCopyrightedMusic].
  • Available since: 3.2.1

Return

Get lrc format lyrics complete callback.

getLrcLyricWithConfig

getLrcLyricWithConfig
getLrcLyricWithConfig(config: ZegoCopyrightedMusicGetLyricConfig): Promise<Object>
Get lyrics in lrc format.
Declared in ZegoExpressCopyrightedMusic.js

Parameters

NameTypeDescription
configZegoCopyrightedMusicGetLyricConfigThe configuration of get lyric.

Details

Get lyrics in lrc format, support parsing lyrics line by line. Use case: Used to display lyrics line by line.

  • When to call: After initializing the copyrighted music success [initCopyrightedMusic].
  • Available since: 3.12.0

Return

Get lrc format lyrics complete callback.

getKrcLyricByToken

getKrcLyricByToken
getKrcLyricByToken(krcToken: string): Promise<Object>
Get lyrics in krc format.
Declared in ZegoExpressCopyrightedMusic.js

Parameters

NameTypeDescription
krcTokenstringThe krcToken obtained when calling [requestResource] for accompaniment or climax clips, or when obtaining shared resources through the [getSharedResource] interface. For more details, please refer to /online-ktv-ios/client-api/apis-to-obtain-songs-and-lyrics#2_2

Details

Get verbatim lyrics, support parsing lyrics word by word. Use case: Used to display lyrics word by word.

  • When to call: After initializing the copyrighted music success [initCopyrightedMusic].
  • Available since: 2.13.0

Return

Get verbatim lyrics complete callback.

requestResource

requestResource
requestResource(config: ZegoCopyrightedMusicRequestConfig, type: ZegoCopyrightedMusicResourceType): Promise<Object>
Request music resource.
Declared in ZegoExpressCopyrightedMusic.js

Parameters

NameTypeDescription
configZegoCopyrightedMusicRequestConfigThe configuration of requesting music resource.
typeZegoCopyrightedMusicResourceTypeThe resource type of music.

Details

In addition to obtaining the basic information of the song (duration, song name, singer, etc.), and the most important resource id that can be used for local playback, there are also some related authentications information. Use case: Get copyrighted songs for local playback and sharing.

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

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

    1. Each resource has a unique resource ID.
    2. Every time this API is called, it will be billed once, please consult ZEGO business personnel for details.
    3. Each resource has a unique resource ID. The resources obtained by calling this API are time-sensitive, the valid duration is the minimum value between the SDK life cycle and 24-hour.
  • Available since: 3.0.2

Return

Callback of requesting music resource.

requestResourceWithConfigV2

requestResourceWithConfigV2
requestResourceWithConfigV2(config: ZegoCopyrightedMusicRequestConfigV2): Promise<Object>
Request music resource.
Declared in ZegoExpressCopyrightedMusic.js

Parameters

NameTypeDescription
configZegoCopyrightedMusicRequestConfigV2The configuration of requesting music resource.

Details

In addition to obtaining the basic information of the song (duration, song name, singer, etc.), and the most important resource id that can be used for local playback, there are also some related authentications information. Use case: Get copyrighted songs for local playback and sharing.

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

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

    1. Each resource has a unique resource ID.
    2. Every time this API is called, it will be billed once, please consult ZEGO business personnel for details.
    3. Each resource has a unique resource ID. The resources obtained by calling this API are time-sensitive, the valid duration is the minimum value between the SDK life cycle and 24-hour.
  • Available since: 3.12.0

Return

Callback of requesting music resource.

getSharedResource

getSharedResource
getSharedResource(config: ZegoCopyrightedMusicGetSharedConfig, type: ZegoCopyrightedMusicResourceType): Promise<Object>
Get shared music resource.
Declared in ZegoExpressCopyrightedMusic.js

Parameters

NameTypeDescription
configZegoCopyrightedMusicGetSharedConfigThe configuration of getting shared music resource.
typeZegoCopyrightedMusicResourceTypeThe resource type of music.

Details

In addition to obtaining the basic information of the song (duration, song name, singer, etc.), and the most important resource id that can be used for local playback, there are also some related authentications information. Use case: Get copyrighted songs for local playback.

  • Related APIs: After a user in the room calls the [requestresource] interface to request a music resource successfully, other users in the room can call this interface to get the music resource for free once.
  • When to call: After initializing the copyrighted music [initCopyrightedMusic]. Each resource has a unique resource ID. The resources obtained by calling this API are time-sensitive, the valid duration is the minimum value between the SDK life cycle and 24-hour.
  • Available since: 3.0.2

Return

Callback of getting shared music resource.

getSharedResourceWithConfigV2

getSharedResourceWithConfigV2
getSharedResourceWithConfigV2(config: ZegoCopyrightedMusicGetSharedConfigV2): Promise<Object>
Get shared music resource.
Declared in ZegoExpressCopyrightedMusic.js

Parameters

NameTypeDescription
configZegoCopyrightedMusicGetSharedConfigV2The configuration of getting shared music resource.

Details

In addition to obtaining the basic information of the song (duration, song name, singer, etc.), and the most important resource id that can be used for local playback, there are also some related authentications information. Use case: Get copyrighted songs for local playback.

  • Related APIs: After a user in the room calls the [requestresource] interface to request a music resource successfully, other users in the room can call this interface to get the music resource for free once.
  • When to call: After initializing the copyrighted music [initCopyrightedMusic]. Each resource has a unique resource ID. The resources obtained by calling this API are time-sensitive, the valid duration is the minimum value between the SDK life cycle and 24-hour.
  • Available since: 3.12.0

Return

Callback of getting shared music resource.

download

download
download(resourceID: string): Promise<Object>
Download music resource.
Declared in ZegoExpressCopyrightedMusic.js

Parameters

NameTypeDescription
resourceIDstringthe resource ID corresponding to the song or accompaniment.

Details

Download music resource. It can only be played after downloading successfully. Use case: After obtaining the music resource authorization, use this interface to download the corresponding resources.

  • When to call: After initializing the copyrighted music success [initCopyrightedMusic].
  • Caution: Downloading copyrighted music resources is affected by the Internet.
  • Available since: 2.13.0

Return

Callback for download song or accompaniment.

queryCacheWithConfig

queryCacheWithConfig
queryCacheWithConfig(config: ZegoCopyrightedMusicQueryCacheConfig): boolean
Query the resource's cache is existed or not.
Declared in ZegoExpressCopyrightedMusic.js

Parameters

NameTypeDescription
configZegoCopyrightedMusicQueryCacheConfigThe configuration of querying cache.

Details

Query the resource is existed or not, query the Yinsuda resource cache by default Use case: Can be used to check the resource's cache is existed or not

  • When to call: After initializing the copyrighted music success [initCopyrightedMusic].
  • Available since: 3.9.0

Return

The resource's cache is existed or not.

queryCacheWithConfigV2

queryCacheWithConfigV2
queryCacheWithConfigV2(config: ZegoCopyrightedMusicQueryCacheConfigV2): boolean
Query the resource's cache is existed or not.
Declared in ZegoExpressCopyrightedMusic.js

Parameters

NameTypeDescription
configZegoCopyrightedMusicQueryCacheConfigV2The configuration of querying cache.

Details

Query the resource is existed or not, query the Yinsuda resource cache by default Use case: Can be used to check the resource's cache is existed or not

  • When to call: After initializing the copyrighted music success [initCopyrightedMusic].
  • Available since: 3.12.0

Return

The resource's cache is existed or not.

getDuration

getDuration
getDuration(resourceID: string): number
Get the playing time of a song or accompaniment file.
Declared in ZegoExpressCopyrightedMusic.js

Parameters

NameTypeDescription
resourceIDstringthe resource ID corresponding to the song or accompaniment.

Details

Get the playing time of a song or accompaniment file. Use case: Can be used to display the playing time information of the song or accompaniment on the view.

  • When to call: After initializing the copyrighted music success [initCopyrightedMusic].
  • Available since: 2.13.0

Return

The playing time of a song or accompaniment file.

setScoringLevel

setScoringLevel
setScoringLevel(level: number): void
Set the difficulty level of scoring.
Declared in ZegoExpressCopyrightedMusic.js

Parameters

NameTypeDescription
levelnumberThe difficulty level of scoring. The level ranges from 0 to 4. The scoring difficulty decreases from 0 to 4.

Details

Users can set the scoring difficulty level through this function.

  • When to call: After calling [initCopyrightedMusic] to initialize copyrighted music successfully, call [startScore] to start scoring.
  • Default value: When this function is not called, the difficulty level of scoring is 4.
  • Available since: 2.22.0
  • Restrictions: This function does not support dynamic settings. After calling this function successfully, the next call to [startScore] will take effect.

startScore

startScore
startScore(resourceID: string, pitchValueInterval: number): number
Start scoring.
Declared in ZegoExpressCopyrightedMusic.js

Parameters

NameTypeDescription
resourceIDstringthe resource ID corresponding to the accompaniment or accompaniment clip.
pitchValueIntervalnumberthe time interval of real-time pitch line callback, in milliseconds, the default is 50 milliseconds.

Details

Start the scoring function.After starting scoring, the scoring result OnCurrentPitchValueUpdate callback will be received according to the set callback time interval. Use case: Can be used to display the singing score on the view.

  • When to call: After obtaining verbatim lyrics and playing the accompaniment resources of copyrighted music.
  • Available since: 2.15.0
  • Restrictions: Only support use this api after [startPublishingStream].

Return

Error code.

pauseScore

pauseScore
pauseScore(resourceID: string): number
Pause scoring.
Declared in ZegoExpressCopyrightedMusic.js

Parameters

NameTypeDescription
resourceIDstringthe resource ID corresponding to the accompaniment or accompaniment clip.

Details

Pause ongoing scoring,will stop the [OnCurrentPitchValueUpdate] callback. Use case: You can call this interface to pause the scoring function while scoring.

  • When to call: It can be called while grading.
  • Available since: 2.15.0

Return

Error code.

resumeScore

resumeScore
resumeScore(resourceID: string): number
Resume scoring.
Declared in ZegoExpressCopyrightedMusic.js

Parameters

NameTypeDescription
resourceIDstringthe resource ID corresponding to the accompaniment or accompaniment clip.

Details

Resume currently paused scoring. Use case: When there is currently paused scoring, this interface can be called to resume the scoring function.

  • When to call: It can be called when there is currently a paused scoring.
  • Available since: 2.15.0

Return

Error code.

stopScore

stopScore
stopScore(resourceID: string): number
Stop scoring.
Declared in ZegoExpressCopyrightedMusic.js

Parameters

NameTypeDescription
resourceIDstringthe resource ID corresponding to the accompaniment or accompaniment clip.

Details

End the current rating.The [OnCurrentPitchValueUpdate] callback will be stopped, but the average or total score can still be obtained normally. Use case: You can call this interface to end the scoring while scoring.

  • When to call: It can be called while grading.
  • Available since: 2.15.0

Return

Error code.

resetScore

resetScore
resetScore(resourceID: string): number
Reset scoring.
Declared in ZegoExpressCopyrightedMusic.js

Parameters

NameTypeDescription
resourceIDstringthe resource ID corresponding to the accompaniment or accompaniment clip.

Details

Reset the scores that have already been performed,The [OnCurrentPitchValueUpdate] callback will be stopped and the average or total score will be 0. Use case: Often used in scenes where the same song is re-sung.

  • When to call: It can be called after scoring has been performed.
  • Available since: 2.15.0

Return

Error code.

getPreviousScore

getPreviousScore
getPreviousScore(resourceID: string): number
Get the score of the previous sentence.
Declared in ZegoExpressCopyrightedMusic.js

Parameters

NameTypeDescription
resourceIDstringthe resource ID corresponding to the accompaniment or accompaniment clip.

Details

Get the score of the previous sentence. Use case: 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 accompaniment clip and starting to score.
  • Available since: 2.15.0

Return

The score of the previous sentence.

getAverageScore

getAverageScore
getAverageScore(resourceID: string): number
Get average score.
Declared in ZegoExpressCopyrightedMusic.js

Parameters

NameTypeDescription
resourceIDstringthe resource ID corresponding to the accompaniment or accompaniment clip.

Details

Get the average score. Use case: Can be used to display the average score on the view.

  • When to call: It can be called after playing the copyright accompaniment or accompaniment clip and starting to score.
  • Available since: 2.15.0

Return

Average score.

getTotalScore

getTotalScore
getTotalScore(resourceID: string): number
Get total score .
Declared in ZegoExpressCopyrightedMusic.js

Parameters

NameTypeDescription
resourceIDstringthe resource ID corresponding to the accompaniment or accompaniment clip.

Details

Get the total score. Use case: Can be used to display the total score on the view.

  • When to call: It can be called after playing the copyright accompaniment or accompaniment clip and starting to score.
  • Available since: 2.15.0

Return

Total score.

getFullScore

getFullScore
getFullScore(resourceID: string): number
Get full score .
Declared in ZegoExpressCopyrightedMusic.js

Parameters

NameTypeDescription
resourceIDstringthe resource ID corresponding to the accompaniment or accompaniment clip.

Details

Get the full score. Use case: Can be used to display the full score on the view.

  • When to call: It can be called after playing the copyright accompaniment or accompaniment clip and starting to score.
  • Available since: 3.0.2

Return

Full score.

getStandardPitch

getStandardPitch
getStandardPitch(resourceID: string): Promise<Object>
Get standard pitch data.
Declared in ZegoExpressCopyrightedMusic.js

Parameters

NameTypeDescription
resourceIDstringthe resource ID corresponding to the accompaniment or accompaniment clip.

Details

Get standard pitch data. Use case: Can be used to display standard pitch lines on the view.

  • Caution: Only accompaniment or climactic clip assets have pitch lines.
  • Available since: 2.15.0

Return

Get standard pitch data complete callback.

getCurrentPitch

getCurrentPitch
getCurrentPitch(resourceID: string): number
Get real-time pitch data.
Declared in ZegoExpressCopyrightedMusic.js

Parameters

NameTypeDescription
resourceIDstringthe resource ID corresponding to the song or accompaniment.

Details

Get real-time pitch data. Use case: Can be used to display real-time pitch lines on the view.

  • When to call: It can be called after playing the copyright accompaniment or accompaniment clip and starting to score.
  • Available since: 2.15.0

Return

Real-time pitch data.

requestSong

requestSong
deprecated
requestSong(config: ZegoCopyrightedMusicRequestConfig): Promise<Object>
[Deprecated] Request a song. Deprecated since 3.0.2, please use the [requestResource] function instead.
Declared in ZegoExpressCopyrightedMusic.js

Parameters

NameTypeDescription
configZegoCopyrightedMusicRequestConfigrequest configuration.

Details

By requesting a song, you can not only obtain basic information about a song (such as duration, song name, and artist), but also obtain the resource ID for local playback, share_token for sharing with others, and related authentication information. Support by the time, by the user monthly, by the room monthly subscription three ways. Use case: Get copyrighted songs for local playback and sharing.

  • When to call: After initializing the copyrighted music success [initCopyrightedMusic].
  • Caution: This interface will trigger billing. A song may have three sound qualities: normal, high-definition, and lossless. Each sound quality has a different resource file, and each resource file has a unique resource ID.
  • Available since: 2.13.0
Deprecated
Deprecated since 3.0.2, please use the [requestResource] function instead.

Return

Callback for request song.

requestAccompaniment

requestAccompaniment
deprecated
requestAccompaniment(config: ZegoCopyrightedMusicRequestConfig): Promise<Object>
[Deprecated] Request accompaniment. Deprecated since 3.0.2, please use the [requestResource] function instead.
Declared in ZegoExpressCopyrightedMusic.js

Parameters

NameTypeDescription
configZegoCopyrightedMusicRequestConfigrequest configuration.

Details

You can get the accompaniment resources of the song corresponding to the songID, including resource_id, krc_token, share_token, etc. Supports click-by-point accompaniment. Use case: Get copyrighted accompaniment for local playback and sharing.

  • When to call: After initializing the copyrighted music success [initCopyrightedMusic].
  • Caution: This interface will trigger billing.
  • Available since: 2.13.0
Deprecated
Deprecated since 3.0.2, please use the [requestResource] function instead.

Return

Callback for request accompaniment.

requestAccompanimentClip

requestAccompanimentClip
deprecated
requestAccompanimentClip(config: ZegoCopyrightedMusicRequestConfig): Promise<Object>
[Deprecated] Request accompaniment clip. Deprecated since 3.0.2, please use the [requestResource] function instead.
Declared in ZegoExpressCopyrightedMusic.js

Parameters

NameTypeDescription
configZegoCopyrightedMusicRequestConfigrequest configuration.

Details

You can get the accompaniment clip resources of the song corresponding to the songID, including resource_id, krc_token, share_token, etc. Supports accompaniment clips by pay-per-use. Use case: Get copyrighted accompaniment clip for local playback and sharing.

  • When to call: After initializing the copyrighted music success [initCopyrightedMusic].
  • Caution: This interface will trigger billing.
  • Available since: 2.13.0
Deprecated
Deprecated since 3.0.2, please use the [requestResource] function instead.

Return

Callback for request accompaniment clip.

getMusicByToken

getMusicByToken
deprecated
getMusicByToken(shareToken: string): Promise<Object>
[Deprecated] Get a song or accompaniment. Deprecated since 3.0.2, please use the [getSharedResource] function instead.
Declared in ZegoExpressCopyrightedMusic.js

Parameters

NameTypeDescription
shareTokenstringaccess the corresponding authorization token for a song or accompaniment.

Details

After the user successfully obtains the song/accompaniment/accompaniment clip resource, he can get the corresponding shareToken, share the shareToken with other users, and other users call this interface to obtain the shared music resources. Use case: In the online KTV scene, after receiving the song or accompaniment token shared by the lead singer, the chorus obtains the corresponding song or accompaniment through this interface, and then plays it on the local end.

  • When to call: After initializing the copyrighted music success [initCopyrightedMusic].
  • Available since: 2.13.0
Deprecated
Deprecated since 3.0.2, please use the [getSharedResource] function instead.

Return

Callback for acquire songs or accompaniment through authorization token.

getLrcLyric

getLrcLyric
deprecated
getLrcLyric(songID: string): Promise<Object>
[Deprecated] Get lyrics in lrc format. Deprecated since 3.2.1, please use the method [getLrcLyricWithVendorID].
Declared in ZegoExpressCopyrightedMusic.js

Parameters

NameTypeDescription
songIDstringthe ID of the song or accompaniment, the song and accompaniment of a song share the same ID.

Details

Get lyrics in lrc format, support parsing lyrics line by line. Use case: Used to display lyrics line by line.

  • When to call: After initializing the copyrighted music success [initCopyrightedMusic].
  • Available since: 2.13.0
Deprecated
Deprecated since 2.14.0, please use the method [getLrcLyricWithVendorID].

Return

Get lrc format lyrics complete callback.

queryCache

queryCache
deprecated
queryCache(songID: string, type: ZegoCopyrightedMusicType): boolean
[Deprecated] Query the resource's cache is existed or not. Deprecated since 3.2.1, please use the method [queryCacheWithVendorID].
Declared in ZegoExpressCopyrightedMusic.js

Parameters

NameTypeDescription
songIDstringthe ID of the song or accompaniment, the song and accompaniment of a song share the same ID.
typeZegoCopyrightedMusicTypethe song resource type.

Details

Query the resource is existed or not. Use case: Can be used to check the resource's cache is existed or not

  • When to call: After initializing the copyrighted music success [initCopyrightedMusic].
  • Available since: 2.13.0
Deprecated
Deprecated since 3.2.1, please use the method [queryCacheWithVendorID].

Return

The resource's cache is existed or not.

queryCacheWithVendorID

queryCacheWithVendorID
deprecated
queryCacheWithVendorID(songID: string, type: ZegoCopyrightedMusicType, vendorID: ZegoCopyrightedMusicVendorID): boolean
[Deprecated] Query the resource's cache is existed or not. Deprecated since 3.9.0, please use the method [queryCacheWithConfig] with the name with [config] parameter instead.
Declared in ZegoExpressCopyrightedMusic.js

Parameters

NameTypeDescription
songIDstringthe ID of the song or accompaniment, the song and accompaniment of a song share the same ID.
typeZegoCopyrightedMusicTypethe song resource type.
vendorIDZegoCopyrightedMusicVendorIDCopyright music resource song copyright provider.

Details

Query the resource is existed or not, query the Yinsuda resource cache by default Use case: Can be used to check the resource's cache is existed or not

  • When to call: After initializing the copyrighted music success [initCopyrightedMusic].
  • Available since: 3.2.1
Deprecated
Deprecated since 3.9.0, please use the method [queryCacheWithConfig] with the name with [config] parameter instead.

Return

The resource's cache is existed or not.

ZegoExpressEngine

Declared in ZegoExpressEngine.js

Methods

createEngine

static
createEngine
createEngine(profile: ZegoEngineProfile): Promise<Object>
Create ZegoExpressEngine singleton object and initialize SDK.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
profileZegoEngineProfileThe basic configuration information is used to create the engine.

Details

Create ZegoExpressEngine singleton object and initialize SDK.

  • When to call: The engine needs to be created before calling other functions.
  • Caution: The SDK only supports the creation of one instance of ZegoExpressEngine. If you need call [createEngine] multiple times, you need call [destroyEngine] before you call the next [createEngine]. Otherwise it will return the instance which created by [createEngine] you called last time.
  • Available since: 2.14.0
  • Restrictions: None.

Return

The result notification callback of create engine.

destroyEngine

static
destroyEngine
destroyEngine(): void
Destroy the ZegoExpressEngine singleton object and deinitialize the SDK.
Declared in ZegoExpressEngine.js

Destroy the ZegoExpressEngine singleton object and deinitialize the SDK.

  • When to call: When the SDK is no longer used, the resources used by the SDK can be released through this interface
  • Caution: After using [createEngine] to create a singleton, if the singleton object has not been created or has been destroyed, you will not receive related callbacks when calling this function.
  • Available since: 1.1.0
  • Restrictions: None.

setEngineConfig

static
setEngineConfig
setEngineConfig(config: ZegoEngineConfig): void
Set advanced engine configuration.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
configZegoEngineConfigAdvanced engine configuration

Details

Used to enable advanced functions.

  • When to call: Different configurations have different call timing requirements. For details, please consult ZEGO technical support.
  • Available since: 1.1.0
  • Restrictions: None.

setLogConfig

static
setLogConfig
setLogConfig(config: ZegoLogConfig): void
Set log configuration.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
configZegoLogConfiglog configuration.

Details

If you need to customize the log file size and path, please call this function to complete the configuration.

  • When to call: It must be set before calling [createEngine] to take effect. If it is set after [createEngine], it will take effect at the next [createEngine] after [destroyEngine].
  • Caution: Once this interface is called, the method of setting log size and path via [setEngineConfig] will be invalid.Therefore, it is not recommended to use [setEngineConfig] to set the log size and path.
  • Available since: 2.3.0
  • Restrictions: None.

setRoomMode

static
setRoomMode
setRoomMode(mode: ZegoRoomMode): void
Set room mode.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
modeZegoRoomModeRoom mode. Description: Used to set the room mode. Use cases: If you need to enter multiple rooms at the same time for publish-play stream, please turn on the multi-room mode through this interface. Required: True. Default value: ZEGO_ROOM_MODE_SINGLE_ROOM.

Details

If you need to use the multi-room 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.
  • Caution: None.
  • Available since: 2.9.0
  • Restrictions: If you need to use the multi-room feature, please contact the instant technical support to configure the server support.

setGeoFence

static
setGeoFence
setGeoFence(type: ZegoGeoFenceType, areaList: Array<number>): void
Set Geo Fence.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
typeZegoGeoFenceTypeGeo fence type. Description: Used to set the geo fence type.
areaListArray<number>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.
  • Caution: None.
  • Available since: 3.4.0
  • Restrictions: If you need to use the geo fence feature, please contact ZEGO Technical Support.

getVersion

static
getVersion
getVersion(): string
Gets the SDK's version number.
Declared in ZegoExpressEngine.js

If you encounter an abnormality during the running of the SDK, you can submit the problem, log and other information to the ZEGO technical staff to locate and troubleshoot. Developers can also collect current SDK version information through this API, which is convenient for App operation statistics and related issues.

  • When to call: Any time.
  • Caution: None.
  • Available since: 1.1.0
  • Restrictions: None.

SDK version.

isFeatureSupported

static
isFeatureSupported
isFeatureSupported(featureType: ZegoFeatureType): boolean
Query whether the current SDK supports the specified feature.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
featureTypeZegoFeatureTypeType of feature to query.

Details

Since the SDK supports feature trimming, some features may be trimmed; you can use this function to quickly determine whether the current SDK supports the specified features, such as querying whether the media player feature is supported.

  • When to call: Any time.
  • Available since: 2.22.0

Return

Whether the specified feature is supported. true: supported; false: not supported.

init

static
init
deprecated
init(appID: number, appSign: string, isTestEnv: boolean, scenario: ZegoScenario): Promise<Object>
[Deprecated] Initializes the Engine. Deprecated since 2.14.0, please use the method [createEngine] instead.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
appIDnumberApplication ID issued by ZEGO for developers, please apply from the ZEGO Admin Console https://console.zegocloud.com The value ranges from 0 to 4294967295.
appSignstringApplication signature for each AppID, please apply from the ZEGO Admin Console. Application signature is a 64 character string. Each character has a range of '0' ~ '9', 'a' ~ 'z'. AppSign 2.17.0 and later allows null or no transmission. If the token is passed empty or not passed, the token must be entered in the [ZegoRoomConfig] parameter for authentication when the [loginRoom] interface is called to login to the room.
isTestEnvboolean[Deprecated] For providing better and more standardized services, starting from 2021-11-16, ZEGO no longer classifies environments into production environments and testing environments. f you create your project in ZEGO Admin Console on/before 2021-11-16, refer to Testing environment deprecation to upgrade the SDK and adjust related codes.
scenarioZegoScenarioThe room scenario. the SDK will optimize the audio and video configuration for the specified scenario to achieve the best effect in this scenario. After specifying the scenario, you can call other APIs to adjusting the audio and video configuration. Differences between scenarios and how to choose a suitable scenario, please refer to https://docs.zegocloud.com/article/14940

Details

The engine needs to be initialized before calling other functions

Deprecated
Deprecated since 2.14.0, please use the method [createEngine] instead.

Return

Engine singleton instance.

setRoomScenario

setRoomScenario
setRoomScenario(scenario: ZegoScenario): void
Set room scenario.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
scenarioZegoScenarioRoom scenario.

Details

You can set the scenario of the room, and the SDK will adopt different optimization strategies for different scenarios in order to obtain better effects; this function does exactly the same thing as the [scenario] parameter in the [profile] configuration of [createEngine].

  • Use cases: This function is suitable for apps in various audio and video business scenarios, such as 1v1 video call (or voice call) scenario and live show scenario; this function can be used to switch scenarios without destroying the engine through [destroyEngine].
  • When to call: Must be set before calling [loginRoom] AND after calling [createEngine].
  • Caution: 1. Users in the same room are recommended to use the same room scenario for best results. 2. Setting the scenario will affect the audio and video bit rate, frame rate, resolution, codec id, audio device mode, audio route type, traffic control, 3A, ear return and other audio and video configurations. If you have special needs, you can call various other APIs to set the above configuration after calling this API. 3. Calling this function will override the scenario specified on [createEngine] or the scenario set by the last call to this function. 4. Calling this function will overwrite the audio and video related configuration you set through APIs such as [setVideoConfig], [setAudioConfig], so it is recommended to set the scenario first and then adjust the audio and video configuration through other APIs.
  • Available since: 3.0.0
  • Restrictions: Once you log in to the room, you are no longer allowed to modify the room scenario. If you need to modify the scenario, 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 you can modify it.

uploadLog

uploadLog
uploadLog(): void
Uploads logs to the ZEGO server.
Declared in ZegoExpressEngine.js

By default, SDK creates and prints log files in the App's default directory. Each log file defaults to a maximum of 5MB. Three log files are written over and over in a circular fashion. When calling this function, SDK will auto package and upload the log files to the ZEGO server.

  • Use cases: Developers can provide a business “feedback” channel in the App. When users feedback problems, they can call this function to upload the local log information of SDK to help locate user problems.
  • When to call: After [createEngine].
  • Caution: 1.After calling this interface to upload logs, if you call [destroyEngine] or exit the App too quickly, there may be a failure.It is recommended to wait a few seconds, and then call [destroyEngine] or exit the App after receiving the upload success callback. 2.If you want to call before [createEngine], use the [submitLog] interface.
  • Available since: 1.1.0
  • Restrictions: The frequency limit is once per minute.

enableDebugAssistant

enableDebugAssistant
enableDebugAssistant(enable: boolean): void
Enable the debug assistant. Note, do not enable this feature in the online version! Use only during development phase!
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
enablebooleanWhether to enable the debug assistant.

Details

After enabled, the SDK will print logs to the console, and will pop-up an alert (toast) UI message when there is a problem with calling other SDK functions.

  • Default value: This function is disabled by default.
  • When to call: This function can be called right after [createEngine].
  • Platform differences: The pop-up alert function only supports Android / iOS / macOS / Windows, and the console log function supports all platforms.
  • Caution: Be sure to confirm that this feature is turned off before the app is released to avoid pop-up UI alert when an error occurs in your release version's app. It is recommended to associate the [enable] parameter of this function with the DEBUG variable of the app, that is, only enable the debug assistant in the DEBUG environment.
  • Available since: 2.17.0
  • Restrictions: None.

callExperimentalAPI

callExperimentalAPI
callExperimentalAPI(params: string): string
Call the experimental API.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
paramsstringParameters in the format of a JSON string, please consult ZEGO technical support for details.

Details

ZEGO provides some technical previews or special customization functions in RTC business through this API. If you need to get the use of the function or the details, please consult ZEGO technical support.

  • When to call: After [createEngine].
  • Available since: 2.7.0

Return

Returns an argument in the format of a JSON string, please consult ZEGO technical support for details.

onDebugError

onDebugError
onDebugError(errorCode: number, funcName: string, info: string): void
The callback for obtaining debugging error information.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
errorCodenumberError code, please refer to the error codes document https://docs.zegocloud.com/en/5548.html for details.
funcNamestringFunction name.
infostringDetailed error information.

Details

When the SDK functions are not used correctly, the callback prompts for detailed error information.

  • Trigger: Notify the developer when an exception occurs in the SDK.
  • Caution: None.
  • Available since: 1.1.0
  • Restrictions: None.

onEngineStateUpdate

onEngineStateUpdate
onEngineStateUpdate(state: ZegoEngineState): void
The callback triggered when the audio/video engine state changes.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
stateZegoEngineStateThe audio/video engine state.

Details

Callback notification of audio/video engine status update. When audio/video functions are enabled, such as preview, push streaming, local media player, audio data observering, etc., the audio/video engine will enter the start state. When you exit the room or disable all audio/video functions , The audio/video engine will enter the stop state.

  • Trigger: The developer called the relevant function to change the state of the audio and video engine. For example: 1. Called ZegoExpressEngine's [startPreview], [stopPreview], [startPublishingStream], [stopPublishingStream], [startPlayingStream], [stopPlayingStream], [startAudioDataObserver], [stopAudioDataObserver] and other functions. 2. The related functions of MediaPlayer are called. 3. The [LogoutRoom] function was called. 4. The related functions of RealTimeSequentialDataManager are called.
  • Caution: 1. When the developer calls [destroyEngine], this notification will not be triggered because the resources of the SDK are completely released. 2. If there is no special need, the developer does not need to pay attention to this callback.
  • Available since: 1.1.0
  • Restrictions: None.

onRecvExperimentalAPI

onRecvExperimentalAPI
onRecvExperimentalAPI(content: string): void
Experimental API callback
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
contentstringCallback content in JSON string format.

Details

Receive experimental API callbacks in JSON string format.

  • Caution: Please use this feature with the help of ZEGO Technical Support.
  • Available since: 2.7.0

loginRoom

loginRoom
loginRoom(roomID: string, user: ZegoUser, config: ZegoRoomConfig): void
Log in to the room by configuring advanced properties, and return the login result through the callback parameter. You must log in to the room before pushing or pulling the stream.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
roomIDstringRoom ID, a string of less 128 bytes in length.
Caution:
1. room ID is defined by yourself.
2. Only support numbers, English characters and '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '=', '-', '`', ';', '’', ',', '.', '<', '>', ''.
3. If you need to communicate with the Web SDK, please do not use '%'.
userZegoUserUser object instance, configure userID, userName. Note that the userID needs to be globally unique with the same appID, otherwise the user who logs in later will kick out the user who logged in first.
configZegoRoomConfigAdvanced room configuration.

Details

If the room does not exist, [loginRoom] creates and logs in the room. SDK uses the 'room' to organize users. After users log in to a room, they can use interface such as push stream [startPublishingStream], pull stream [startPlayingStream], send and receive broadcast messages [sendBroadcastMessage], etc. To prevent the app from being impersonated by a malicious user, you can add authentication before logging in to the room, that is, the [token] parameter in the ZegoRoomConfig object passed in by the [config] parameter.

  • Use cases: In the same room, users can conduct live broadcast, audio and video calls, etc.
  • When to call /Trigger: This interface is called after [createEngine] initializes the SDK.
  • Caution: 1. Apps that use different appIDs cannot intercommunication with each other. 2. SDK supports startPlayingStream audio and video streams from different rooms under the same appID, that is, startPlayingStream audio and video streams across rooms. Since ZegoExpressEngine's room related callback notifications are based on the same room, when developers want to startPlayingStream streams across rooms, developers need to maintain related messages and signaling notifications by themselves. 3. It is strongly recommended that userID corresponds to the user ID of the business APP, that is, a userID and a real user are fixed and unique, and should not be passed to the SDK in a random userID. Because the unique and fixed userID allows ZEGO technicians to quickly locate online problems. 4. After the first login failure due to network reasons or the room is disconnected, the default time of SDK reconnection is 20min.
  • Privacy reminder: Please do not fill in sensitive user information in this interface, including but not limited to mobile phone number, ID number, passport number, real name, etc.
  • Related callbacks: 1. When the user starts to log in to the room, the room is successfully logged in, or the room fails to log in, the [onRoomStateChanged] (Not supported before 2.18.0, please use [onRoomStateUpdate]) callback will be triggered to notify the developer of the status of the current user connected to the room. 2. Different users who log in to the same room can get room related notifications in the same room (eg [onRoomUserUpdate], [onRoomStreamUpdate], etc.), and users in one room cannot receive room signaling notifications in another room. 3. If the network is temporarily interrupted due to network quality reasons, the SDK will automatically reconnect internally. You can get the current connection status of the local room by listening to the [onRoomStateChanged] (Not supported before 2.18.0, please use [onRoomStateUpdate]) callback method, and other users in the same room will receive [onRoomUserUpdate] callback notification. 4. Messages sent in one room (e.g. [setStreamExtraInfo], [sendBroadcastMessage], [sendBarrageMessage], [sendCustomCommand], etc.) cannot be received callback ((eg [onRoomStreamExtraInfoUpdate], [onIMRecvBroadcastMessage], [onIMRecvBarrageMessage], [onIMRecvCustomCommand], etc) in other rooms. Currently, SDK does not provide the ability to send messages across rooms. Developers can integrate the SDK of third-party IM to achieve.
  • Related APIs: 1. Users can call [logoutRoom] to log out. In the case that a user has successfully logged in and has not logged out, if the login interface is called again, the console will report an error and print the error code 1002001. 2. SDK supports multi-room login, please call [setRoomMode] function to select multi-room mode before engine initialization, and then call [loginRoom] to log in to multi-room. 3. Calling [destroyEngine] will also automatically log out.

logoutRoom

logoutRoom
logoutRoom(roomID: string): void
Exit the room of the specified room ID.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
roomIDstringRoom ID, a string of up to 128 bytes in length.
Caution:
1. Only support numbers, English characters and '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '=', '-', '`', ';', '’', ',', '.', '<', '>', ''.
2. If you need to communicate with the Web SDK, please do not use '%'.
3. If this parameter is not passed, SDK will exit the room that the current user has logged in to. If multiple rooms are enabled, all rooms will be logged out.

Details

This API will log out the room named roomID.

  • Use cases: In the same room, users can conduct live broadcast, audio and video calls, etc.
  • When to call /Trigger: After successfully logging in to the room, if the room is no longer used, the user can call the function [logoutRoom].
  • Caution: 1. Exiting the room will stop all publishing and playing streams for user, and inner audio and video engine will stop, and then SDK will auto stop local preview UI. If you want to keep the preview ability when switching rooms, please use the [switchRoom] method. 2. If the user logs out to the room, but the incoming 'roomID' is different from the logged-in room name, SDK will return failure.
  • Related callbacks: After calling this function, you will receive [onRoomStateChanged] (Not supported before 2.18.0, please use [onRoomStateUpdate]) callback notification successfully exits the room, while other users in the same room will receive the [onRoomUserUpdate] callback notification(On the premise of enabling isUserStatusNotify configuration).
  • Related APIs: Users can use [loginRoom], [switchRoom] functions to log in or switch rooms.
  • Available since: 1.1.0
  • Restrictions: None.

switchRoom

switchRoom
switchRoom(fromRoomID: string, toRoomID: string, config: ZegoRoomConfig): void
Switch the room with advanced room configurations.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
fromRoomIDstringCurrent roomID.
toRoomIDstringThe next roomID.
configZegoRoomConfigAdvanced room configuration.

Details

Using this interface allows users to quickly switch from one room to another room.

  • Use cases: if you need to quickly switch to the next room, you can call this function.
  • When to call /Trigger: After successfully login room.
  • Caution: 1. When this function is called, all streams currently publishing or playing will stop (but the local preview will not stop). 2. To prevent the app from being impersonated by a malicious user, you can add authentication before logging in to the room, that is, the [token] parameter in the ZegoRoomConfig object passed in by the [config] parameter. This parameter configuration affects the room to be switched over. 3. Multi-room mode is supported in version 3.5.0 (use the function [setRoomMode] to set ZegoRoomMode to ZEGO_ROOM_MODE_MULTI_ROOM). 4. If a Token is passed in for login when logging into the room [loginRoom], the [switchroom] interface must be used with the config parameter and the corresponding Token value passed in when switching rooms.
  • Privacy reminder: Please do not fill in sensitive user information in this interface, including but not limited to mobile phone number, ID number, passport number, real name, etc.
  • Related callbacks: When the user call the [switchRoom] function, the [onRoomStateChanged] (Not supported before 2.18.0, please use [onRoomStateUpdate]) callback will be triggered to notify the developer of the status of the current user connected to the room.
  • Related APIs: Users can use the [logoutRoom] function to log out of the room.
  • Available since: 1.15.0
  • Restrictions: None.

renewToken

renewToken
renewToken(roomID: string, token: string): void
Renew token.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
roomIDstringRoom ID.
tokenstringThe token that needs to be renew.

Details

After the developer receives [onRoomTokenWillExpire], they can use this API to update the token to ensure that the subsequent RTC functions are normal.

  • Use cases: Used when the token is about to expire.
  • When to call /Trigger: After the developer receives [onRoomTokenWillExpire].
  • Caution: The token contains important information such as the user's room permissions, publish stream permissions, and effective time, please refer to https://docs.zegocloud.com/article/11649.
  • Related callbacks: None.
  • Related APIs: None.
  • Available since: 2.8.0
  • Restrictions: None.

setRoomExtraInfo

setRoomExtraInfo
setRoomExtraInfo(roomID: string, key: string, value: string): Promise<Object>
Set room extra information.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
roomIDstringRoom ID.
keystringkey of the extra info.
valuestringvalue if the extra info.

Details

The user can call this function to set the extra info of the room.

  • Use cases: You can set some room-related business attributes, such as whether someone is Co-hosting.
  • When to call /Trigger: After logging in the room successful.
  • Caution: For key and value restrictions, please refer to Restrictions. Newly set values ​​will overwrite old ones.
  • Related callbacks: Other users in the same room will be notified through the [onRoomExtraInfoUpdate] callback function.
  • Related APIs: None.

Return

Set room extra info execution result notification

onRoomStateUpdate

onRoomStateUpdate
onRoomStateUpdate(roomID: string, state: ZegoRoomState, errorCode: number, extendedData: string): void
Notification of the room connection state changes.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
roomIDstringRoom ID, a string of up to 128 bytes in length.
stateZegoRoomStateChanged room state.
errorCodenumberError code, For details, please refer to Common Error Codes.
extendedDatastringExtended Information with state updates. When the room login is successful, the key "room_session_id" can be used to obtain the unique RoomSessionID of each audio and video communication, which identifies the continuous communication from the first user in the room to the end of the audio and video communication. It can be used in scenarios such as call quality scoring and call problem diagnosis.

Details

This callback is triggered when the connection status of the room changes, and the reason for the change is notified.For versions 2.18.0 and above, it is recommended to use the onRoomStateChanged callback instead of the onRoomStateUpdate callback to monitor room state changes.

  • Use cases: Developers can use this callback to determine the status of the current user in the room. When to trigger:
  1. The developer will receive this notification when calling the [loginRoom], [logoutRoom], [switchRoom] functions.
  2. This notification may also be received when the network condition of the user's device changes (SDK will automatically log in to the room when disconnected, please refer to [Does ZEGO SDK support a fast reconnection for temporary disconnection] for details](https://docs.zegocloud.com/faq/reconnect?product=ExpressVideo&platform=all).
  • Caution: If the connection is being requested for a long time, the general probability is that the user's network is unstable.
  • Related APIs: [loginRoom]、[logoutRoom]、[switchRoom]
  • Available since: 1.1.0
  • Restrictions: None.

onRoomStateChanged

onRoomStateChanged
onRoomStateChanged(roomID: string, reason: ZegoRoomStateChangedReason, errorCode: number, extendedData: string): void
Notification of the room connection state changes, including specific reasons for state change.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
roomIDstringRoom ID, a string of up to 128 bytes in length.
reasonZegoRoomStateChangedReasonRoom state change reason.
errorCodenumberError code, please refer to the error codes document https://doc-en.zego.im/en/5548.html for details.
extendedDatastringExtended Information with state updates. When the room login is successful, the key "room_session_id" can be used to obtain the unique RoomSessionID of each audio and video communication, which identifies the continuous communication from the first user in the room to the end of the audio and video communication. It can be used in scenarios such as call quality scoring and call problem diagnosis.

Details

This callback is triggered when the connection status of the room changes, and the reason for the change is notified.For versions 2.18.0 and above, it is recommended to use the onRoomStateChanged callback instead of the onRoomStateUpdate callback to monitor room state changes.

  • Use cases: Developers can use this callback to determine the status of the current user in the room. When to trigger: Users will receive this notification when they call room functions (refer to [Related APIs]). 2. This notification may also be received when the user device's network conditions change (SDK will automatically log in to the room again when the connection is disconnected, refer to https://doc-zh.zego.im/faq/reconnect ).
  • Caution: If the connection is being requested for a long time, the general probability is that the user's network is unstable.
  • Related APIs: [loginRoom], [logoutRoom], [switchRoom]
  • Available since: 2.18.0
  • Restrictions: None.

onRoomUserUpdate

onRoomUserUpdate
onRoomUserUpdate(roomID: string, updateType: ZegoUpdateType, userList: ZegoUser[]): void
The callback triggered when the number of other users in the room increases or decreases.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
roomIDstringRoom ID where the user is logged in, a string of up to 128 bytes in length.
updateTypeZegoUpdateTypeUpdate type (add/delete).
userListZegoUser[]List of users changed in the current room.

Details

When other users in the room are online or offline, which causes the user list in the room to change, the developer will be notified through this callback.

  • Use cases: Developers can use this callback to update the user list display in the room in real time. When to trigger:
    1. When the user logs in to the room for the first time, if there are other users in the room, the SDK will trigger a callback notification with updateType being [ZegoUpdateTypeAdd], and userList is the other users in the room at this time.
    2. The user is already in the room. If another user logs in to the room through the [loginRoom] or [switchRoom] functions, the SDK will trigger a callback notification with updateType being [ZegoUpdateTypeAdd].
    3. If other users log out of this room through the [logoutRoom] or [switchRoom] functions, the SDK will trigger a callback notification with updateType being [ZegoUpdateTypeDelete].
    4. The user is already in the room. If another user is kicked out of the room from the server, the SDK will trigger a callback notification with updateType being [ZegoUpdateTypeDelete].
  • Related APIs: [loginRoom]、[logoutRoom]、[switchRoom]
  • Available since: 1.1.0
  • Restrictions: If developers need to use ZEGO room users notifications, please ensure that the [ZegoRoomConfig] sent by each user when logging in to the room has the [isUserStatusNotify] property set to true, otherwise the callback notification will not be received.

onRoomOnlineUserCountUpdate

onRoomOnlineUserCountUpdate
onRoomOnlineUserCountUpdate(roomID: string, count: number): void
The callback triggered every 30 seconds to report the current number of online users.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
roomIDstringRoom ID where the user is logged in, a string of up to 128 bytes in length.
countnumberCount of online users.

Details

This method will notify the user of the current number of online users in the room.

  • Use cases: Developers can use this callback to show the number of user online in the current room.
  • When to call /Trigger: After successfully logging in to the room.
  • Caution: 1. This function is called back every 30 seconds. 2. Because of this design, when the number of users in the room exceeds 500, there will be some errors in the statistics of the number of online people in the room.
  • Available since: 1.7.0
  • Restrictions: None.

onRoomStreamUpdate

onRoomStreamUpdate
onRoomStreamUpdate(roomID: string, updateType: ZegoUpdateType, streamList: ZegoStream[], extendedData: string): void
The callback triggered when the number of streams published by the other users in the same room increases or decreases.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
roomIDstringRoom ID where the user is logged in, a string of up to 128 bytes in length.
updateTypeZegoUpdateTypeUpdate type (add/delete).
streamListZegoStream[]Updated stream list.
extendedDatastringExtended information with stream updates.When receiving a stream deletion notification, the developer can convert the string into a json object to get the stream_delete_reason field, which is an array of stream deletion reasons, and the stream_delete_reason[].code field may have the following values: 1 (the user actively stops publishing stream) ; 2 (user heartbeat timeout); 3 (user repeated login); 4 (user kicked out); 5 (user disconnected); 6 (removed by the server).

Details

When other users in the room start publishing stream or stop publishing stream, the streaming list in the room changes, and the developer will be notified through this callback.

  • Use cases: This callback is used to monitor stream addition or stream deletion notifications of other users in the room. Developers can use this callback to determine whether other users in the same room start or stop publishing stream, so as to achieve active playing stream [startPlayingStream] or take the initiative to stop the playing stream [stopPlayingStream], and use it to change the UI controls at the same time. When to trigger:
    1. When the user logs in to the room for the first time, if there are other users publishing streams in the room, the SDK will trigger a callback notification with updateType being [ZegoUpdateTypeAdd], and streamList is an existing stream list.
    2. The user is already in the room. if another user adds a new push, the SDK will trigger a callback notification with updateType being [ZegoUpdateTypeAdd].
    3. The user is already in the room. If other users stop streaming, the SDK will trigger a callback notification with updateType being [ZegoUpdateTypeDelete].
    4. The user is already in the room. If other users leave the room, the SDK will trigger a callback notification with updateType being [ZegoUpdateTypeDelete].
  • Available since: 1.1.0
  • Restrictions: None.

onRoomStreamExtraInfoUpdate

onRoomStreamExtraInfoUpdate
onRoomStreamExtraInfoUpdate(roomID: string, streamList: ZegoStream[]): void
The callback triggered when there is an update on the extra information of the streams published by other users in the same room.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
roomIDstringRoom ID where the user is logged in, a string of up to 128 bytes in length.
streamListZegoStream[]List of streams that the extra info was updated.

Details

All users in the room will be notified by this callback when the extra information of the stream in the room is updated.

  • Use cases: Users can realize some business functions through the characteristics of stream extra information consistent with stream life cycle.
  • When to call /Trigger: When a user publishing the stream update the extra information of the stream in the same room, other users in the same room will receive the callback.
  • Caution: Unlike the stream ID, which cannot be modified during the publishing process, the stream extra information can be updated during the life cycle of the corresponding stream ID.
  • Related APIs: Users who publish stream can set extra stream information through [setStreamExtraInfo].
  • Available since: 1.1.0
  • Restrictions: None.

onRoomExtraInfoUpdate

onRoomExtraInfoUpdate
onRoomExtraInfoUpdate(roomID: string, roomExtraInfoList: ZegoRoomExtraInfo[]): void
The callback triggered when there is an update on the extra information of the room.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
roomIDstringRoom ID where the user is logged in, a string of up to 128 bytes in length.
roomExtraInfoListZegoRoomExtraInfo[]List of the extra info updated.

Details

After the room extra information is updated, all users in the room will be notified except update the room extra information user.

  • Use cases: Extra information for the room.
  • When to call /Trigger: When a user update the room extra information, other users in the same room will receive the callback.
  • Related APIs: Users can update room extra information through [setRoomExtraInfo] function.
  • Available since: 1.1.0
  • Restrictions: None.

onRoomTokenWillExpire

onRoomTokenWillExpire
onRoomTokenWillExpire(roomID: string, remainTimeInSecond: number): void
Callback notification that room Token authentication is about to expire.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
roomIDstringRoom ID where the user is logged in, a string of up to 128 bytes in length.
remainTimeInSecondnumberThe remaining time before the token expires.

Details

The callback notification that the room Token authentication is about to expire, please use [renewToken] to update the room Token authentication.

  • Use cases: In order to prevent illegal entry into the room, it is necessary to perform authentication control on login room, push streaming, etc., to improve security.
  • When to call /Trigger: 30 seconds before the Token expires, the SDK will call [onRoomTokenWillExpire] to notify developer.
  • Caution: The token contains important information such as the user's room permissions, publish stream permissions, and effective time, please refer to https://docs.zegocloud.com/article/11649.
  • Related APIs: When the developer receives this callback, he can use [renewToken] to update the token authentication information.
  • Available since: 2.8.0
  • Restrictions: None.

startPublishingStream

startPublishingStream
startPublishingStream(streamID: string, config?: ZegoPublisherConfig, channel: ZegoPublishChannel): void
Starts publishing a stream. Support multi-room mode.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
streamIDstringStream ID, a string of up to 256 characters.
Caution:
1. Stream ID is defined by you.
2. needs to be globally unique within the entire AppID. If in the same AppID, different users publish each stream and the stream ID is the same, which will cause the user to publish the stream failure. You cannot include URL keywords, otherwise publishing stream and playing stream will fails.
3. Only support numbers, English characters and '-', '_'.
configZegoPublisherConfigAdvanced publish configuration.
channelZegoPublishChannelPublish stream channel.

Details

Users push their local audio and video streams to the ZEGO RTC server or CDN, and other users in the same room can pull the audio and video streams to watch through the streamID or CDN pull stream address.

  • Use cases: It can be used to publish streams in real-time connecting wheat, live broadcast and other scenarios.
  • When to call: After [loginRoom].
  • Caution: 1. Before start to publish the stream, the user can choose to call [setVideoConfig] to set the relevant video parameters, and call [startPreview] to preview the video. 2. Other users in the same room can get the streamID by monitoring the [onRoomStreamUpdate] event callback after the local user publishing stream successfully. 3. In the case of poor network quality, user publish may be interrupted, and the SDK will attempt to reconnect. You can learn about the current state and error information of the stream published by monitoring the [onPublisherStateUpdate] event. 4. To call [SetRoomMode] function to select multiple rooms, the room ID must be specified explicitly.
  • Available since: 1.1.0
  • Restrictions: None.

stopPublishingStream

stopPublishingStream
stopPublishingStream(channel: ZegoPublishChannel): void
Stops publishing a stream (for the specified channel).
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
channelZegoPublishChannelPublish stream channel.

Details

The user stops sending local audio and video streams, and other users in the room will receive a stream deletion notification.

  • Use cases: It can be used to stop publish streams in real-time connecting wheat, live broadcast and other scenarios.
  • When to call: After [startPublishingStream].
  • Caution: 1. After stopping the streaming, other users in the same room can receive the delete notification of the stream by listening to the [onRoomStreamUpdate] callback. 2. If the user has initiated publish flow, this function must be called to stop the publish of the current stream before publishing the new stream (new streamID), otherwise the new stream publish will return a failure. 3. After stopping streaming, the developer should stop the local preview based on whether the business situation requires it.
  • Available since: 1.1.0
  • Restrictions: None.

setStreamExtraInfo

setStreamExtraInfo
setStreamExtraInfo(extraInfo: string, channel: ZegoPublishChannel): Promise<Object>
Sets the extra information of the stream being published for the specified publish channel.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
extraInfostringStream extra information, a string of up to 1024 characters.
channelZegoPublishChannelPublish stream channel.

Details

Use this function to set the extra info of the stream. The stream extra information is an extra information identifier of the stream ID. Unlike the stream ID, which cannot be modified during the publishing process, the stream extra information can be modified midway through the stream corresponding to the stream ID. Developers can synchronize variable content related to stream IDs based on stream additional information.

  • When to call: After the engine is created [createEngine], Called before and after [startPublishingStream] can both take effect.
  • Related callbacks: Users can obtain the execution result of the function through [ZegoPublisherSetStreamExtraInfoCallback] callback.
  • Available since: 1.1.0
  • Restrictions: None.

Return

Set stream extra information execution result notification.

startPreview

startPreview
startPreview(view: ZegoView, channel: ZegoPublishChannel): void
Starts/Updates the local video preview (for the specified channel).
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
viewZegoViewThe view used to display the preview image.
channelZegoPublishChannelPublish stream channel

Details

The user can see his own local image by calling this function.

  • Use cases: It can be used for local preview in real-time connecting wheat, live broadcast and other scenarios.
  • When to call: After [createEngine].
  • Caution: 1. The preview function does not require you to log in to the room or publish the stream first. But after exiting the room, SDK internally actively stops previewing by default. 2. Local view and preview modes can be updated by calling this function again. The user can only preview on one view. If you call [startPreview] again to pass in a new view, the preview screen will only be displayed in the new view. 3. You can set the mirror mode of the preview by calling the [setVideoMirrorMode] function. The default preview setting is image mirrored. 4. When this function is called, the audio and video engine module inside SDK will start really, and it will start to try to collect audio and video.
  • Available since: 1.1.0
  • Restrictions: None.

stopPreview

stopPreview
stopPreview(channel: ZegoPublishChannel): void
Stops the local preview (for the specified channel).
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
channelZegoPublishChannelPublish stream channel

Details

This function can be called to stop the preview when the preview is not needed locally.

  • Caution: Stopping the preview will not affect the publish stream and playing stream functions.
  • Available since: 1.1.0

setVideoConfig

setVideoConfig
setVideoConfig(config: ([ZegoVideoConfigPreset](/javascript_electron/enum/ZegoVideoConfigPreset)|ZegoVideoConfig), channel: ZegoPublishChannel): void
Sets up the video configurations (for the specified channel).
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
config([ZegoVideoConfigPreset](/javascript_electron/enum/ZegoVideoConfigPreset)|ZegoVideoConfig)Video configuration, the SDK provides a common setting combination of resolution, frame rate and bit rate, they also can be customized.
channelZegoPublishChannelPublish stream channel.

Details

Set the video frame rate, bit rate, video capture resolution, and video encoding output resolution.

  • Default value: The default video capture resolution is 360p, the video encoding output resolution is 360p, the bit rate is 600 kbps, and the frame rate is 15 fps.
  • When to call: After [createEngine].
  • Caution: Developers should note that the wide and high resolution of the mobile end is opposite to the wide and high resolution of the PC. For example, in the case of 360p, the resolution of the mobile end is 360x640, and the resolution of the PC end is 640x360.
  • Available since: 1.1.0
  • Restrictions: It is necessary to set the relevant video configuration before [startPreview], and only support the modification of the encoding resolution, the bit rate and the frame rate after [startPreview].

getVideoConfig

getVideoConfig
getVideoConfig(channel: ZegoPublishChannel): ZegoVideoConfig
Gets the current video configurations (for the specified channel).
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
channelZegoPublishChannelPublish stream channel

Details

This function can be used to get the specified publish channel's current video frame rate, bit rate, video capture resolution, and video encoding output resolution.

Return

Video configuration object

setVideoMirrorMode

setVideoMirrorMode
setVideoMirrorMode(mirrorMode: ZegoVideoMirrorMode, channel: ZegoPublishChannel): void
Sets the video mirroring mode (for the specified channel).
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
mirrorModeZegoVideoMirrorModeMirror mode for previewing or publishing the stream.
channelZegoPublishChannelPublish stream channel.

Details

Set whether the local preview video and the published video have mirror mode enabled. For specific mirroring mode.

  • When to call: After [createEngine].
  • Available since: 1.1.0
  • Restrictions: This setting only works if the SDK is responsible for rendering.

setAudioConfig

setAudioConfig
setAudioConfig(config: ([ZegoAudioConfigPreset](/javascript_electron/enum/ZegoAudioConfigPreset)|ZegoAudioConfig)): void
Sets up the audio configurations.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
config([ZegoAudioConfigPreset](/javascript_electron/enum/ZegoAudioConfigPreset)|ZegoAudioConfig)Audio config.

Details

You can set the combined value of the audio codec, bit rate, and audio channel through this function. If the preset value cannot meet the developer's scenario, the developer can set the parameters according to the business requirements.

  • Default value: The default audio config refers to the default value of [ZegoAudioConfig].
  • When to call: After the engine is created [createEngine], and before publishing [startPublishingStream].
  • Caution: Act on the main publish channel ZegoPublishChannel.Main.
  • Related APIs: [getAudioConfig].
  • Available since: 1.3.4
  • Restrictions: None.

setAudioConfigWithChannel

setAudioConfigWithChannel
setAudioConfigWithChannel(config: ([ZegoAudioConfigPreset](/javascript_electron/enum/ZegoAudioConfigPreset)|ZegoAudioConfig), channel: ZegoPublishChannel): void
Sets up the audio configurations for the specified publish channel.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
config([ZegoAudioConfigPreset](/javascript_electron/enum/ZegoAudioConfigPreset)|ZegoAudioConfig)Audio config.
channelZegoPublishChannelPublish stream channel.

Details

You can set the combined value of the audio codec, bit rate, and audio channel through this function. If the preset value cannot meet the developer's scenario, the developer can set the parameters according to the business requirements.

  • Default value: The default audio config refers to the default value of [ZegoAudioConfig].
  • When to call: After the engine is created [createEngine], and before publishing [startPublishingStream].
  • Related APIs: [getAudioConfig].
  • Available since: 1.3.4
  • Restrictions: None.

getAudioConfig

getAudioConfig
getAudioConfig(): ZegoAudioConfig
Gets the current audio configurations.
Declared in ZegoExpressEngine.js

You can get the current audio codec, bit rate, and audio channel through this function.

  • When to call: After the engine is created [createEngine].
  • Caution: Act on the main publish channel ZegoPublishChannel.Main.
  • Related APIs: [setAudioConfig].
  • Available since: 1.8.0
  • Restrictions: None.

Audio config.

setPublishStreamEncryptionKey

setPublishStreamEncryptionKey
setPublishStreamEncryptionKey(key: string, channel: ZegoPublishChannel): void
Set encryption key for the publishing stream for the specified publish channel.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
keystringThe encryption key, note that the key length only supports 16/24/32 bytes.
channelZegoPublishChannelPublish stream channel.

Details

Support calling this function to update the encryption key while publishing stream.

  • When to call: After the engine is created [createEngine], Called before and after [startPublishingStream] can both take effect.
  • Caution: that developers need to update the player's decryption key before updating the publisher's encryption key.
  • Related APIs: Calling [stopPublishingStream] or [logoutRoom] will clear the encryption key.
  • Available since: 1.19.0
  • Restrictions: This function is only valid when publishing stream to the Zego RTC server.

takePublishStreamSnapshot

takePublishStreamSnapshot
takePublishStreamSnapshot(channel: ZegoPublishChannel): Promise<Object>
Take a snapshot of the publishing stream for the specified publish channel.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
channelZegoPublishChannelPublish stream channel.

Details

Take a snapshot of the publishing stream.

  • When to call: Called this function after calling [startPublishingStream] or [startPreview].
  • Caution: The resolution of the snapshot is the encoding resolution set in [setVideoConfig]. If you need to change it to capture resolution, please call [setCapturePipelineScaleMode] to change the capture pipeline scale mode to [Post].
  • Related callbacks: The screenshot result will be called back through [ZegoPublisherTakeSnapshotCallback].
  • Related APIs: [takePlayStreamSnapshot].
  • Available since: 1.17.0
  • Restrictions: None.

Return

Results of take publish stream snapshot.

mutePublishStreamAudio

mutePublishStreamAudio
mutePublishStreamAudio(mute: boolean, channel: ZegoPublishChannel): void
Stops or resumes sending the audio part of a stream for the specified channel.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
mutebooleanWhether to stop sending audio streams, true means not to send audio stream, and false means sending audio stream. The default is false.
channelZegoPublishChannelPublish stream channel.

Details

This function can be called when publishing the stream to realize not publishing the audio data stream. The SDK still collects and processes the audio, but send muted audio frame packets to the network. Use case: Users can call this interface when they do not want to publish any audio data. This interface does not affect [onBeforeAudioPrepAudioData].

  • When to call: Called after the engine is created [createEngine] can take effect.
  • Related callbacks: If you stop sending audio streams, the remote user that play stream of local user publishing stream can receive Mute status change notification by monitoring [onRemoteMicStateUpdate] callbacks.
  • Related APIs: [mutePublishStreamVideo].
  • Available since: 1.1.0
  • Restrictions: None.

mutePublishStreamVideo

mutePublishStreamVideo
mutePublishStreamVideo(mute: boolean, channel: ZegoPublishChannel): void
Stops or resumes sending the video part of a stream for the specified channel.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
mutebooleanWhether to stop sending video streams, true means not to send video stream, and false means sending video stream. The default is false.
channelZegoPublishChannelPublish stream channel.

Details

This function can be called when publishing the stream to realize not publishing the video stream. The local camera can still work normally, can capture, preview and process video images normally, but does not send the video data to the network.

  • When to call: Called after the engine is created [createEngine] can take effect.
  • Related callbacks: If you stop sending video streams locally, the remote user that play stream of local user publishing stream can receive Mute status change notification by monitoring [onRemoteCameraStateUpdate] callbacks.
  • Related APIs: [mutePublishStreamAudio].
  • Available since: 1.1.0
  • Restrictions: None.

setStreamAlignmentProperty

setStreamAlignmentProperty
setStreamAlignmentProperty(alignment: number, channel: ZegoPublishChannel): void
Enable or disable the stream precision alignment function.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
alignmentnumberWhether to enable the stream mixing precision alignment function.
channelZegoPublishChannelPublish stream channel

Details

Use this interface to enable stream alignment, the SDK will attach network time information to the stream when publishing it for accurate stream alignment. Use case: Generally used in scenarios such as KTV where stream mixing alignment is required.

  • When to call: After the engine is created [createEngine].
  • Caution: If you need to align each stream through network time when playing multiple streams or mixed streams, you need to call [startPublishingStream] to publish the stream and [forceSynchronousNetworkTime] in [ZegoPublisherConfig] is 1 to enable network time synchronization.
  • Related APIs: [startMixerTask], [startAutoMixerTask]
  • Available since: 2.11.0.

enableTrafficControl

enableTrafficControl
enableTrafficControl(enable: boolean, property: number, channel: ZegoPublishChannel): void
Enables or disables the traffic control for the specified publish channel.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
enablebooleanWhether to enable traffic control. The default is ture.
propertynumberAdjustable property of traffic control, bitmask format. Should be one or the combinations of [ZegoTrafficControlProperty] enumeration. [AdaptiveFPS] as default.
channelZegoPublishChannelPublish stream channel.

Details

Enabling traffic control allows the SDK to adjust the audio and video streaming bitrate according to the current upstream network environment conditions, or according to the counterpart's downstream network environment conditions in a one-to-one interactive scenario, to ensure smooth results. At the same time, you can further specify the attributes of traffic control to adjust the corresponding control strategy.

  • Default value: Enable.
  • When to call: After the engine is created [createEngine], Called before [startPublishingStream] can take effect.
  • Available since: 1.5.0
  • Restrictions: Only support RTC publish.

setMinVideoBitrateForTrafficControl

setMinVideoBitrateForTrafficControl
setMinVideoBitrateForTrafficControl(bitrate: number, mode: ZegoTrafficControlMinVideoBitrateMode): void
Set the minimum video bitrate threshold for traffic control.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
bitratenumberMinimum video bitrate threshold for traffic control(kbps).
modeZegoTrafficControlMinVideoBitrateModeVideo sending mode below the minimum bitrate.

Details

Set the control strategy when the video bitrate reaches the lowest threshold during flow control. When the bitrate is lower than the minimum threshold, you can choose not to send video data or send it at a very low frame bitrate.

  • Default value: There is no control effect of the lowest threshold of video bitrate.
  • When to call: After the engine is created [createEngine], Called before [startPublishingStream] can take effect.
  • Caution: Act on the main publish channel ZegoPublishChannel.Main.
  • Related APIs: [enableTrafficControl].
  • Available since: 1.1.0
  • Restrictions: The traffic control must be turned on [enableTrafficControl].

setMinVideoFpsForTrafficControl

setMinVideoFpsForTrafficControl
setMinVideoFpsForTrafficControl(fps: number, channel: ZegoPublishChannel): void
Sets the minimum video frame rate threshold for traffic control.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
fpsnumberThe minimum video frame rate threshold for traffic control(fps).
channelZegoPublishChannelPublish stream channel.

Details

When enabling traffic control [enableTrafficControl], and its parameter [property] includes the attribute AdaptiveFPS, the minimum frame rate of the video will not be lower than the value set by the [setMinVideoFpsForTrafficControl] interface. A value of 0 indicates no limit.

  • Default value: There is no control effect of the lowest threshold of video frame rate.
  • When to call: The call takes effect after the engine [createEngine] is created.
  • Related APIs: [enableTrafficControl].
  • Caution: If you need to cancel the limit of the setting value, you can set it to 0.
  • Available since: 2.17.0
  • Restrictions: The traffic control must be turned on [enableTrafficControl]. And its parameter [property] must contain AdaptiveFPS, Please refer to [ZegoTrafficControlProperty] for details.

setMinVideoResolutionForTrafficControl

setMinVideoResolutionForTrafficControl
setMinVideoResolutionForTrafficControl(width: number, height: number, channel: ZegoPublishChannel): void
Sets the minimum video resolution threshold for traffic control.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
widthnumberThe flow controls the width of the lowest video resolution.
heightnumberThe flow controls the height of the lowest video resolution.
channelZegoPublishChannelPublish stream channel.

Details

When enabling traffic control [enableTrafficControl], and its parameter [property] includes the attribute AdaptiveResolution, the minimum resolution of the video will not be lower than the value set by the [setMinVideoResolutionForTrafficControl] interface. A value of 0 indicates no limit.

  • Default value: There is no control effect of the lowest threshold of video resolution.
  • When to call: The call takes effect after the engine [createEngine] is created.
  • Related APIs: [enableTrafficControl].
  • Caution: If you need to cancel the limit of the setting value, you can set width and height to 0.
  • Available since: 2.17.0
  • Restrictions: The traffic control must be turned on [enableTrafficControl]. And its parameter [property] must contain AdaptiveResolution, Please refer to [ZegoTrafficControlProperty] for details.

setTrafficControlFocusOn

setTrafficControlFocusOn
setTrafficControlFocusOn(mode: ZegoTrafficControlFocusOnMode, channel: ZegoPublishChannel): void
Set the factors of concern that trigger traffic control for the specified publish channel.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
modeZegoTrafficControlFocusOnModeWhen LOCAL_ONLY is selected, only the local network status is concerned. When choosing REMOTE, also take into account the remote network.
channelZegoPublishChannelPublish stream channel.

Details

Use this interface to control whether to start traffic control due to poor remote network conditions.

  • Default value: Default is disable.
  • When to call: After the engine is created [createEngine], Called before [startPublishingStream] can take effect.
  • Related APIs: [enableTrafficControl.
  • Available since: 2.4.0
  • Restrictions: The traffic control must be turned on [enableTrafficControl].

setCaptureVolume

setCaptureVolume
setCaptureVolume(volume: number): void
Sets the audio recording volume for stream publishing.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
volumenumberThe volume gain percentage, the range is 0 ~ 200, and the default value is 100, which means 100% of the original collection volume of the device.

Details

This function is used to perform gain processing based on the device's collected volume. The local user can control the sound level of the audio stream sent to the remote end.

  • Default value: Default is 100.
  • When to call: After creating the engine [createEngine].
  • Related APIs: Set the playing stream volume [setPlayVolume].
  • Available since: 1.13.0
  • Restrictions: The capture volume can be dynamically set during publishing.

setAudioCaptureStereoMode

setAudioCaptureStereoMode
setAudioCaptureStereoMode(mode: ZegoAudioCaptureStereoMode): void
Set audio capture stereo mode.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
modeZegoAudioCaptureStereoModeAudio stereo capture mode.

Details

This function is used to set the audio capture channel mode. When the developer turns on the stereo capture, using a special stereo capture device, the stereo audio data can be captured and streamed.

  • Use cases: In some professional scenes, users are particularly sensitive to sound effects, such as voice radio and musical instrument performance. At this time, support for stereo and high-quality sound is required.
  • Default value: The default is None, which means mono capture.
  • When to call: It needs to be called after [createEngine], before [startPublishingStream], [startPlayingStream], [startPreview], [createMediaPlayer], [createAudioEffectPlayer] and [createRealTimeSequentialDataManager].
  • Related APIs: When streaming, you need to enable the stereo audio encoding function through the [setAudioConfig] interface at the same time.
  • Available since: 1.15.0 (iOS/Android/Windows/OHOS); support macOS since 2.16.0
  • Restrictions: If you need to enable stereo capture, you also need to meet the following conditions: For iOS/Android, you need to connect an external audio device that supports stereo capture and be at the media volume. For macOS, it needs to be at the media volume. For Windows, an external audio device that supports stereo capture is required.

addPublishCdnUrl

addPublishCdnUrl
addPublishCdnUrl(streamID: string, targetURL: string): Promise<Object>
Adds a target CDN URL to which the stream will be relayed from ZEGO RTC server.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
streamIDstringStream ID.
targetURLstringCDN relay address, supported address format is rtmp, rtmps.

Details

Forward audio and video streams from ZEGO RTC servers to custom CDN content distribution networks with high latency but support for high concurrent pull streams.

  • Use cases: 1. It is often used in large-scale live broadcast scenes that do not have particularly high requirements for delay. 2. Since ZEGO RTC server itself can be configured to support CDN(content distribution networks), this function is mainly used by developers who have CDN content distribution services themselves. 3. This function supports dynamic relay to the CDN content distribution network, so developers can use this function as a disaster recovery solution for CDN content distribution services.
  • When to call: After calling the [createEngine] function to create the engine.
  • Caution: Removing URLs retweeted to CDN requires calling [removePublishCdnUrl], calling [stopPublishingStream] will not remove URLs publish to CDN.
  • Related APIs: Remove URLs that are re-pushed to the CDN [removePublishCdnUrl].
  • Available since: 1.1.0
  • Restrictions: When the [enablePublishDirectToCDN] function is set to true to publish the stream straight to the CDN, then calling this function will have no effect.

Return

The execution result of update the relay CDN operation.

removePublishCdnUrl

removePublishCdnUrl
removePublishCdnUrl(streamID: string, targetURL: string): Promise<Object>
Deletes the specified CDN URL, which is used for relaying streams from ZEGO RTC server to CDN.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
streamIDstringStream ID.
targetURLstringCDN relay address, supported address format rtmp.

Details

When a CDN forwarding address has been added via [addPublishCdnUrl], this function is called when the stream needs to be stopped.

  • When to call: After calling the [createEngine] function to create the engine, When you don't need to continue publish to the CDN.
  • Caution: This function does not stop publishing audio and video stream to the ZEGO ZEGO RTC server.
  • Related APIs: Add URLs that are re-pushed to the CDN [addPublishCdnUrl].
  • Available since: 1.1.0
  • Restrictions: When the [enablePublishDirectToCDN] function is set to true to publish the stream straight to the CDN, then calling this function will have no effect.

Return

The execution result of update the relay CDN operation.

enablePublishDirectToCDN

enablePublishDirectToCDN
enablePublishDirectToCDN(enable: boolean, config: ?ZegoCDNConfig, channel: ZegoPublishChannel): void
Whether to directly push to CDN (without going through the ZEGO RTC server), for the specified channel.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
enablebooleanWhether to enable direct publish CDN, true: enable direct publish CDN, false: disable direct publish CDN.
config?ZegoCDNConfigCDN configuration, if null, use Zego's background default configuration.
channelZegoPublishChannelPublish stream channel.

Details

Whether to publish streams directly from the client to CDN without passing through Zego RTC server.

  • Use cases: It is often used in large-scale live broadcast scenes that do not have particularly high requirements for delay.
  • Default value: The default is false, and direct push is not enabled.
  • When to call: After creating the engine [createEngine], before starting to push the stream [startPublishingStream].
  • Caution: The Direct Push CDN feature does not pass through the ZEGO Real-Time Audio and Video Cloud during network transmission, so you cannot use ZEGO's ultra-low latency audio and video services.
  • Related APIs: Dynamic re-push to CDN function [addPublishCdnUrl], [removePublishCdnUrl].
  • Available since: 1.5.0

setPublishWatermark

setPublishWatermark
setPublishWatermark(watermark: ?ZegoWatermark, isPreviewVisible: boolean, channel: ZegoPublishChannel): void
Sets up the stream watermark before stream publishing (for the specified channel).
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
watermark?ZegoWatermarkThe upper left corner of the watermark layout is the origin of the coordinate system, and the area cannot exceed the size set by the encoding resolution. If it is null, the watermark is cancelled.
isPreviewVisiblebooleanthe watermark is visible on local preview
channelZegoPublishChannelPublish stream channel.

Details

Set watermark for publish stream screen.

  • Use cases: It is often used to identify the source of the publish.
  • When to call: After creating the engine through [createEngine] function.
  • Caution: The layout of the watermark cannot exceed the video encoding resolution of the stream. It can be set at any time before or during the publishing stream.
  • Available since: 1.1.0

setSEIConfig

setSEIConfig
setSEIConfig(config: ZegoSEIConfig): void
Set the Supplemental Enhancement Information type.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
configZegoSEIConfigSEI configuration. The SEI defined by ZEGO is used by default.

Details

By default, the SDK wraps the data with ZEGO's self-defined SEI type, which is not specified by the SEI standard. When the developer needs to use a third-party decoder to decode the SEI, the correct SEI will not be decoded and the [setSEIConfig] interface needs to be called to change the type of the SEI sent by the SDK to UserUnregister type.

  • Use cases: This function needs to be executed when the developer uses a third-party decoder to decode the SEI.
  • When to call: After creating the engine [createEngine], before starting to push the stream [startPublishingStream].
  • Available since: 1.18.0
  • Restrictions: None.

sendSEI

sendSEI
sendSEI(data: ArrayBuffer, channel: ZegoPublishChannel): void
Sends Supplemental Enhancement Information to the specified publish channel.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
dataArrayBufferSEI data.
channelZegoPublishChannelPublish stream channel.

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. Due to network issues, frame loss may occur, which means SEI information may also be lost. To address this situation, it is advisable to send it multiple times within a limited frequency. 2. Even if the [enableCamera] interface is called to turn off the camera or [mutePublishStreamVideo] is used to stop sending video data, SEI can still be successfully sent; as long as the playback side does not call the [mutePlayStreamVideo] interface to stop pulling audio data, SEI can still be received normally. 3. If the SDK does not support the video module but does support the SEI functional module, SEI information can still be sent normally.
  • Related APIs: After the pusher sends the SEI, the puller can obtain the SEI content by monitoring the callback of [onPlayerRecvSEI].
  • Available since: 1.1.0
  • Restrictions: Do not exceed 30 times per second, and the SEI data length is limited to 4096 bytes.

enableHardwareEncoder

enableHardwareEncoder
enableHardwareEncoder(enable: boolean): void
Enables or disables hardware encoding.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
enablebooleanWhether to enable hardware encoding, true: enable hardware encoding, false: disable hardware encoding.

Details

Whether to use the hardware encoding function when publishing the stream, the GPU is used to encode the stream and to reduce the CPU usage.

  • When to call: The setting can take effect before the stream published. If it is set after the stream published, the stream should be stopped first before it takes effect.
  • Caution: Because hard-coded support is not particularly good for a few models, SDK uses software encoding by default. If the developer finds that the device is hot when publishing a high-resolution audio and video stream during testing of some models, you can consider calling this function to enable hard coding.
  • Available since: 1.1.0

setCapturePipelineScaleMode

setCapturePipelineScaleMode
setCapturePipelineScaleMode(mode: ZegoCapturePipelineScaleMode): void
Sets the timing of video scaling in the video capture workflow. You can choose to do video scaling right after video capture (the default value) or before encoding.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
modeZegoCapturePipelineScaleModeThe capture scale timing mode.
  • When to call: This function needs to be set before call [startPreview] or [startPublishingStream].
  • Caution: The main effect is Whether the local preview is affected when the acquisition resolution is different from the encoding resolution.
  • Available since: 1.1.0

setDummyCaptureImagePath

setDummyCaptureImagePath
setDummyCaptureImagePath(filePath: string, channel: ZegoPublishChannel): void
Set the path of the static picture would be published when the camera is closed.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
filePathstringPicture file path
channelZegoPublishChannelPublish channel.

Details

Set the path of the static picture would be published when enableCamera(false) is called, it would start to publish static pictures, and when enableCamera(true) is called, it would end publishing static pictures. Use case: The developer wants to display a static picture when the camera is closed. For example, when the anchor exits the background, the camera would be actively closed. At this time, the audience side needs to display the image of the anchor temporarily leaving.

  • When to call: After the engine is initialized, call this API to configure the parameters before closing the camera.
  • Caution: 1. The static picture cannot be seen in the local preview. 2. External filters, mirroring, watermarks, and snapshots are all invalid. 3. If the picture aspect ratio is inconsistent with the set code aspect ratio, it will be cropped according to the code aspect ratio. 4. To publish the audio stream, you must call this interface again and set the image path to empty to avoid video billing.
  • Platform differences: 1. Windows: Fill in the location of the picture directly, such as "D://dir//image.jpg". 2. iOS: If it is a full path, add the prefix "file:", such as @"file:/var/image.png"; If it is a assets picture path, add the prefix "asset:", such as @"asset
    ". 3. Android: If it is a full path, add the prefix "file:", such as "file:/sdcard/image.png"; If it is a assets directory path, add the prefix "asset:", such as "asset
    .png". 4. Flutter: If it is a absolute path, add the prefix "file:", such as "file:/sdcard/image.png"; If it is a assets resources directory path, add the prefix "flutter-asset://", such as "flutter-asset://assets/watermark.png". 5. UniApp: Only absolute paths are supported. You need to add a "file:" prefix, such as: "file:/sdcard/image.png".
  • Restrictions: 1. Supported picture types are JPEG/JPG, PNG, BMP, HEIF. 2. The function is only for SDK video capture and does not take effect for custom video capture. 3. Not supported that the filePath is a network link.

enableH265EncodeFallback

enableH265EncodeFallback
enableH265EncodeFallback(enable: boolean): void
Whether to enable H.265 encoding to automatically downgrade to H.264 encoding.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
enablebooleanWhether to enable H.265 coding automatically fallback to H.264 coding, true: enable, false: disable, and the default value is true

Details

When using H.265 encoding to push the stream, whether to enable the strategy of automatically degrading H.265 encoding to H.264 encoding under abnormal circumstances.After enabling automatic downgrade, when H.265 encoding is not supported or H.265 encoding fails, the SDK will try to downgrade and use H.264 encoding to push the stream.After turning off automatic downgrade, when H.265 encoding is not supported or H.265 encoding fails, the direct streaming fails.

  • Use cases: In the Co-hosting and Showroom Live Streaming scenarios, use H265 encoding to push the stream to save CDN traffic without degrading the picture quality. Default Value: When this interface is not called, the default is yes, which means that H.265 encoding is turned on and automatically downgraded to H.264 encoding.
  • When to call: After creating the engine, call the [startPublishingStream] function before pushing the stream.
  • Related callbacks: When the H.265 encoding is automatically downgraded to the H.264 encoding strategy, the [onPublisherVideoEncoderChanged] callback will be triggered when the encoding method changes.
  • Caution: When downgrading from H.265 to H.264 encoding occurs during the streaming process, if you are recording local video or cloud recording, multiple recording files will be generated, which needs to be dealt with.
  • Available since: 2.12.0

isVideoEncoderSupported

isVideoEncoderSupported
isVideoEncoderSupported(codecID: ZegoVideoCodecID, codecBackend: ZegoVideoCodecBackend): number
Whether the specified video encoding type and implementation are supported.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
codecIDZegoVideoCodecIDVideo codec id. Required: Yes.
codecBackendZegoVideoCodecBackendBackend implementation of encoder. Required: Yes.

Details

Whether the specified video encoding is supported depends on the following aspects, whether the hardware model supports hard encoding, whether the performance of the hardware model supports soft encoding, and whether the SDK has the encoding module.

  • When to call: After creating the engine.
  • Caution: It is recommended that users call this interface to obtain H.265 encoding support capability before publish stream with H.265 encoding, if not supported, you can use other encodings for publish, such as H.264.On the mobile platform, the SDK only supports H.265 hardware encoding, and it is affected by the model and hardware capabilities.
  • Available since: 3.0.0 and above

Return

Whether the specified video encoding format is supported; 0 means not supported, and the encoding format cannot be used for publish stream; 1 means support, you can use this encoding format for publish stream; 2 means not confirmed, it is recommended to call this interface later.

setLowlightEnhancement

setLowlightEnhancement
setLowlightEnhancement(mode: ZegoLowlightEnhancementMode, channel: ZegoPublishChannel): void
Set low light enhancement.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
modeZegoLowlightEnhancementModeLow light enhancement mode.
channelZegoPublishChannelPublish stream channel.

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: Off.
  • When to call: After creating the engine [createEngine].
  • Available since: 2.21.0

setVideoSource

setVideoSource
setVideoSource(source: ZegoVideoSourceType, instanceID: number, channel: ZegoPublishChannel): number
Set a video capture instance as video capture source for the specified channel.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
sourceZegoVideoSourceTypeVideo capture source.
instanceIDnumberVideo capture source instance id.
channelZegoPublishChannelPublish stream channel.

Details

Set video capture source for switching between different video capture sources.

  • Use cases: Typically used in educational scenarios that require switching between different video capture sources.
  • When to call: After the engine is created [createEngine].
  • Caution: 1. Main push channel ZegoPublishChannel.Main does not support using ZegoVideoSourceType.Player and ZegoVideoSourceType.MainPublishChannel video source type.
  1. When using ZegoVideoSourceType.Player and ZegoVideoSourceType.MainPublishChannel video source type in aux publish channel ZegoPublishChannel.Aux, must ensure that physical device works on main publish channel ZegoPublishChannel.Main.
  2. Preemptive video sources are not allowed to be used on multiple channels at the same time, such as ZegoVideoSourceType.Camera and ZegoVideoSourceType.ScreenCapture.
  3. The other publish channel can copy the main publish channel only when the main publish channel uses internal video capture. A maximum of one copy is supported.
  4. When using ZegoVideoSourceType.Player video source type, please ensure that the ZegoMediaPlayer instance is created successfully.
  • Available since: 3.1.0
  • Restrictions: None.

Return

result.

setAudioSource

setAudioSource
setAudioSource(source: ZegoAudioSourceType, channel: ZegoPublishChannel): number
Set audio capture source for the specified channel.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
sourceZegoAudioSourceTypeAudio capture source.
channelZegoPublishChannelPublish stream channel.

Details

Set audio capture source for switching between different audio capture sources.

  • Use cases: Typically used in educational scenarios that require switching between different audio capture sources.
  • When to call: After the engine is created [createEngine].
  • Caution: 1. Main push channel ZegoPublishChannel.Main does not support using ZegoAudioSourceType.MediaPlayer and ZegoAudioSourceType.MainPublishChannel audio source type.
  1. When using ZegoAudioSourceType.MediaPlayer and ZegoAudioSourceType.MainPublishChannel audio source type in aux publish channel ZegoPublishChannel.Aux, must ensure that physical device works on main publish channel ZegoPublishChannel.Main.
  2. Preemptive audio sources are not allowed to be used on multiple channels at the same time, such as ZegoAudioSourceType.Microphone.
  3. When using ZegoAudioSourceType.MediaPlayer audio source type, please ensure that the ZegoMediaPlayer instance is created successfully.
  • Available since: 3.1.0

Return

ErrorCode.

setAudioSourceWithConfig

setAudioSourceWithConfig
setAudioSourceWithConfig(source: ZegoAudioSourceType, config: ZegoAudioSourceMixConfig): number
Set audio capture source with audio mix config.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
sourceZegoAudioSourceTypeAudio capture source.
configZegoAudioSourceMixConfigAudio capture source mix config.

Details

Set audio capture source for switching between different audio capture sources.

  • Use cases: Typically used in educational scenarios that require switching between different audio capture sources.
  • When to call: After the engine is created [createEngine].
  • Caution: 1. Act on the main publish channel ZegoPublishChannel.Main.
  1. Main push channel ZegoPublishChannel.Main does not support using ZegoAudioSourceType.MediaPlayer and ZegoAudioSourceType.MainPublishChannel audio source type.
  • Available since: 3.1.0
  • Restrictions: None.

Return

errorCode.

enableVideoObjectSegmentation

enableVideoObjectSegmentation
enableVideoObjectSegmentation(enable: boolean, config: ZegoObjectSegmentationConfig, channel: ZegoPublishChannel): void
Enable video object segmentation.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
enablebooleanWhether to enable video object segmentation, off by default.
configZegoObjectSegmentationConfigThe type of object segmentation.
channelZegoPublishChannelPublish stream channel.

Details

Video object segmentation and transmission is a technology that separates the video object (in most cases, a person) in a rectangular video through an AI algorithm at the push end, transmits it in the RTC network, and renders it at the stream playing end.

  • Use cases: Scenes where the object in the video needs to be separated from the background, such as mixed reality, multi-person interaction scenes, and so on.
  • When to call: After the engine is created [createEngine].
  • Caution: This feature requires special braiding, please contact ZEGO Technical Support
  • Related callbacks: When the object segmentation is turned on or off, the notification of the object segmentation state can be received through [onVideoObjectSegmentationStateChanged].
  • Related APIs: Use [enableAlphaChannelVideoEncoder] to support the transparent background encoding of the divided object, and then publish the stream, you can render the object with a transparent background effect on the stream playing side.
  • Available since: 3.6.0
  • Restrictions: Enabling object segmentation is a time-consuming operation, and it is not necessary to turn it on and off frequently.

enableAlphaChannelVideoEncoder

enableAlphaChannelVideoEncoder
enableAlphaChannelVideoEncoder(enable: boolean, alphaLayout: ZegoAlphaLayoutType, channel: ZegoPublishChannel): void
Enable video encoder alpha channel support.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
enablebooleanEnable video encoder alpha channel support, off by default.
alphaLayoutZegoAlphaLayoutTypeSpecify the layout position of the alpha channel data.
channelZegoPublishChannelPublish stream channel.

Details

Enable the alpha channel support of the video encoder on the stream publishing end, and encode the split video body for streaming.

  • Use cases: Scenes where the object in the video needs to be separated from the background, such as mixed reality, multi-person interaction scenes, and so on.
  • When to call: After creating the engine.
  • Available since: 3.4.0

onPublisherStateUpdate

onPublisherStateUpdate
onPublisherStateUpdate(streamID: string, state: ZegoPublisherState, errorCode: number, extendedData: string): void
The callback triggered when the state of stream publishing changes.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
streamIDstringStream ID.
stateZegoPublisherStateState of publishing stream.
errorCodenumberThe error code corresponding to the status change of the publish stream, please refer to the error codes document https://docs.zegocloud.com/en/5548.html for details.
extendedDatastringExtended information with state updates, include playing stream CDN address.

Details

After calling the [startPublishingStream] successfully, the notification of the publish stream state change can be obtained through the callback function. You can roughly judge the user's uplink network status based on whether the state parameter is in [PUBLISH_REQUESTING].

  • Caution: The parameter [extendedData] is extended information with state updates. If you use ZEGO's CDN content distribution network, after the stream is successfully published, the keys of the content of this parameter are [flv_url_list], [rtmp_url_list], [hls_url_list], these correspond to the publishing stream URLs of the flv, rtmp, and hls protocols.
  • Related callbacks: After calling the [startPlayingStream] successfully, the notification of the play stream state change can be obtained through the callback function [onPlayerStateUpdate]. You can roughly judge the user's downlink network status based on whether the state parameter is in [PLAY_REQUESTING].
  • Available since: 1.1.0

onPublisherQualityUpdate

onPublisherQualityUpdate
onPublisherQualityUpdate(streamID: string, quality: ZegoPublishStreamQuality): void
Callback for current stream publishing quality.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
streamIDstringStream ID.
qualityZegoPublishStreamQualityPublishing stream quality, including audio and video framerate, bitrate, RTT, etc.

Details

After calling the [startPublishingStream] successfully, the callback will be received every 3 seconds default(If you need to change the time, please contact the instant technical support to configure). Through the callback, the collection frame rate, bit rate, RTT, packet loss rate and other quality data of the published audio and video stream can be obtained, and the health of the publish stream can be monitored in real time.You can monitor the health of the published audio and video streams in real time according to the quality parameters of the callback function, in order to show the uplink network status in real time on the device UI.

  • Caution: If you does not know how to use the parameters of this callback function, you can only pay attention to the [level] field of the [quality] parameter, which is a comprehensive value describing the uplink network calculated by SDK based on the quality parameters.
  • Related callbacks: After calling the [startPlayingStream] successfully, the callback [onPlayerQualityUpdate] will be received every 3 seconds. You can monitor the health of play streams in real time based on quality data such as frame rate, code rate, RTT, packet loss rate, etc.
  • Available since: 1.1.0

onPublisherCapturedAudioFirstFrame

onPublisherCapturedAudioFirstFrame
onPublisherCapturedAudioFirstFrame(): void
The callback triggered when the first audio frame is captured.
Declared in ZegoExpressEngine.js

This callback will be received when the SDK starts the microphone to capture the first frame of audio data. If this callback is not received, the audio capture device is occupied or abnormal.

  • Trigger: When the engine of the audio/video module inside the SDK starts, the SDK will go and collect the audio data from the local device and will receive the callback at that time.
  • Related callbacks: Determine if the SDK actually collected video data by the callback function [onPublisherCapturedVideoFirstFrame], determine if the SDK has rendered the first frame of video data collected by calling back [onPublisherRenderVideoFirstFrame].
  • Available since: 1.1.0

onPublisherCapturedVideoFirstFrame

onPublisherCapturedVideoFirstFrame
onPublisherCapturedVideoFirstFrame(channel: ZegoPublishChannel): void
The callback triggered when the first video frame is captured.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
channelZegoPublishChannelPublishing stream channel.If you only publish one audio and video stream, you can ignore this parameter.

Details

The SDK will receive this callback when the first frame of video data is captured. If this callback is not received, the video capture device is occupied or abnormal.

  • Trigger: When the SDK's internal audio/video module's engine starts, the SDK will collect video data from the local device and will receive this callback.
  • Related callbacks: Determine if the SDK actually collected audio data by the callback function [onPublisherCapturedAudioFirstFrame], determine if the SDK has rendered the first frame of video data collected by calling back [onPublisherRenderVideoFirstFrame].
  • Available since: 1.1.0

onPublisherSendAudioFirstFrame

onPublisherSendAudioFirstFrame
onPublisherSendAudioFirstFrame(channel: ZegoPublishChannel): void
The callback triggered when the first audio frame is sent.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
channelZegoPublishChannelPublishing stream channel.If you only publish one audio stream, you can ignore this parameter.

Details

After the [startPublishingStream] function is called successfully, this callback will be called when SDK received the first frame of audio data. Developers can use this callback to determine whether SDK has actually collected audio data. If the callback is not received, the audio capture device is occupied or abnormal.

  • Trigger: In the case of no startPublishingStream audio stream, the first startPublishingStream audio stream, it will receive this callback.
  • Related callbacks: After the [startPublishingStream] function is called successfully, determine if the SDK actually collected video data by the callback function [onPublisherCapturedVideoFirstFrame], determine if the SDK has rendered the first frame of video data collected by calling back [onPublisherRenderVideoFirstFrame].
  • Available since: 3.5.0

onPublisherSendVideoFirstFrame

onPublisherSendVideoFirstFrame
onPublisherSendVideoFirstFrame(channel: ZegoPublishChannel): void
The callback triggered when the first video frame is sent.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
channelZegoPublishChannelPublishing stream channel.If you only publish one video stream, you can ignore this parameter.

Details

After the [startPublishingStream] function is called successfully, this callback will be called when SDK received the first frame of video data. Developers can use this callback to determine whether SDK has actually collected video data. If the callback is not received, the video capture device is occupied or abnormal.

  • Trigger: In the case of no startPublishingStream video stream, the first startPublishingStream video stream, it will receive this callback.
  • Related callbacks: After the [startPublishingStream] function is called successfully, determine if the SDK actually collected audio data by the callback function [onPublisherCapturedAudioFirstFrame], determine if the SDK has rendered the first frame of video data collected by calling back [onPublisherRenderVideoFirstFrame].
  • Available since: 3.5.0

onPublisherVideoSizeChanged

onPublisherVideoSizeChanged
onPublisherVideoSizeChanged(width: number, height: number, channel: ZegoPublishChannel): void
The callback triggered when the video capture resolution changes.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
widthnumberVideo capture resolution width.
heightnumberVideo capture resolution height.
channelZegoPublishChannelPublishing stream channel.If you only publish one audio and video stream, you can ignore this parameter.

Details

When the audio and video stream is not published [startPublishingStream] or previewed [startPreview] for the first time, the publishing stream or preview first time, that is, the engine of the audio and video module inside the SDK is started, the video data of the local device will be collected, and the collection resolution will change at this time.

  • Trigger: After the successful publish [startPublishingStream], the callback will be received if there is a change in the video capture resolution in the process of publishing the stream.
  • Use cases: You can use this callback to remove the cover of the local preview UI and similar operations.You can also dynamically adjust the scale of the preview view based on the resolution of the callback.
  • Caution: What is notified during external collection is the change in encoding resolution, which will be affected by flow control.
  • Available since: 1.1.0

onPublisherRelayCDNStateUpdate

onPublisherRelayCDNStateUpdate
onPublisherRelayCDNStateUpdate(streamID: string, infoList: ZegoStreamRelayCDNInfo[]): void
The callback triggered when the state of relayed streaming to CDN changes.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
streamIDstringStream ID.
infoListZegoStreamRelayCDNInfo[]List of information that the current CDN is relaying.

Details

Developers can use this callback to determine whether the audio and video streams of the relay CDN are normal. If they are abnormal, further locate the cause of the abnormal audio and video streams of the relay CDN and make corresponding disaster recovery strategies.

  • Trigger: After the ZEGO RTC server relays the audio and video streams to the CDN, this callback will be received if the CDN relay status changes, such as a stop or a retry.
  • Caution: If you do not understand the cause of the abnormality, you can contact ZEGO technicians to analyze the specific cause of the abnormality.
  • Available since: 1.1.0

onVideoObjectSegmentationStateChanged

onVideoObjectSegmentationStateChanged
onVideoObjectSegmentationStateChanged(state: ZegoObjectSegmentationState, channel: ZegoPublishChannel, errorCode: number): void
The video object segmentation state changed.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
stateZegoObjectSegmentationStateObject segmentation state.
channelZegoPublishChannelPublishing stream channel.If you only publish one audio and video stream, you can ignore this parameter.
errorCodenumberThe error code corresponding to the status change of the object segmentation, please refer to the error codes document https://docs.zegocloud.com/en/5548.html for details.

Details

The object segmentation state of the stream publishing end changes. When to trigger: When [enableVideoObjectSegmentation] enables or disables object segmentation, notify the developer whether to enable object segmentation according to the actual state.

  • Caution: This callback depends on enabling preview or stream publishing.
  • Available since: 3.4.0

startPlayingStream

startPlayingStream
startPlayingStream(streamID: string, view: ZegoView, config: ZegoPlayerConfig): void
Starts playing a stream from ZEGO RTC server or from third-party CDN. Support multi-room mode.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
streamIDstringStream ID, a string of up to 256 characters.
Caution:
Only support numbers, English characters and '-', '_'.
viewZegoViewThe view used to display the preview image.
configZegoPlayerConfigAdvanced player configuration Room [roomID] in [ZegoPlayerConfig] is the login roomID.

Details

Play audio and video streams from the ZEGO RTC server or CDN.

  • Use cases: In real-time or live broadcast scenarios, developers can listen to the [onRoomStreamUpdate] event callback to obtain the new stream information in the room where they are located, and call this interface to pass in streamID for play streams.
  • When to call: After [loginRoom].
  • Caution: 1. The developer can update the player canvas by calling this function again (the streamID must be the same). 2. After the first play stream failure due to network reasons or the play stream is interrupted, the default time for SDK reconnection is 20min. 3. In the case of poor network quality, user play may be interrupted, the SDK will try to reconnect, and the current play status and error information can be obtained by listening to the [onPlayerStateUpdate] event. please refer to https://docs.zegocloud.com/faq/reconnect. 4. Playing the stream ID that does not exist, the SDK continues to try to play after calling this function. After the stream ID is successfully published, the audio and video stream can be actually played.
  • Available since: 1.1.0
  • Restrictions: None.

stopPlayingStream

stopPlayingStream
stopPlayingStream(streamID: string): void
Stops playing a stream.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
streamIDstringStream ID.

Details

Play audio and video streams from the ZEGO RTC server.

  • Use cases: In the real-time scenario, developers can listen to the [onRoomStreamUpdate] event callback to obtain the delete stream information in the room where they are located, and call this interface to pass in streamID for stop play streams.
  • When to call: After [loginRoom].
  • Caution: 1. When stopped, the attributes set for this stream previously, such as [setPlayVolume], [mutePlayStreamAudio], [mutePlayStreamVideo], etc., will be invalid and need to be reset when playing the the stream next time.
  1. After stopping pulling, the iOS platform view will clear the last frame by default and keep the background color of the view. The Android platform view remains at the last frame by default. If you need to clear the last frame, please contact ZEGO technical support.
  • Available since: 1.1.0
  • Restrictions: None.

setPlayStreamDecryptionKey

setPlayStreamDecryptionKey
setPlayStreamDecryptionKey(streamID: string, key: string): void
Set decryption key for the playing stream.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
streamIDstringStream ID.
keystringThe decryption key, note that the key length only supports 16/24/32 bytes.

Details

When streaming, the audio and video data will be decrypted according to the set key.

  • Use cases: Usually used in scenarios that require high security for audio and video calls.
  • When to call: after [createEngine], after the play stream can be changed at any time.
  • Related APIs: [setPublishStreamEncryptionKey]Set the publish stream encryption key.
  • Caution: This interface can only be called if encryption is set on the publish. Calling [stopPlayingStream] or [logoutRoom] will clear the decryption key.
  • Available since: 1.19.0
  • Restrictions: This function is only valid when calling from Zego RTC or L3 server.

takePlayStreamSnapshot

takePlayStreamSnapshot
takePlayStreamSnapshot(streamID: string): Promise<Object>
Take a snapshot of the playing stream.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
streamIDstringStream ID to be snapshot.

Details

Take a screenshot of the specified stream ID.

  • When to call: after called [startPlayingStream].
  • Related callbacks: [onPlayerTakeSnapshotResult] Screenshot data callback.
  • Available since: 1.17.0
  • Restrictions: None.

Return

Results of take play stream snapshot.

setPlayVolume

setPlayVolume
setPlayVolume(streamID: string, volume: number): void
Sets the stream playback volume.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
streamIDstringStream ID.
volumenumberVolume percentage. The value ranges from 0 to 200, and the default value is 100.

Details

Set the sound size of the stream, the local user can control the playback volume of the audio stream.

  • When to call: after called [startPlayingStream].
  • Related APIs: [setAllPlayStreamVolume] Set all stream volume.
  • Caution: You need to reset after [stopPlayingStream] and [startPlayingStream]. This function and the [setAllPlayStreamVolume] function overwrite each other, and the last call takes effect.
  • Available since: 1.16.0
  • Restrictions: None.

setAllPlayStreamVolume

setAllPlayStreamVolume
setAllPlayStreamVolume(volume: number): void
Sets the all stream playback volume.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
volumenumberVolume percentage. The value ranges from 0 to 200, and the default value is 100.

Details

Set the sound size of the stream, the local user can control the playback volume of the audio stream.

  • When to call: after called [startPlayingStream].
  • Related APIs: [setPlayVolume] Set the specified streaming volume.
  • Caution: Set the specified streaming volume and [setAllPlayStreamVolume] interface to override each other, and the last call takes effect.
  • Available since: 2.3.0
  • Restrictions: None.

setPlayStreamVideoType

setPlayStreamVideoType
setPlayStreamVideoType(streamID: string, streamType: ZegoVideoStreamType): void
Set play video stream type.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
streamIDstringStream ID.
streamTypeZegoVideoStreamTypeVideo stream type.

Details

When the publish stream sets the codecID to SVC through [setVideoConfig], the puller can dynamically set and select different stream types (small resolution is one-half of the standard layer).

  • Use cases: In general, when the network is weak or the rendered UI window is small, you can choose to pull videos with small resolutions to save bandwidth.
  • When to call: before or after called [startPlayingStream].
  • Available since: 2.3.0
  • Restrictions: None.

setPlayStreamBufferIntervalRange

setPlayStreamBufferIntervalRange
setPlayStreamBufferIntervalRange(streamID: string, minBufferInterval: number, maxBufferInterval: number): void
Set the adaptive adjustment interval range of the buffer for playing stream.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
streamIDstringStream ID.
minBufferIntervalnumberThe lower limit of the buffer adaptation interval, in milliseconds. The default value is 0ms.
maxBufferIntervalnumberThe upper limit of the buffer adaptation interval, in milliseconds. The default value is 4000ms.

Details

Set the range of adaptive adjustment of the internal buffer of the sdk when streaming is 0-4000ms.

  • Use cases: Generally, in the case of a poor network environment, adjusting and increasing the playback buffer of the pull stream will significantly reduce the audio and video freezes, but will increase the delay.
  • When to call: after called [createEngine], if it has been set, you need to reset it every time you play the stream again.
  • Caution: When the upper limit of the cache interval set by the developer exceeds 4000ms, the value will be 4000ms. When the upper limit of the cache interval set by the developer is less than the lower limit of the cache interval, the upper limit will be automatically set as the lower limit.
  • Available since: 2.1.0
  • Restrictions: None.

setPlayStreamFocusOn

setPlayStreamFocusOn
setPlayStreamFocusOn(streamID: string): void
Set the weight of the pull stream priority.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
streamIDstringStream ID.

Details

Set the weight of the streaming priority.

  • Use cases: This interface can be used when developers need to prioritize the quality of a audio and video stream in business(do not use in pure audio case). For example: in class scene, if students pull multiple streams, you can set high priority for teacher stream.
  • When to call: after called [startPlayingStream].
  • Caution: By default, all streams have the same weight. Only one stream can be set with high priority, whichever is set last. After the flow is stopped, the initial state is automatically restored, and all flows have the same weight.When the local network is not good, while ensuring the focus flow, other stalls may be caused more.
  • Available since: 1.1.0
  • Restrictions: None.

mutePlayStreamAudio

mutePlayStreamAudio
mutePlayStreamAudio(streamID: string, mute: boolean): void
Whether the pull stream can receive the specified audio data.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
streamIDstringStream ID.
mutebooleanWhether it can receive the audio data of the specified remote user when streaming, "true" means prohibition, "false" means receiving, the default value is "false".

Details

In the process of real-time audio and video interaction, local users can use this function to control whether to receive audio data from designated remote users when pulling streams as needed. When the developer does not receive the audio receipt, the hardware and network overhead can be reduced.

  • Use cases: Call this function when developers need to quickly close and restore remote audio. Compared to re-flow, it can greatly reduce the time and improve the interactive experience.
  • When to call: This function can be called after calling [createEngine].
  • Caution:
  1. When used together with [muteAllPlayAudioStreams], they can override each other's configurations.
  2. When used together with [muteAllPlayStreamAudio], this function only works when the [muteAllPlayStreamAudio] function is set to false.
  3. After stopping streaming, any properties previously set for this stream such as [setPlayVolume], [mutePlayStreamAudio], [mutePlayStreamVideo] and other streaming-related configurations will become invalid and need to be reset before the next stream is pulled.
  • Related APIs: You can call the [muteAllPlayStreamAudio] function to control whether to receive all audio data. When the two functions [muteAllPlayStreamAudio] and [mutePlayStreamAudio] are set to false at the same time, the local user can receive the audio data of the remote user when the stream is pulled: 1. When the [muteAllPlayStreamAudio(true)] function is called, it is globally effective, that is, local users will be prohibited from receiving all remote users' audio data. At this time, the [mutePlayStreamAudio] function will not take effect whether it is called before or after [muteAllPlayStreamAudio].2. When the [muteAllPlayStreamAudio(false)] function is called, the local user can receive the audio data of all remote users. At this time, the [mutePlayStreamAudio] function can be used to control whether to receive a single audio data. Calling the [mutePlayStreamAudio(true, streamID)] function allows the local user to receive audio data other than the streamID; calling the [mutePlayStreamAudio(false, streamID)] function allows the local user to receive all audio data.
  • Available since: 1.1.0

mutePlayStreamVideo

mutePlayStreamVideo
mutePlayStreamVideo(streamID: string, mute: boolean): void
Whether the pull stream can receive the specified video data.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
streamIDstringStream ID.
mutebooleanWhether it is possible to receive the video data of the specified remote user when streaming, "true" means prohibition, "false" means receiving, the default value is "false". The default value for automatically played streams within the SDK is false.

Details

In the process of real-time video and video interaction, local users can use this function to control whether to receive video data from designated remote users when pulling streams as needed. When the developer does not receive the video data, the hardware and network overhead can be reduced.

  • Use cases: This function can be called when developers need to quickly close and resume watching remote video. Compared to re-flow, it can greatly reduce the time and improve the interactive experience.
  • When to call: This function can be called after calling [createEngine].
  • Caution:
  1. When used together with [muteAllPlayVideoStreams], they can override each other's configurations.
  2. When used together with [muteAllPlayStreamAudio], this function only works when the [muteAllPlayStreamVideo] function is set to false.
  3. When you mute the video stream, the view remains at the last frame by default, if you need to clear the last frame, please contact ZEGO technical support.
  4. After stopping streaming, any properties previously set for this stream such as [setPlayVolume], [mutePlayStreamAudio], [mutePlayStreamVideo] and other streaming-related configurations will become invalid and need to be reset before the next stream is pulled.
  • Related APIs: You can call the [muteAllPlayStreamVideo] function to control whether to receive all video data. When the two functions [muteAllPlayStreamVideo] and [mutePlayStreamVideo] are set to false at the same time, the local user can receive the video data of the remote user when the stream is pulled: 1. When the [muteAllPlayStreamVideo(true)] function is called, it will take effect globally, that is, local users will be prohibited from receiving all remote users' video data. At this time, the [mutePlayStreamVideo] function will not take effect whether it is called before or after [muteAllPlayStreamVideo]. 2. When the [muteAllPlayStreamVideo(false)] function is called, the local user can receive the video data of all remote users. At this time, the [mutePlayStreamVideo] function can be used to control whether to receive a single video data. Call the [mutePlayStreamVideo(true, streamID)] function, the local user can receive other video data other than the streamID; call the [mutePlayStreamVideo(false, streamID)] function, the local user can receive all the video data.
  • Available since: 1.1.0

muteAllPlayStreamAudio

muteAllPlayStreamAudio
muteAllPlayStreamAudio(mute: boolean): void
Can the pull stream receive all audio data. (When set to true, calling [mutePlayStreamAudio] will not take effect)
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
mutebooleanWhether it is possible to receive audio data from all remote users when streaming, "true" means prohibition, "false" means receiving, and the default value is "false".

Details

In the process of real-time audio and video interaction, local users can use this function to control whether to receive audio data from all remote users when pulling streams (including the audio streams pushed by users who have newly joined the room after calling this function). By default, users can receive audio data pushed by all remote users after joining the room. When the developer does not receive the audio receipt, the hardware and network overhead can be reduced.

  • Use cases: Call this function when developers need to quickly close and restore remote audio. Compared to re-flow, it can greatly reduce the time and improve the interactive experience.
  • When to call: This function can be called after calling [createEngine].
  • Caution: This function cannot be used together with [muteAllPlayAudioStreams] throughout the SDK lifecycle.
  • Related APIs: You can call the [mutePlayStreamAudio] function to control whether to receive a single piece of audio data. When the two functions [muteAllPlayStreamAudio] and [mutePlayStreamAudio] are set to false at the same time, the local user can receive the audio data of the remote user when the stream is pulled: 1. When the [muteAllPlayStreamAudio(true)] function is called, it takes effect globally, that is, local users will be prohibited from receiving audio data from all remote users. At this time, the [mutePlayStreamAudio] function will not take effect no matter if the [mutePlayStreamAudio] function is called before or after [muteAllPlayStreamAudio]. 2. When the [muteAllPlayStreamAudio(false)] function is called, the local user can receive the audio data of all remote users. At this time, the [mutePlayStreamAudio] function can be used to control whether to receive a single audio data. Calling the [mutePlayStreamAudio(true, streamID)] function allows the local user to receive audio data other than the streamID; calling the [mutePlayStreamAudio(false, streamID)] function allows the local user to receive all audio data.
  • Available since: 2.4.0

muteAllPlayStreamVideo

muteAllPlayStreamVideo
muteAllPlayStreamVideo(mute: boolean): void
Can the pull stream receive all video data. (When set to true, calling [mutePlayStreamVideo] will not take effect)
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
mutebooleanWhether it is possible to receive all remote users' video data when streaming, "true" means prohibition, "false" means receiving, and the default value is "false".

Details

In the process of real-time video and video interaction, local users can use this function to control whether to receive all remote users' video data when pulling the stream (including the video stream pushed by the new user who joins the room after calling this function). By default, users can receive video data pushed by all remote users after joining the room. When the developer does not receive the video data, the hardware and network overhead can be reduced.

  • Use cases: This function can be called when developers need to quickly close and resume watching remote video. Compared to re-flow, it can greatly reduce the time and improve the interactive experience.
  • When to call: This function can be called after calling [createEngine].
  • Caution:
  1. This function cannot be used together with [muteAllPlayVideoStreams] throughout the SDK lifecycle.
  2. When you mute the video stream, the view remains at the last frame by default, if you need to clear the last frame, please contact ZEGO technical support.
  • Related APIs: You can call the [mutePlayStreamVideo] function to control whether to receive a single piece of video data. When the two functions [muteAllPlayStreamVideo] and [mutePlayStreamVideo] are set to false at the same time, the local user can receive the video data of the remote user when the stream is pulled: 1. When the [muteAllPlayStreamVideo(true)] function is called, it will take effect globally, that is, the local user will be prohibited from receiving all remote users' video data. At this time, the [mutePlayStreamVideo] function will not take effect whether it is called before or after [muteAllPlayStreamVideo]. 2. When the [muteAllPlayStreamVideo(false)] function is called, the local user can receive the video data of all remote users. At this time, the [mutePlayStreamVideo] function can be used to control whether to receive a single video data. Call the [mutePlayStreamVideo(true, streamID)] function, the local user can receive other video data other than the streamID; call the [mutePlayStreamVideo(false, streamID)] function, the local user can receive all the video data.
  • Available since: 2.4.0

enableHardwareDecoder

enableHardwareDecoder
enableHardwareDecoder(enable: boolean): void
Enables or disables hardware decoding.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
enablebooleanWhether to turn on hardware decoding switch, true: enable hardware decoding, false: disable hardware decoding.

Details

Control whether hardware decoding is used when playing streams, with hardware decoding enabled the SDK will use the GPU for decoding, reducing CPU usage.

  • Use cases: If developers find that the device heats up badly when playing large resolution audio and video streams during testing on some models, consider calling this function to enable hardware decoding.
  • Default value: Hardware decoding is disabled by default when this interface is not called.
  • When to call: This function needs to be called after [createEngine] creates an instance.
  • Caution: Need to be called before calling [startPlayingStream], if called after playing the stream, it will only take effect after stopping the stream and re-playing it. Once this configuration has taken effect, it will remain in force until the next call takes effect.
  • Available since: 1.1.0
  • Restrictions: None.

enableCheckPoc

enableCheckPoc
enableCheckPoc(enable: boolean): void
Enables or disables frame order detection.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
enablebooleanWhether to turn on frame order detection, true: enable check poc, false: disable check poc.

Details

Control whether to turn on frame order detection.

  • Use cases: Turning on frame order detection when pulling cdn's stream will prevent splash screens.
  • Default value: Turn on frame order detection by default when this interface is not called.
  • When to call: This function needs to be called after [createEngine] creates an instance.
  • Caution: Turn off frame order detection during playing stream may result in a brief splash screen.
  • Available since: 1.1.0
  • Restrictions: None.

isVideoDecoderSupported

isVideoDecoderSupported
isVideoDecoderSupported(codecID: ZegoVideoCodecID, codecBackend: ZegoVideoCodecBackend): number
Whether the specified video decoding format is supported.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
codecIDZegoVideoCodecIDVideo codec id. Required: Yes.
codecBackendZegoVideoCodecBackendBackend implementation of decoder. Required: Yes.

Details

Whether the specified video decoding is supported depends on the following aspects: whether the hardware model supports hard decoding, whether the performance of the hardware model supports soft decoding, and whether the SDK includes the decoding module.

  • When to call: After creating the engine.
  • Caution: It is recommended that users call this interface to obtain the H.265 decoding support capability before pulling the H.265 stream. If it is not supported, the user can pull the stream of other encoding formats, such as H.264.
  • Available since: 3.0.0

Return

Whether the specified video decoding format is supported; 0 means not supported, and the decoding format cannot be used for play stream; 1 means support, you can use this decoding format for playing stream; 2 means not confirmed, it is recommended to call this interface later.

onPlayerStateUpdate

onPlayerStateUpdate
onPlayerStateUpdate(streamID: string, state: ZegoPlayerState, errorCode: number, extendedData: string): void
The callback triggered when the state of stream playing changes.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
streamIDstringstream ID.
stateZegoPlayerStateState of playing stream.
errorCodenumberThe error code corresponding to the status change of the playing stream, please refer to the error codes document https://docs.zegocloud.com/en/5548.html for details.
extendedDatastringExtended Information with state updates. As the standby, only an empty json table is currently returned.

Details

After calling the [startPlayingStream] successfully, the notification of the playing stream state change can be obtained through the callback function. You can roughly judge the user's downlink network status based on whether the state parameter is in [PLAY_REQUESTING]. When to trigger: After calling the [startPublishingStream], this callback is triggered when a playing stream's state changed.

  • Related callbacks: After calling the [startPublishingStream] successfully, the notification of the publish stream state change can be obtained through the callback function [onPublisherStateUpdate]. You can roughly judge the user's uplink network status based on whether the state parameter is in [PUBLISH_REQUESTING].
  • Available since: 1.1.0

onPlayerQualityUpdate

onPlayerQualityUpdate
onPlayerQualityUpdate(streamID: string, quality: ZegoPlayStreamQuality): void
Callback for current stream playing quality.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
streamIDstringStream ID.
qualityZegoPlayStreamQualityPlaying stream quality, including audio and video framerate, bitrate, RTT, etc.

Details

After calling the [startPlayingStream] successfully, the callback will be received every 3 seconds default(If you need to change the time, please contact the instant technical support to configure). Through the callback, the collection frame rate, bit rate, RTT, packet loss rate and other quality data can be obtained, and the health of the played audio and video streams can be monitored in real time.

  • Use cases: You can monitor the health of the played audio and video streams in real time according to the quality parameters of the callback function, in order to show the downlink network status on the device UI in real time.
  • Caution: If you does not know how to use the various parameters of the callback function, you can only focus on the level field of the quality parameter, which is a comprehensive value describing the downlink network calculated by SDK based on the quality parameters.
  • Related callbacks: After calling the [startPublishingStream] successfully, a callback [onPublisherQualityUpdate] will be received every 3 seconds. You can monitor the health of publish streams in real time based on quality data such as frame rate, code rate, RTT, packet loss rate, etc.
  • Available since: 1.1.0

onPlayerMediaEvent

onPlayerMediaEvent
onPlayerMediaEvent(streamID: string, event: ZegoPlayerMediaEvent): void
The callback triggered when a media event occurs during streaming playing.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
streamIDstringStream ID.
eventZegoPlayerMediaEventSpecific events received when playing the stream.

Details

This callback is used to receive pull streaming events.

  • Use cases: You can use this callback to make statistics on stutters or to make friendly displays in the UI of the app. When to trigger: After calling the [startPublishingStream], this callback is triggered when an event such as audio and video jamming and recovery occurs in the playing stream.
  • Available since: 1.1.0

onPlayerRecvAudioFirstFrame

onPlayerRecvAudioFirstFrame
onPlayerRecvAudioFirstFrame(streamID: string): void
The callback triggered when the first audio frame is received.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
streamIDstringStream ID.

Details

After the [startPlayingStream] function is called successfully, this callback will be called when SDK received the first frame of audio data.

  • Use cases: Developer can use this callback to count time consuming that take the first frame time or update the UI for playing stream.
  • Trigger: This callback is triggered when SDK receives the first frame of audio data from the network.
  • Related callbacks: After a successful call to [startPlayingStream], the callback function [onPlayerRecvVideoFirstFrame] determines whether the SDK has received the video data, and the callback [onPlayerRenderVideoFirstFrame] determines whether the SDK has rendered the first frame of the received video data.
  • Available since: 1.1.0

onPlayerRecvVideoFirstFrame

onPlayerRecvVideoFirstFrame
onPlayerRecvVideoFirstFrame(streamID: string): void
The callback triggered when the first video frame is received.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
streamIDstringStream ID.

Details

After the [startPlayingStream] function is called successfully, this callback will be called when SDK received the first frame of video data.

  • Use cases: Developer can use this callback to count time consuming that take the first frame time or update the UI for playing stream.
  • Trigger: This callback is triggered when SDK receives the first frame of video data from the network.
  • Related callbacks: After a successful call to [startPlayingStream], the callback function [onPlayerRecvAudioFirstFrame] determines whether the SDK has received the audio data, and the callback [onPlayerRenderVideoFirstFrame] determines whether the SDK has rendered the first frame of the received video data.
  • Available since: 1.1.0

onPlayerRenderVideoFirstFrame

onPlayerRenderVideoFirstFrame
onPlayerRenderVideoFirstFrame(streamID: string): void
The callback triggered when the first video frame is rendered.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
streamIDstringStream ID.

Details

After the [startPlayingStream] function is called successfully, this callback will be called when SDK rendered the first frame of video data.

  • Use cases: Developer can use this callback to count time consuming that take the first frame time or update the UI for playing stream.
  • Trigger: This callback is triggered when SDK rendered the first frame of video data from the network.
  • Related callbacks: After a successful call to [startPlayingStream], the callback function [onPlayerRecvAudioFirstFrame] determines whether the SDK has received the audio data, and the callback [onPlayerRecvVideoFirstFrame] determines whether the SDK has received the video data.
  • Available since: 1.1.0

onPlayerVideoSizeChanged

onPlayerVideoSizeChanged
onPlayerVideoSizeChanged(streamID: string, width: number, height: number): void
The callback triggered when the stream playback resolution changes.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
streamIDstringStream ID.
widthnumberVideo decoding resolution width.
heightnumberVideo decoding resolution height.

Details

After the [startPlayingStream] function is called successfully, the play resolution will change when the first frame of video data is received, or when the publisher changes the encoding resolution by calling [setVideoConfig], or when the network traffic control strategies work.

  • Use cases: Developers can update or switch the UI components that actually play the stream based on the final resolution of the stream.
  • Trigger: After the [startPlayingStream] function is called successfully, this callback is triggered when the video resolution changes while playing the stream.
  • Caution:
  1. If the stream is only audio data, the callback will not be triggered.
  2. If the user enables custom video rendering of the ZegoVideoBufferTypeEncodedData type, the SDK is not responsible for video decoding and will not trigger this callback.
  • Available since: 1.1.0

onPlayerRecvSEI

onPlayerRecvSEI
deprecated
onPlayerRecvSEI(streamID: string, data: UInt8Array): void
The callback triggered when Supplemental Enhancement Information is received.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
streamIDstringStream ID.
dataUInt8ArraySEI content.

Details

After the [startPlayingStream] function is called successfully, when the remote stream sends SEI (such as directly calling [sendSEI], audio mixing with SEI data, and sending custom video capture encoded data with SEI, etc.), the local end will receive this callback.

  • Trigger: After the [startPlayingStream] function is called successfully, when the remote stream sends SEI, the local end will receive this callback.
  • Caution: 1.The customer can directly operate the UI control in this callback function.
  1. Since the video encoder itself generates an SEI with a payload type of 5, or when a video file is used for publishing, such SEI may also exist in the video file. Therefore, if the developer needs to filter out this type of SEI, it can be before [createEngine] Call [ZegoEngineConfig.advancedConfig("unregister_sei_filter", "XXXXX")]. Among them, unregister_sei_filter is the key, and XXXXX is the uuid filter string to be set.
  2. When [mutePlayStreamVideo] or [muteAllPlayStreamVideo] is called to set only the audio stream to be pulled, the SEI will not be received.
  • Available since: 1.1.0
Deprecated
It will be deprecated in version 3.4.0 and above. Please use the [onPlayerSyncRecvSEI] function instead.

onPlayerSyncRecvSEI

onPlayerSyncRecvSEI
onPlayerSyncRecvSEI(streamID: string, data: UInt8Array): void
The callback triggered when Supplemental Enhancement Information is received synchronously.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
streamIDstringStream ID.
dataUInt8ArraySEI content.

Details

After the [startPlayingStream] function is called successfully, when the remote stream sends SEI (such as directly calling [sendSEI], audio mixing with SEI data, and sending custom video capture encoded data with SEI, etc.), the local end will receive this callback.

  • Trigger: After the [startPlayingStream] function is called successfully, when the remote stream sends SEI, the local end will receive this callback.
  • Caution:
  1. Since the video encoder itself generates an SEI with a payload type of 5, or when a video file is used for publishing, such SEI may also exist in the video file. Therefore, if the developer needs to filter out this type of SEI, it can be before [createEngine] Call [ZegoEngineConfig.advancedConfig("unregister_sei_filter", "XXXXX")]. Among them, unregister_sei_filter is the key, and XXXXX is the uuid filter string to be set.
  2. When [mutePlayStreamVideo] or [muteAllPlayStreamVideo] is called to set only the audio stream to be pulled, the SEI will not be received.
  • Available since: 3.4.0

startMixerTask

startMixerTask
startMixerTask(task: ZegoMixerTask): Promise<number, string>
Starts a stream mixing task.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
taskZegoMixerTaskMixing task object. Required: Yes.

Details

Initiate a mixing stream request to the ZEGO RTC server, the server will look for the stream currently being pushed, and mix the layers according to the parameters of the mixing stream task requested by the SDK. When you need to update a mixing task, that is, when the input stream increases or decreases, you need to update the input stream list. At this time, you can update the field of the [ZegoMixerTask] object inputList and call this function again to pass in the same [ZegoMixerTask] object to update the mixing task.

  • Use cases: It is often used when multiple video images are required to synthesize a video using mixed streaming, such as education, live broadcast of teacher and student images.
  • When to call: After calling [loginRoom] to log in to the room.
  • Caution: Due to the performance considerations of the client device, the SDK muxing is to start the mixing task on the ZEGO RTC server for mixing. If an exception occurs when the mixing task is requested to start, for example, the most common mixing input stream does not exist, the error code will be given from the callback callback. If a certain input stream does not exist in the middle, the muxing task will automatically retry to pull this input stream for 90 seconds, and will not retry after 90 seconds. If all input streams no longer exist, the server will automatically stop the mixing task after 90 seconds.
  • Related callbacks: [OnMixerRelayCDNStateUpdate] can be used to obtain the CDN status update notification of the mixed stream repost, and the sound update notification of each single stream in the mixed stream can be obtained through [onMixerSoundLevelUpdate].
  • Related APIs: the mixing task can be stopped by the [stopMixerTask] function.
  • Available since: 1.2.1
  • Restrictions: None.

Return

Start stream mixing task result

stopMixerTask

stopMixerTask
stopMixerTask(task: ZegoMixerTask): Promise<number>
Stops a stream mixing task.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
taskZegoMixerTaskMixing task object. Required: Yes.

Details

Initiate a request to end the mixing task to the ZEGO RTC server.

  • Use cases: It is often used when multiple video images are required to synthesize a video using mixed streaming, such as education, live broadcast of teacher and student images.
  • When to call: After calling [startMixerTask] to start mixing.
  • Caution: If the developer starts the next mixing task without stopping the previous mixing task, the previous mixing task will not automatically stop until the input stream of the previous mixing task does not exist for 90 seconds. Before starting the next mixing task, you should stop the previous mixing task, so that when an anchor has already started the next mixing task to mix with other anchors, the audience is still pulling the output stream of the previous mixing task.
  • Related APIs: You can start mixing by using the [startMixerTask] function.
  • Available since: 1.2.1
  • Restrictions: None.

Return

Stop stream mixing task result

muteMicrophone

muteMicrophone
muteMicrophone(mute: boolean): void
Mutes or unmutes the microphone.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
mutebooleanWhether to mute (disable) the microphone, true: mute (disable) microphone, false: enable microphone.

Details

This function is used to control whether to use the collected audio data. Mute (turn off the microphone) will use the muted data to replace the audio data collected by the device for streaming. At this time, the microphone device will still be occupied. Use case: Users can call this interface by only turning off the human voice collected by the microphone and not turning off the music sound of the media player. This interface affects [onBeforeAudioPrepAudioData].

  • Default value: The default is false, which means no muting.
  • When to call: After creating the engine [createEngine].
  • Related APIs: Developers who want to control whether to use microphone on the UI should use this function to avoid unnecessary performance overhead by using the [enableAudioCaptureDevice]. You can use [isMicrophoneMuted] to check if the microphone is muted.
  • Available since: 1.1.0
  • Restrictions: None.

isMicrophoneMuted

isMicrophoneMuted
isMicrophoneMuted(): boolean
Checks whether the microphone is muted.
Declared in ZegoExpressEngine.js

Used to determine whether the microphone is set to mute.

  • When to call: After creating the engine [createEngine].
  • Related APIs: [muteMicrophone].
  • Available since: 1.1.0
  • Restrictions: None.

Whether the microphone is muted; true: the microphone is muted; false: the microphone is enable (not muted).

muteSpeaker

muteSpeaker
muteSpeaker(mute: boolean): void
Mutes or unmutes the audio output speaker.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
mutebooleanWhether to mute (disable) speaker audio output, true: mute (disable) speaker audio output, false: enable speaker audio output.

Details

After mute speaker, all the SDK sounds will not play, including playing stream, mediaplayer, etc.

  • Default value: The default is false, which means no muting.
  • When to call: After creating the engine [createEngine].
  • Available since: 1.1.0
  • Restrictions: None.

isSpeakerMuted

isSpeakerMuted
isSpeakerMuted(): boolean
Checks whether the audio output speaker is muted.
Declared in ZegoExpressEngine.js

Used to determine whether the audio output is muted.

  • When to call: After creating the engine [createEngine].
  • Related APIs: [muteSpeaker].
  • Available since: 1.1.0
  • Restrictions: None.

Whether the speaker is muted; true: the speaker is muted; false: the speaker is enable (not muted).

getAudioDeviceList

getAudioDeviceList
getAudioDeviceList(deviceType: ZegoAudioDeviceType): ZegoDeviceInfo[]
Gets a list of audio devices.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
deviceTypeZegoAudioDeviceTypeAudio device type

Details

Only for Windows / macOS / Linux

Return

Audo device List

getDefaultAudioDeviceID

getDefaultAudioDeviceID
getDefaultAudioDeviceID(deviceType: ZegoAudioDeviceType): string
Get the device ID of the default audio device.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
deviceTypeZegoAudioDeviceTypeAudio device type

Details

Only for Windows / macOS / Linux

Return

Default Audio device ID

useAudioDevice

useAudioDevice
useAudioDevice(deviceID: string, deviceType: ZegoAudioDeviceType): void
Chooses to use the specified audio device.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
deviceIDstringID of a device obtained by [getAudioDeviceList]
deviceTypeZegoAudioDeviceTypeAudio device type

Details

Chooses to use the specified audio device.

  • When to call: After creating the engine [createEngine].
  • Available since: 1.1.0
  • Restrictions: Only supports Windows / macOS / Linux

getAudioDeviceVolume

getAudioDeviceVolume
getAudioDeviceVolume(deviceType: ZegoAudioDeviceType, deviceID: string): number
Get volume for the specified audio device.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
deviceTypeZegoAudioDeviceTypeAudio device type
deviceIDstringID of a device obtained by [getAudioDeviceList]

Details

Get volume for the specified audio device. Only for Windows / macOS / Linux

Return

Device volume

setAudioDeviceVolume

setAudioDeviceVolume
setAudioDeviceVolume(deviceType: ZegoAudioDeviceType, deviceID: string, volume: number): void
Set volume for the specified audio device.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
deviceTypeZegoAudioDeviceTypeAudio device type
deviceIDstringID of a device obtained by [getAudioDeviceList]
volumenumberDevice volume

Details

The direct operating system device may fail due to system restrictions. Please use [setCaptureVolume] and [setPlayVolume] first to adjust the volume of publish and play streams. Only for Windows / macOS / Linux

setSpeakerVolumeInAPP

setSpeakerVolumeInAPP
setSpeakerVolumeInAPP(deviceID: string, volume: number): void
Set the volume of the speaker in the App.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
deviceIDstringID of a device obtained by [getAudioDeviceList].
volumenumberDevice volume.

Details

Set the volume of the speaker in the App.

  • Use cases: You need to adjust only the playback volume of the app, and do not adjust the playback volume of the system.
  • When to call: After creating the engine [createEngine].
  • Caution: This interface triggers startup switchover of the device. You are advised not to invoke this interface frequently to avoid unnecessary overhead and hardware problems. This interface may cause the volume mode to switch between call and media. If the media volume is inconsistent with the call volume, the volume may change.
  • Available since: 3.3.0
  • Restrictions: Only for Windows.

getSpeakerVolumeInAPP

getSpeakerVolumeInAPP
getSpeakerVolumeInAPP(deviceID: string): number
Get the volume of the speaker in the App, only support Windows.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
deviceIDstringID of a device obtained by [getAudioDeviceList].

Details

Get the volume of the speaker in the App, only support Windows.

  • When to call: After creating the engine [createEngine].
  • Related APIs: Set the volume of the speaker in the App [setSpeakerVolumeInAPP].
  • Available since: 3.3.0.
  • Restrictions: Only for Windows.

Return

Device volume.

startAudioDeviceVolumeMonitor

startAudioDeviceVolumeMonitor
startAudioDeviceVolumeMonitor(deviceType: ZegoAudioDeviceType, deviceID: string): void
Turn on audio device volume monitoring.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
deviceTypeZegoAudioDeviceTypeAudio device type
deviceIDstringID of a device obtained by [getAudioDeviceList]

Details

Starts the audio device volume monitor. When the volume of the device changes, the changed volume will be called back via [onAudioDeviceVolumeChanged].

  • Caution: Currently, only one audio output device and one audio input device are supported to be monitored at the same time. When this API is called multiple times and the same device type is set, the device ID set to this API during the last call will be overwritten.
  • When to call: After creating the engine via [createEngine].
  • Platform differences: Only supports Windows and macOS.
  • Related APIs: When you no longer need to monitor the device volume, please call [stopAudioDeviceVolumeMonitor] to stop monitoring.
  • Available since: 1.1.0

stopAudioDeviceVolumeMonitor

stopAudioDeviceVolumeMonitor
stopAudioDeviceVolumeMonitor(deviceType: ZegoAudioDeviceType, deviceID: string): void
Turn off audio device volume monitoring. Only for Windows/macOS.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
deviceTypeZegoAudioDeviceTypeAudio device type
deviceIDstringID of a device obtained by [getAudioDeviceList]

Details

Stops the audio device volume monitor.

  • When to call: After creating the engine via [createEngine], and when you no longer need to monitor the device volume.
  • Platform differences: Only supports Windows and macOS.
  • Available since: 1.1.0

muteAudioDevice

muteAudioDevice
muteAudioDevice(deviceType: ZegoAudioDeviceType, deviceID: string, mute: boolean): void
Mutes or unmutes the audio device.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
deviceTypeZegoAudioDeviceTypeAudio device type
deviceIDstringID of a device obtained by [getAudioDeviceList]
mutebooleanWhether to mute the audio device; true means to mute the audio device; false means to unmute the audio device.

Details

Only for Windows / macOS / Linux

enableAudioCaptureDevice

enableAudioCaptureDevice
enableAudioCaptureDevice(enable: boolean): void
Enables or disables the audio capture device.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
enablebooleanWhether to enable the audio capture device, true: enable audio capture device, false: disable audio capture device.

Details

This function is used to control whether to use the audio collection device. When the audio collection device is turned off, the SDK will no longer occupy the audio device. Of course, if the stream is being published at this time, by default, mute data will be used as audio data for streaming. not support Linux.

  • Use cases: When the user never needs to use the audio, you can call this function to close the audio collection.
  • Default value: The default is true.
  • When to call: After creating the engine [createEngine].
  • Related APIs: Turning off or turning on the microphone on the hardware is a time-consuming operation, and there is a certain performance overhead when the user performs frequent operations. [muteMicrophone] is generally recommended.
  • Available since: 1.1.0
  • Restrictions: None.

enableCamera

enableCamera
enableCamera(enable: boolean, channel: ZegoPublishChannel): void
Turns on/off the camera (for the specified channel).
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
enablebooleanWhether to turn on the camera, true: turn on camera, false: turn off camera
channelZegoPublishChannelPublishing stream channel

Details

This function is used to control whether to start the capture of the camera. After the camera is turned off, the video capture will not be performed. At this time, there will be no video data for local preview and push streaming.

  • Default value: The default is true which means the camera is turned on.
  • When to call: After creating the engine [createEngine].
  • Caution: In the case of using the custom video capture function [enableCustomVideoCapture], since the developer has taken over the video data capture, the SDK is no longer responsible for the video data capture, but this function still affects whether to encode or not. Therefore, when developers use custom video capture, please ensure that the value of this function is true.
  • Available since: 1.1.0
  • Restrictions: None.

useVideoDevice

useVideoDevice
useVideoDevice(deviceID: string, channel: ZegoPublishChannel): void
Chooses to use the specified video device (for the specified channel).
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
deviceIDstringID of a device obtained by [getVideoDeviceList]
channelZegoPublishChannelPublishing stream channel

Details

Only for Windows / macOS / Linux

getVideoDeviceList

getVideoDeviceList
getVideoDeviceList(): ZegoDeviceInfo[]
Gets a list of video devices.
Declared in ZegoExpressEngine.js

Only for Windows / macOS / Linux

Video device List

getDefaultVideoDeviceID

getDefaultVideoDeviceID
getDefaultVideoDeviceID(): string
Get the device ID of the default video device.
Declared in ZegoExpressEngine.js

Only for Windows / macOS / Linux

Default video device ID

startSoundLevelMonitor

startSoundLevelMonitor
startSoundLevelMonitor(millisecond: number): void
Starts sound level monitoring. Support setting the listening interval.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
millisecondnumberMonitoring time period of the sound level, in milliseconds, has a value range of [100, 3000]. Default is 100 ms.

Details

After starting monitoring, you can receive local audio sound level via [onCapturedSoundLevelUpdate] callback, and receive remote audio sound level via [onRemoteSoundLevelUpdate] callback. Before entering the room, you can call [startPreview] with this function and combine it with [onCapturedSoundLevelUpdate] callback to determine whether the audio device is working properly.

  • Use cases: During the publishing and playing process, determine who is talking on the wheat and do a UI presentation.
  • When to call: After the engine is created [createEngine].
  • Caution: 1. [onCapturedSoundLevelUpdate] and [onRemoteSoundLevelUpdate] callback notification period is the value set by the parameter. If you want to use advanced feature of sound level, please use the function of the same name (the parameter type is ZegoSoundLevelConfig) instead. 2. After the sound monitoring is started, even if the local audio capture is not started, [onCapturedSoundLevelUpdate] will have a callback, and the sound level is 0.
  • Available since: 1.15.0

startSoundLevelMonitorWithConfig

startSoundLevelMonitorWithConfig
startSoundLevelMonitorWithConfig(config: ZegoSoundLevelConfig): void
Starts sound level monitoring. Support enable some advanced feature.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
configZegoSoundLevelConfigConfiguration for starts the sound level monitor.

Details

After starting monitoring, you can receive local audio sound level via [onCapturedSoundLevelUpdate] callback, and receive remote audio sound level via [onRemoteSoundLevelUpdate] callback. Before entering the room, you can call [startPreview] with this function and combine it with [onCapturedSoundLevelUpdate] callback to determine whether the audio device is working properly.

  • Use cases: During the publishing and playing process, determine who is talking on the wheat and do a UI presentation.
  • When to call: After the engine is created [createEngine].
  • Caution: 1. [onCapturedSoundLevelUpdate] and [onRemoteSoundLevelUpdate] callback notification period is the value set by the parameter. 2. After the sound monitoring is started, even if the local audio capture is not started, [onCapturedSoundLevelUpdate] will have a callback, and the sound level is 0.
  • Available since: 2.10.0

stopSoundLevelMonitor

stopSoundLevelMonitor
stopSoundLevelMonitor(): void
Stops sound level monitoring.
Declared in ZegoExpressEngine.js

After the monitoring is stopped, the callback of the local/remote audio sound level will be stopped.

  • When to call: After the engine is created [createEngine].
  • Related APIs: Soundwave monitoring can be initiated via [startSoundLevelMonitor].
  • Available since: 1.1.0

startAudioSpectrumMonitor

startAudioSpectrumMonitor
startAudioSpectrumMonitor(millisecond: number): void
Starts audio spectrum monitoring. Support setting the listening interval.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
millisecondnumberMonitoring time period of the audio spectrum, in milliseconds, the minimum value is 10. Default is 500 ms.

Details

After starting monitoring, you can receive local audio spectrum via [onCapturedAudioSpectrumUpdate] callback, and receive remote audio spectrum via [onRemoteAudioSpectrumUpdate] callback.

  • Use cases: In the host K song scene, has been published or played under the premise that the host or audience to see the tone and volume change animation.
  • When to call: After the engine is created [createEngine].
  • Caution: [onCapturedAudioSpectrumUpdate] and [onRemoteAudioSpectrumUpdate] callback notification period is the value set by the parameter.
  • Available since: 1.15.0

stopAudioSpectrumMonitor

stopAudioSpectrumMonitor
stopAudioSpectrumMonitor(): void
Stops audio spectrum monitoring.
Declared in ZegoExpressEngine.js

After the monitoring is stopped, the callback of the local/remote audio spectrum will be stopped.

  • When to call: After the engine is created [createEngine].
  • Related APIs: Audio spectrum monitoring can be initiated via [startAudioSpectrumMonitor].
  • Available since: 1.1.0

enableHeadphoneMonitor

enableHeadphoneMonitor
enableHeadphoneMonitor(enable: boolean): void
Enables or disables headphone monitoring.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
enablebooleanWhether to use headphone monitor, true: enable, false: disable

Details

Enable/Disable headphone monitor, and users hear their own voices as they use the microphone to capture sounds.

  • When to call: After the engine is created [createEngine].
  • Default value: Disable.
  • Caution: 1. This setting does not actually take effect until both the headset and microphone are connected. 2. The default is to return after acquisition and before pre-processing. If you need to return after pre-processing, please contact ZEGO technical support.
  • Available since: 1.9.0

setHeadphoneMonitorVolume

setHeadphoneMonitorVolume
setHeadphoneMonitorVolume(volume: number): void
Sets the headphone monitor volume.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
volumenumberheadphone monitor volume, range from 0 to 200, 60 as default.

Details

set headphone monitor volume.

  • When to call: After the engine is created [createEngine].
  • Caution: This setting does not actually take effect until both the headset and microphone are connected.
  • Related APIs: Enables or disables headphone monitoring via [enableHeadphoneMonitor].
  • Available since: 1.9.0

enableMixSystemPlayout

enableMixSystemPlayout
enableMixSystemPlayout(enable: boolean): void
Enable or disable system audio capture.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
enablebooleanWhether to mix system playout.

Details

Enable sound card capture to mix sounds played by the system into the publishing stream, such as sounds played by the browser, sounds played by the third-party player, etc.

  • Default value: Default is disable.
  • When to call: Called this function after calling [startPublishingStream] or [startPreview].
  • Caution: The system sound card sound does not include streaming sound, media player sound and sound effect player sound.
  • Related APIs: [setMixSystemPlayoutVolume] function can set system audio capture volume.
  • Platform differences: Only supports Windows and macOS.
  • Available since: 1.9.0
  • Restrictions: None.

setMixSystemPlayoutVolume

setMixSystemPlayoutVolume
setMixSystemPlayoutVolume(volume: number): void
set system audio capture volume.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
volumenumberthe volume. Valid range [0, 200], default is 100.

Details

set system audio capture volume.

  • Use cases: User needs to adjust the volume which system playout mix to stream publishing.
  • When to call /Trigger: Called this function after calling [startPublishingStream] or [startPreview].
  • Related APIs: [enableMixSystemPlayout] enable or disable mix system playout.
  • Platform differences: Only supports Windows and macOS.
  • Available since: 2.4.0
  • Restrictions: None.

enableMixEnginePlayout

enableMixEnginePlayout
enableMixEnginePlayout(enable: boolean): void
Enable or disable mix SDK playout to stream publishing.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
enablebooleanWhether to mix engine playout

Details

Enable mix SDK playout sounds into the stream publishing.

  • Use cases: Users need to mix the sound of SDK playout into stream publishing. For example, when the class scene, the teacher and student Co-hosting, and the teacher can mix the play streaming sound into the publish streaming.
  • Default value: Default is disable.
  • When to call /Trigger: Called this function after calling [startPublishingStream] or [startPreview].
  • Available since: 1.1.0
  • Restrictions: None.

startAudioVADStableStateMonitor

startAudioVADStableStateMonitor
startAudioVADStableStateMonitor(type: ZegoAudioVADStableStateMonitorType, millisecond: number): void
Start audio VAD stable state monitoring, and the monitoring period can be set.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
typeZegoAudioVADStableStateMonitorTypeaudio VAD monitor type.
millisecondnumbermonitoring period default 3000. value of [200, 10000]

Details

After monitoring is started, you can use the [onAudioVADStateUpdate] callback to receive the specified type of audio VAD callback.

  • Use cases: For example, when you specify the type of collection and use the microphone to collect, you can check whether the host has continuous and stable voice input through this interface.
  • When to call: Before publish stream, you can call [startPreview] with this function and combine it with [onAudioVADStateUpdate] callback to determine whether the audio device is working properly.
  • Related APIs: [stopAudioVADStableStateMonitor].
  • Restrictions: None.

stopAudioVADStableStateMonitor

stopAudioVADStableStateMonitor
stopAudioVADStableStateMonitor(type: ZegoAudioVADStableStateMonitorType): void
Stop audio VAD stable state monitoring.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
typeZegoAudioVADStableStateMonitorTypeaudio VAD monitor type.

Details

After calling this interface, the specified type of [onAudioVADStateUpdate] callback can no longer be received.

  • When to call: None.
  • Related APIs: [startAudioVADStableStateMonitor].
  • Available since: 2.14.0
  • Restrictions: None.

onAudioDeviceStateChanged

onAudioDeviceStateChanged
onAudioDeviceStateChanged(updateType: ZegoUpdateType, deviceType: ZegoAudioDeviceType, deviceInfo: ZegoDeviceInfo): void
The callback triggered when there is a change to audio devices (i.e. new device added or existing device deleted).
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
updateTypeZegoUpdateTypeUpdate type (add/delete)
deviceTypeZegoAudioDeviceTypeAudio device type
deviceInfoZegoDeviceInfoAudio device information

Details

By listening to this callback, users can update the sound collection or output using a specific device when necessary. When to trigger: This callback is triggered when an audio device is added or removed from the system.

  • Platform differences: Only supports Windows and macOS.
  • Available since: 1.1.0
  • Restrictions: None.

onAudioDeviceVolumeChanged

onAudioDeviceVolumeChanged
onAudioDeviceVolumeChanged(deviceType: ZegoAudioDeviceType, deviceID: string, volume: number): void
The callback triggered when there is a change of the volume for the audio devices.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
deviceTypeZegoAudioDeviceTypeAudio device type
deviceIDstringAudio device ID
volumenumberaudio device volume

Details

Audio device volume change event callback. When to trigger: After calling the [startAudioDeviceVolumeMonitor] function to start the device volume monitor, and the volume of the monitored audio device changes.

  • Platform differences: Only supports Windows and macOS.
  • Available since: 1.1.0

onVideoDeviceStateChanged

onVideoDeviceStateChanged
onVideoDeviceStateChanged(updateType: ZegoUpdateType, deviceInfo: ZegoDeviceInfo): void
The callback triggered when there is a change to video devices (i.e. new device added or existing device deleted).
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
updateTypeZegoUpdateTypeUpdate type (add/delete)
deviceInfoZegoDeviceInfoAudio device information

Details

By listening to this callback, users can update the video capture using a specific device when necessary. When to trigger: This callback is triggered when a video device is added or removed from the system.

  • Platform differences: Only supports Windows and macOS.
  • Available since: 1.1.0
  • Restrictions: None

onCapturedSoundLevelUpdate

onCapturedSoundLevelUpdate
onCapturedSoundLevelUpdate(soundLevel: number): void
The local captured audio sound level callback.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
soundLevelnumberLocally captured sound level value, ranging from 0.0 to 100.0 (This value only represents the range of the sound level value returned by the callback, not the precision.) .

Details

The local captured audio sound level callback.

  • Trigger: After you start the sound level monitor by calling [startSoundLevelMonitor].
  • Caution: 1. The callback notification period is the parameter value set when the [startSoundLevelMonitor] is called. The callback value is the default value of 0 When you have not called the interface [startPublishingStream] and [startPreview]. 2. This callback is a high-frequency callback, and it is recommended not to do complex logic processing inside the callback.
  • Related APIs: Start sound level monitoring via [startSoundLevelMonitor]. Monitoring remote played audio sound level by callback [onRemoteSoundLevelUpdate]
  • Available since: 1.1.0

onCapturedSoundLevelInfoUpdate

onCapturedSoundLevelInfoUpdate
onCapturedSoundLevelInfoUpdate(soundLevelInfo: ZegoSoundLevelInfo *): void
The local captured audio sound level callback, supported vad.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
soundLevelInfoZegoSoundLevelInfo *Locally captured sound level value, ranging from 0.0 to 100.0 (This value only represents the range of the sound level value returned by the callback, not the precision.).

Details

The local captured audio sound level callback.

  • Trigger: After you start the sound level monitor by calling [startSoundLevelMonitor].
  • Caution: 1. The callback notification period is the parameter value set when the [startSoundLevelMonitor] is called. 2. This callback is a high-frequency callback, and it is recommended not to do complex logic processing inside the callback.
  • Related APIs: Start sound level monitoring via [startSoundLevelMonitor]. Monitoring remote played audio sound level by callback [onRemoteSoundLevelUpdate] or [onRemoteSoundLevelInfoUpdate].
  • Available since: 2.10.0

onRemoteSoundLevelUpdate

onRemoteSoundLevelUpdate
onRemoteSoundLevelUpdate(soundLevels: Object): void
The remote playing streams audio sound level callback.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
soundLevelsObjectRemote sound level hash map, key is the streamID, value is the sound level value of the corresponding streamID, value ranging from 0.0 to 100.0 (This value only represents the range of the sound level value returned by the callback, not the precision.).

Details

The remote playing streams audio sound level callback.

  • Trigger: After you start the sound level monitor by calling [startSoundLevelMonitor], you are in the state of playing the stream [startPlayingStream].
  • Caution: The callback notification period is the parameter value set when the [startSoundLevelMonitor] is called.
  • Related APIs: Start sound level monitoring via [startSoundLevelMonitor]. Monitoring local captured audio sound by callback [onCapturedSoundLevelUpdate] or [onCapturedSoundLevelInfoUpdate].
  • Available since: 1.1.0

onLocalCaptureVideoData

onLocalCaptureVideoData
onLocalCaptureVideoData(videoParam: ZegoVideoFrameObject): void
Callback to local capture video data.
Declared in ZegoExpressEngine.js
NameTypeDescription
videoParamZegoVideoFrameObjectvideo param.

onRemotePlayVideoData

onRemotePlayVideoData
onRemotePlayVideoData(videoParam: ZegoVideoFrameObject): void
Callback to play stream video data.
Declared in ZegoExpressEngine.js
NameTypeDescription
videoParamZegoVideoFrameObjectvideo param.

onRemoteSoundLevelInfoUpdate

onRemoteSoundLevelInfoUpdate
onRemoteSoundLevelInfoUpdate(soundLevelInfos: Map<String, ZegoSoundLevelInfo>): void
The remote playing streams audio sound level callback, supported vad.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
soundLevelInfosMap<String, ZegoSoundLevelInfo>Remote sound level hash map, key is the streamID, value is the sound level value of the corresponding streamID, value ranging from 0.0 to 100.0 (This value only represents the range of the sound level value returned by the callback, not the precision.).

Details

The remote playing streams audio sound level callback.

  • Trigger: After you start the sound level monitor by calling [startSoundLevelMonitor], you are in the state of playing the stream [startPlayingStream].
  • Caution: The callback notification period is the parameter value set when the [startSoundLevelMonitor] is called.
  • Related APIs: Start sound level monitoring via [startSoundLevelMonitor]. Monitoring local captured audio sound by callback [onCapturedSoundLevelUpdate] or [onCapturedSoundLevelInfoUpdate].
  • Available since: 2.10.0

onCapturedAudioSpectrumUpdate

onCapturedAudioSpectrumUpdate
onCapturedAudioSpectrumUpdate(audioSpectrum: number[]): void
The local captured audio spectrum callback.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
audioSpectrumnumber[]Locally captured audio spectrum value list. Spectrum value range is [0-2^30].

Details

The local captured audio spectrum callback.

  • Trigger: After you start the audio spectrum monitor by calling [startAudioSpectrumMonitor].
  • Caution: The callback notification period is the parameter value set when the [startAudioSpectrumMonitor] is called. The callback value is the default value of 0 When you have not called the interface [startPublishingStream] and [startPreview].
  • Related APIs: Start audio spectrum monitoring via [startAudioSpectrumMonitor]. Monitoring remote played audio spectrum by callback [onRemoteAudioSpectrumUpdate]
  • Available since: 1.1.0

onRemoteAudioSpectrumUpdate

onRemoteAudioSpectrumUpdate
onRemoteAudioSpectrumUpdate(audioSpectrums: object): void
The remote playing streams audio spectrum callback.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
audioSpectrumsobjectRemote audio spectrum hash map, key is the streamID, value is the audio spectrum list of the corresponding streamID. Spectrum value range is [0-2^30]

Details

The remote playing streams audio spectrum callback.

  • Trigger: After you start the audio spectrum monitor by calling [startAudioSpectrumMonitor], you are in the state of playing the stream [startPlayingStream].
  • Caution: The callback notification period is the parameter value set when the [startAudioSpectrumMonitor] is called.
  • Related APIs: Start audio spectrum monitoring via [startAudioSpectrumMonitor]. Monitoring local played audio spectrum by callback [onCapturedAudioSpectrumUpdate].
  • Available since: 1.1.0

onLocalDeviceExceptionOccurred

onLocalDeviceExceptionOccurred
onLocalDeviceExceptionOccurred(exceptionType: ZegoDeviceExceptionType, deviceType: ZegoDeviceType, deviceID: string): void
The callback triggered when a local device exception occurred.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
exceptionTypeZegoDeviceExceptionTypeThe type of the device exception.
deviceTypeZegoDeviceTypeThe type of device where the exception occurred.
deviceIDstringDevice ID. Currently, only desktop devices are supported to distinguish different devices; for mobile devices, this parameter will return an empty string.

Details

The callback triggered when a local device exception occurs.

  • Trigger: This callback is triggered when the function of the local audio or video device is abnormal.
  • Available since: 2.15.0

onRemoteCameraStateUpdate

onRemoteCameraStateUpdate
onRemoteCameraStateUpdate(streamID: string, state: ZegoRemoteDeviceState): void
The callback triggered when the state of the remote camera changes.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
streamIDstringStream ID.
stateZegoRemoteDeviceStateRemote camera status.

Details

The callback triggered when the state of the remote camera changes.

  • Use cases: Developers of 1v1 education scenarios or education small class scenarios and similar scenarios can use this callback notification to determine whether the camera device of the remote publishing stream device is working normally, and preliminary understand the cause of the device problem according to the corresponding state.
  • Trigger: When the state of the remote camera device changes, such as switching the camera, by monitoring this callback, it is possible to obtain an event related to the far-end camera, which can be used to prompt the user that the video may be abnormal.
  • Caution: This callback will not be called back when the remote stream is play from the CDN, or when custom video acquisition is used at the peer.
  • Available since: 1.1.0

onRemoteMicStateUpdate

onRemoteMicStateUpdate
onRemoteMicStateUpdate(streamID: string, state: ZegoRemoteDeviceState): void
The callback triggered when the state of the remote microphone changes.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
streamIDstringStream ID.
stateZegoRemoteDeviceStateRemote microphone status.

Details

The callback triggered when the state of the remote microphone changes.

  • Use cases: Developers of 1v1 education scenarios or education small class scenarios and similar scenarios can use this callback notification to determine whether the microphone device of the remote publishing stream device is working normally, and preliminary understand the cause of the device problem according to the corresponding state.
  • Trigger: When the state of the remote microphone device is changed, such as switching a microphone, etc., by listening to the callback, it is possible to obtain an event related to the remote microphone, which can be used to prompt the user that the audio may be abnormal.
  • Caution: This callback will not be called back when the remote stream is play from the CDN, or when custom audio acquisition is used at the peer (But the stream is not published to the ZEGO RTC server.).
  • Available since: 1.1.0

onRemoteSpeakerStateUpdate

onRemoteSpeakerStateUpdate
onRemoteSpeakerStateUpdate(streamID: string, state: ZegoRemoteDeviceState): void
The callback triggered when the state of the remote speaker changes.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
streamIDstringStream ID.
stateZegoRemoteDeviceStateRemote speaker status.

Details

The callback triggered when the state of the remote microphone changes.

  • Use cases: Developers of 1v1 education scenarios or education small class scenarios and similar scenarios can use this callback notification to determine whether the speaker device of the remote publishing stream device is working normally, and preliminary understand the cause of the device problem according to the corresponding state.
  • Trigger: When the state of the remote speaker device changes, such as switching the speaker, by monitoring this callback, you can get events related to the remote speaker.
  • Caution: This callback will not be called back when the remote stream is play from the CDN.
  • Available since: 1.1.0

onAudioVADStateUpdate

onAudioVADStateUpdate
onAudioVADStateUpdate(type: ZegoAudioVADStableStateMonitorType, state: ZegoAudioVADType): void
Callback for audio VAD stable state update.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
typeZegoAudioVADStableStateMonitorTypeaudio VAD monitor type
stateZegoAudioVADTypeVAD result

Details

Callback for audio VAD stable state update. When to trigger: the [startAudioVADStableStateMonitor] function must be called to start the audio VAD monitor and you must be in a state where it is publishing the audio and video stream or be in [startPreview] state.

  • Related APIs: [startAudioVADStableStateMonitor], [stopAudioVADStableStateMonitor].
  • Available since: 2.14.0
  • Restrictions: The callback notification period is 3 seconds.

getCurrentAudioDevice

getCurrentAudioDevice
getCurrentAudioDevice(deviceType: ZegoAudioDeviceType): ZegoDeviceInfo
Get the audio device information currently in use.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
deviceTypeZegoAudioDeviceTypeAudio device type.Required
.

Details

Get the audio device information currently in use.

  • Use cases: Used for scenes that need to manually switch between multiple audio devices.
  • When to call: Called this function after calling [startPublishingStream] or [startPreview].
  • Related APIs: The default audio device ID can be obtained through [getDefaultAudioDeviceID].
  • Available since: 2.12.0
  • Restrictions: Only supports Windows and macOS.

Return

Audio device information.

enableAEC

enableAEC
enableAEC(enable: boolean): void
Whether to enable acoustic echo cancellation (AEC).
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
enablebooleanWhether to enable echo cancellation, true: enable, false: disable

Details

Turning on echo cancellation, the SDK filters the collected audio data to reduce the echo component in the audio. Use case: When you need to reduce the echo to improve the call quality and user experience, you can turn on this feature.

  • When to call: It needs to be called after [createEngine].
  • Caution: The AEC function only supports the processing of sounds playbacked through the SDK, such as sounds played by the playing stream, media player, audio effect player, etc. Before this function is called, the SDK automatically determines whether to use AEC. Once this function is called, the SDK does not automatically determine whether to use AEC.
  • Related APIs: Developers can use [enableHeadphoneAEC] to set whether to enable AEC when using headphones, and use [setAECMode] to set the echo cancellation mode.
  • Available since: 1.1.0
  • Restrictions: None.

setAECMode

setAECMode
setAECMode(mode: ZegoAECMode): void
Sets the acoustic echo cancellation (AEC) mode.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
modeZegoAECModeEcho cancellation mode

Details

When [enableAEC] is used to enable echo cancellation, this function can be used to switch between different echo cancellation modes to control the degree of echo cancellation. Use case: When the default echo cancellation effect does not meet expectations, this function can be used to adjust the echo cancellation mode.

  • Default value: When this function is not called, the default echo cancellation mode is [Aggressive].
  • When to call: It needs to be called after [createEngine].
  • Available since: 1.1.0
  • Restrictions: The value set by this function is valid only after the echo cancellation function is turned on.

enableAGC

enableAGC
enableAGC(enable: boolean): void
Enables or disables automatic gain control (AGC).
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
enablebooleanWhether to enable automatic gain control, true: enable, false: disable

Details

After turning on this function, the SDK can automatically adjust the microphone volume to adapt to near and far sound pickups and keep the volume stable. Use case: When you need to ensure volume stability to improve call quality and user experience, you can turn on this feature.

  • When to call: It needs to be called after [createEngine].
  • Caution: Before this function is called, the SDK automatically determines whether to use AGC. Once this function is called, the SDK does not automatically determine whether to use AGC.
  • Available since: 1.1.0
  • Restrictions: None.

enableANS

enableANS
enableANS(enable: boolean): void
Enables or disables active noise suppression (ANS, aka ANC).
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
enablebooleanWhether to enable noise suppression, true: enable, false: disable

Details

Enable the noise suppression can reduce the noise in the audio data and make the human voice clearer. Use case: When you need to suppress noise to improve call quality and user experience, you can turn on this feature.

  • When to call: It needs to be called after [createEngine].
  • Related APIs: This function has a better suppression effect on continuous noise (such as the sound of rain, white noise). If you need to turn on transient noise suppression, please use [enableTransientANS]. And the noise suppression mode can be set by [setANSMode].
  • Caution: Before this function is called, the SDK automatically determines whether to use ANS. Once this function is called, the SDK does not automatically determine whether to use ANS.
  • Available since: 1.1.0
  • Restrictions: None.

enableTransientANS

enableTransientANS
enableTransientANS(enable: boolean): void
Enables or disables transient noise suppression.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
enablebooleanWhether to enable transient noise suppression, true: enable, false: disable

Details

Enable the transient noise suppression can suppress the noises such as keyboard and desk knocks. Use case: When you need to suppress transient noise to improve call quality and user experience, you can turn on this feature.

  • Default value: When this function is not called, this is disabled by default.
  • When to call: It needs to be called after [createEngine].
  • Related APIs: This function will not suppress normal noise after it is turned on. If you need to turn on normal noise suppression, please use [enableANS].
  • Available since: 1.17.0
  • Restrictions: None.

setANSMode

setANSMode
setANSMode(mode: ZegoANSMode): void
Sets the automatic noise suppression (ANS) mode.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
modeZegoANSModeAudio Noise Suppression mode

Details

When [enableANS] is used to enable noise suppression, this function can be used to switch between different noise suppression modes to control the degree of noise suppression. Use case: When the default noise suppression effect does not meet expectations, this function can be used to adjust the noise suppression mode.

  • Default value: When this function is not called, the default automatic noise suppression (ANS) mode is [Medium].
  • When to call: It needs to be called after [createEngine].
  • Available since: 1.1.0
  • Restrictions: The value set by this function is valid only after the noise suppression function is turned on.

setAudioEqualizerGain

setAudioEqualizerGain
setAudioEqualizerGain(bandIndex: number, bandGain: number): void
Set the sound equalizer (EQ).
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
bandIndexnumberBand frequency index, the value range is [0, 9], corresponding to 10 frequency bands, and the center frequencies are [31, 62, 125, 250, 500, 1K, 2K, 4K, 8K, 16K] Hz.
bandGainnumberBand gain for the index, the value range is [-15, 15]. Default value is 0, if all gain values in all frequency bands are 0, EQ function will be disabled.

Details

Call this function to set the sound equalizer adjust the tone.

  • Use cases: Often used in voice chatroom, KTV.
  • When to call: It should be called after the engine has started.
  • Available since: 1.12.0
  • Restrictions: None.

setVoiceChangerPreset

setVoiceChangerPreset
setVoiceChangerPreset(preset: ZegoVoiceChangerPreset): void
Setting up the voice changer via preset enumeration.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
presetZegoVoiceChangerPresetThe voice changer preset enumeration.

Details

Call this function to use preset voice changer effect.

  • Use cases: Often used in live broadcasting, voice chatroom and KTV.
  • When to call: It needs to be called after [createEngine].
  • Related APIs: If you need advanced voice changer effect, please use [setVoiceChangerParam]. The effect of using this function together with [setReverbPreset] may be different from what is expected. If you need to use it at the same time, it is recommended to enable the voice changer first, and then enable the reverb. Using ANDROID/ETHEREAL preset voice changer effect will modify reverberation or reverberation echo parameters. Calling [setVoiceChangerParam], [setReverbAdvancedParam], [setReverbEchoParam] may affect the voice changer effect after use these preset voice changer effect. If you need advanced reverb/echo/electronic effects/voice changer effect, please use [setReverbAdvancedParam], [setReverbEchoParam], [setElectronicEffects], [setVoiceChangerParam] together.
  • Available since: 1.17.0

setVoiceChangerParam

setVoiceChangerParam
setVoiceChangerParam(param: ZegoVoiceChangerParam): void
Setting up the specific voice changer parameters.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
paramZegoVoiceChangerParamVoice changer parameters.

Details

Call this function to set custom voice changer effect.

  • Use cases: Often used in live broadcasting, voice chatroom and KTV.
  • When to call: It needs to be called after [createEngine].
  • Related APIs: [setVoiceChangerPreset] provide a set of preset voice changer effects. If you need advanced reverb/echo/voice changer effect, please use [setReverbAdvancedParam], [setReverbEchoParam], [setVoiceChangerParam] together.
  • Available since: 1.10.0

setReverbPreset

setReverbPreset
setReverbPreset(preset: ZegoReverbPreset): void
Setting up the reverberation via preset enumeration.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
presetZegoReverbPresetThe reverberation preset enumeration.

Details

Call this function to set preset reverb effect.

  • Use cases: Often used in live broadcasting, voice chatroom and KTV.
  • When to call: It needs to be called after [createEngine]. Support call this function to change preset reverb effect during publishing stream.
  • Related APIs: If you need advanced reverb effect, please use [setReverbAdvancedParam]. The effect of using this function together with [setVoiceChangerPreset] may be different from what is expected. If you need to use it at the same time, it is recommended to enable the voice changer first, and then enable the reverb. If you need advanced reverb/echo/voice changer effect, please use [setReverbAdvancedParam], [setReverbEchoParam], [setVoiceChangerParam] together.
  • Available since: 1.17.0

setReverbAdvancedParam

setReverbAdvancedParam
setReverbAdvancedParam(param: ZegoReverbAdvancedParam): void
Setting up the specific reverberation parameters.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
paramZegoReverbAdvancedParamReverb advanced parameter.

Details

Call this function to set preset reverb effect.

  • Use cases: Often used in live broadcasting, voice chatroom and KTV.
  • When to call: It needs to be called after [createEngine].
  • Caution: Different values dynamically set during publishing stream will take effect. When all parameters are set to 0, the reverberation is turned off.
  • Related APIs: [setReverbPreset] provide a set of preset reverb effects. If you need advanced reverb/echo/voice changer effect, please use [setReverbAdvancedParam], [setReverbEchoParam], [setVoiceChangerParam] together.
  • Available since: 1.10.0

setReverbEchoParam

setReverbEchoParam
setReverbEchoParam(param: ZegoReverbEchoParam): void
Setting up the specific reverberation echo parameters.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
paramZegoReverbEchoParamThe reverberation echo parameter.

Details

Call this function to set reverb echo effect. This function can be used with voice changer and reverb to achieve a variety of custom sound effects.

  • Use cases: Often used in live broadcasting, voice chatroom and KTV.
  • When to call: It needs to be called after [createEngine].
  • Related APIs: If you need advanced reverb/echo/voice changer effect, please use [setReverbAdvancedParam], [setReverbEchoParam], [setVoiceChangerParam] together.
  • Available since: 1.17.0

enableVirtualStereo

enableVirtualStereo
enableVirtualStereo(enable: boolean, angle: number): void
Enable or disable the virtual stereo effect when publishing stream.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
enablebooleantrue to turn on the virtual stereo, false to turn off the virtual stereo.
anglenumberThe angle of the sound source in virtual stereo in the range of -1 ~ 360, with 90 being directly in front, 0 / 180 / 270 corresponding to the rightmost and leftmost respectively. In particular, when set to -1, it is all round virtual stereo effects.

Details

Call this function to enable / disable the virtual stereo effect when publishing stream.

  • Use cases: Often used in live broadcasting, voice chatroom and KTV.
  • When to call: It needs to be called after [createEngine].
  • Caution: You need to set up a dual channel with [setAudioConfig] for the virtual stereo to take effect.
  • Available since: 1.10.0; Starting from 2.15.0, the angle parameter supports setting -1 to present a all round virtual stereo effect.

sendBroadcastMessage

sendBroadcastMessage
sendBroadcastMessage(roomID: string, message: string): Promise<Object>
Sends a Broadcast Message.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
roomIDstringRoom ID, a string of less 128 bytes in length.
Caution:
1. room ID is defined by yourself.
2. Only support numbers, English characters and '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '=', '-', '`', ';', '’', ',', '.', '<', '>', ''.
3. If you need to communicate with the Web SDK, please do not use '%'.
messagestringThe content of the message. Required: Yes. Value range: The length does not exceed 1024 bytes.

Details

Send a broadcast message to the room, users who have entered the same room can receive the message, and the message is reliable.

  • Use cases: Generally used in the live room.
  • When to call: After calling [loginRoom] to log in to the room.
  • Related callbacks: The room broadcast message can be received through [onIMRecvBroadcastMessage].
  • Related APIs: Barrage messages can be sent through the [sendBarrageMessage] function, and custom command can be sent through the [sendCustomCommand] function.
  • Available since: 1.2.1
  • Restrictions: The frequency of sending broadcast messages in the same room cannot be higher than 10 messages/s. The maximum QPS for a single user to call this interface within a single room is 2. For restrictions on the use of this function, please contact ZEGO technical support.

Return

Send broadcast message result callback

sendBarrageMessage

sendBarrageMessage
sendBarrageMessage(roomID: string, message: string): Promise<Object>
Sends a Barrage Message (bullet screen) to all users in the same room, without guaranteeing the delivery.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
roomIDstringRoom ID, a string of less 128 bytes in length.
Caution:
1. room ID is defined by yourself.
2. Only support numbers, English characters and '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '=', '-', '`', ';', '’', ',', '.', '<', '>', ''.
3. If you need to communicate with the Web SDK, please do not use '%'.
messagestringThe content of the message. Required: Yes. Value range: The length does not exceed 1024 bytes.

Details

Send a barrage message to the room, users who have logged in to the same room can receive the message, the message is unreliable.

  • Use cases: Generally used in scenarios where there is a large number of messages sent and received in the room and the reliability of the messages is not required, such as live barrage.
  • When to call: After calling [loginRoom] to log in to the room.
  • Related callbacks: The room barrage message can be received through [onIMRecvBarrageMessage].
  • Related APIs: Broadcast messages can be sent through the [sendBroadcastMessage] function, and custom command can be sent through the [sendCustomCommand] function.
  • Available since: 1.5.0
  • 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.

Return

Send barrage message result callback.

sendCustomCommand

sendCustomCommand
sendCustomCommand(roomID: string, command: string, toUserList: ZegoUser[]): Promise<Object>
Sends a Custom Command to the specified users in the same room.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
roomIDstringRoom ID, a string of less 128 bytes in length.
Caution:
1. room ID is defined by yourself.
2. Only support numbers, English characters and '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '=', '-', '`', ';', '’', ',', '.', '<', '>', ''.
3. If you need to communicate with the Web SDK, please do not use '%'.
commandstringCustom command content. Required: Yes. Value range: The maximum length is 1024 bytes. Caution: To protect privacy, please do not fill in sensitive user information in this interface, including but not limited to mobile phone number, ID number, passport number, real name, etc.
toUserListZegoUser[]List of recipients of signaling. Required: Yes. Value range: user list or [nullptr]. Caution: When it is [nullptr], the SDK will send custom signaling back to all users in the room

Details

Send point-to-point signaling to other users who have logged into the same room, and the message is reliable.

  • Use cases: Generally used for remote control signaling or message sending between users.
  • When to call: After calling [loginRoom] to log in to the room.
  • Related callbacks: The room custom command can be received through [onIMRecvCustomCommand].
  • Related APIs: Broadcast messages can be sent through the [sendBroadcastMessage] function, and barrage messages can be sent through the [sendBarrageMessage] function.
  • Privacy reminder: Please do not fill in sensitive user information in this interface, including but not limited to mobile phone number, ID number, passport number, real name, etc.
  • Available since: 1.2.1
  • 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.

Return

Send command result callback.

onIMRecvBroadcastMessage

onIMRecvBroadcastMessage
onIMRecvBroadcastMessage(roomID: string, messageList: ZegoBroadcastMessageInfo[]): void
The callback triggered when Broadcast Messages are received.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
roomIDstringRoom ID. Value range: The maximum length is 128 bytes.
messageListZegoBroadcastMessageInfo[]List of received messages. Value range: Up to 50 messages can be received each time.

Details

This callback is used to receive broadcast messages sent by other users in the same room.

  • Use cases: Generally used in the live room. When to trigger: After calling [loginRoom] to log in to the room, if a user in the room sends a broadcast message via [sendBroadcastMessage] function, this callback will be triggered.
  • Caution: The broadcast message sent by the user will not be notified through this callback.
  • Related callbacks: You can receive room barrage messages through [onIMRecvBarrageMessage], and you can receive room custom signaling through [onIMRecvCustomCommand].
  • Available since: 1.2.1
  • Restrictions: None

onIMRecvBarrageMessage

onIMRecvBarrageMessage
onIMRecvBarrageMessage(roomID: string, messageList: ZegoBarrageMessageInfo[]): void
The callback triggered when Barrage Messages are received.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
roomIDstringRoom ID. Value range: The maximum length is 128 bytes.
messageListZegoBarrageMessageInfo[]List of received messages. Value range: Up to 50 messages can be received each time.

Details

This callback is used to receive barrage messages sent by other users in the same room.

  • Use cases: Generally used in scenarios where there is a large number of messages sent and received in the room and the reliability of the messages is not required, such as live barrage. When to trigger: After calling [loginRoom] to log in to the room, if a user in the room sends a barrage message through the [sendBarrageMessage] function, this callback will be triggered.
  • Caution: Barrage messages sent by users themselves will not be notified through this callback. When there are a large number of barrage messages in the room, the notification may be delayed, and some barrage messages may be lost.
  • Related callbacks: Develop can receive room broadcast messages through [onIMRecvBroadcastMessage], and can receive room custom signaling through [onIMRecvCustomCommand].
  • Available since: 1.5.0
  • Restrictions: None

onIMRecvCustomCommand

onIMRecvCustomCommand
onIMRecvCustomCommand(roomID: string, fromUser: ZegoUser, command: string): void
The callback triggered when a Custom Command is received.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
roomIDstringRoom ID. Value range: The maximum length is 128 bytes.
fromUserZegoUserSender of the command.
commandstringCommand content received.Value range: The maximum length is 1024 bytes.

Details

This callback is used to receive custom command sent by other users in the same room.

  • Use cases: Generally used in the live room. When to trigger: After calling [loginRoom] to log in to the room, if other users in the room send custom signaling to the developer through the [sendCustomCommand] function, this callback will be triggered.
  • Caution: The custom command sent by the user himself will not be notified through this callback.
  • Related callbacks: You can receive room broadcast messages through [onIMRecvBroadcastMessage], and you can receive room barrage message through [onIMRecvBarrageMessage].
  • Available since: 1.2.1
  • Restrictions: None

createMediaPlayer

createMediaPlayer
createMediaPlayer(): ZegoMediaPlayer
Creates a media player instance.
Declared in ZegoExpressEngine.js

Creates a media player instance. Use case: It is often used to play media resource scenes, For example, play video files, push the video of media resources in combination with custom video acquisition, and the remote end can pull the stream for viewing.

  • When to call: It can be called after the SDK by [createEngine] has been initialized.
  • Caution: The more instances of a media player, the greater the performance overhead on the device.
  • Related APIs: User can call [destroyMediaPlayer] function to destroy a media player instance.
  • Available since: 2.1.0
  • Restrictions: Currently, a maximum of 10 instances can be created, after which it will return null.

Media player instance, null will be returned when the maximum number is exceeded.

destroyMediaPlayer

destroyMediaPlayer
destroyMediaPlayer(mediaPlayer: ZegoMediaPlayer): void
Destroys a media player instance.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
mediaPlayerZegoMediaPlayerThe media player instance object to be destroyed.

Details

Destroys a media player instance.

  • Related APIs: User can call [createMediaPlayer] function to create a media player instance.
  • Available since: 2.1.0

createAudioEffectPlayer

createAudioEffectPlayer
createAudioEffectPlayer(): ZegoAudioEffectPlayer
Creates a audio effect player instance.
Declared in ZegoExpressEngine.js

Creates a audio effect player instance.

  • Use cases: When you need to play short sound effects, such as applause, cheers, etc., you can use audioEffectPlayer to achieve.
  • When to call: It can be called after [createEngine].
  • Related APIs: [destroyAudioEffectPlayer].
  • Available since: 1.16.0
  • Restrictions: Currently, a maximum of 1 instances can be created, after which it will return null.

audio effect player instance, null will be returned when the maximum number is exceeded.

destroyAudioEffectPlayer

destroyAudioEffectPlayer
destroyAudioEffectPlayer(audioEffectPlayer: ZegoAudioEffectPlayer): void
Destroys a audio effect player instance.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
audioEffectPlayerZegoAudioEffectPlayerThe audio effect player instance object to be destroyed.

Details

Destroys the specified audio effect player instance.

  • When to call: It can be called after [createAudioEffectPlayer].
  • Related APIs: [createAudioEffectPlayer].
  • Available since: 1.16.0
  • Restrictions: None.

startRecordingCapturedData

startRecordingCapturedData
startRecordingCapturedData(config: ZegoDataRecordConfig, channel: ZegoPublishChannel): void
Starts to record and directly save the data to a file.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
configZegoDataRecordConfigRecord config.
channelZegoPublishChannelPublishing stream channel.

Details

Starts to record locally captured audio or video and directly save the data to a file, The recorded data will be the same as the data publishing through the specified channel.

  • Caution: Developers should not [stopPreview] or [stopPublishingStream] during recording, otherwise the SDK will end the current recording task. The data of the media player needs to be mixed into the publishing stream to be recorded.
  • Related callbacks: Developers will receive the [onCapturedDataRecordStateUpdate] and the [onCapturedDataRecordProgressUpdate] callback after start recording.
  • Available since: 1.10.0
  • Restrictions: None.

stopRecordingCapturedData

stopRecordingCapturedData
stopRecordingCapturedData(channel: ZegoPublishChannel): void
Stops recording locally captured audio or video.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
channelZegoPublishChannelPublishing stream channel.

Details

Stops recording locally captured audio or video.

  • When to call: After [startRecordingCapturedData].
  • Available since: 1.10.0
  • Restrictions: None.

onCapturedDataRecordStateUpdate

onCapturedDataRecordStateUpdate
onCapturedDataRecordStateUpdate(state: ZegoDataRecordState, errorCode: number, config: ZegoDataRecordConfig, channel: ZegoPublishChannel): void
The callback triggered when the state of data recording (to a file) changes.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
stateZegoDataRecordStateFile recording status.
errorCodenumberError code, please refer to the error codes document https://docs.zegocloud.com/en/5548.html for details.
configZegoDataRecordConfigRecord config.
channelZegoPublishChannelPublishing stream channel.

Details

The callback triggered when the state of data recording (to a file) changes.

  • Use cases: The developer should use this callback to determine the status of the file recording or for UI prompting. When to trigger: After [startRecordingCapturedData] is called, if the state of the recording process changes, this callback will be triggered.
  • Available since: 1.10.0
  • Restrictions: None.

onCapturedDataRecordProgressUpdate

onCapturedDataRecordProgressUpdate
onCapturedDataRecordProgressUpdate(progress: ZegoDataRecordProgress, config: ZegoDataRecordConfig, channel: ZegoPublishChannel): void
The callback to report the current recording progress.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
progressZegoDataRecordProgressFile recording progress, which allows developers to hint at the UI, etc.
configZegoDataRecordConfigRecord config.
channelZegoPublishChannelPublishing stream channel.

Details

Recording progress update callback, triggered at regular intervals during recording.

  • Use cases: Developers can do UI hints for the user interface. When to trigger: After [startRecordingCapturedData] is called, If configured to require a callback, timed trigger during recording.
  • Available since: 1.10.0
  • Restrictions: None.

startNetworkSpeedTest

startNetworkSpeedTest
startNetworkSpeedTest(config: ZegoNetworkSpeedTestConfig, interval: number): void
Start network speed test. Support set speed test interval。
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
configZegoNetworkSpeedTestConfigNetwork speed test configuration.
intervalnumberInterval of network speed test. In milliseconds, default is 3000 ms.

Details

This function supports uplink/downlink network speed test when the network can be connected.

  • Use cases: This function can be used to detect whether the network environment is suitable for pushing/pulling streams with specified bitrates.
  • When to call: It needs to be called after [loginRoom]. If you call [startPublishingStream]/[startPlayingStream] while speed testing, the speed test will automatically stop.
  • Caution: Developers can register [onNetworkSpeedTestQualityUpdate] callback to get the speed test result, which will be triggered every 3 seconds. If an error occurs during the speed test process, [onNetworkSpeedTestError] callback will be triggered. If this function is repeatedly called multiple times, the last functioh call's configuration will be used.
  • Related APIs: Call [stopNetworkSpeedTest] to stop network speed test.
  • Available since: 1.20.0
  • Restrictions: The default maximum allowable test time for a single network speed test is 30 seconds.

stopNetworkSpeedTest

stopNetworkSpeedTest
stopNetworkSpeedTest(): void
Stop network speed test.
Declared in ZegoExpressEngine.js

Stop network speed test.

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

getNetworkTimeInfo

getNetworkTimeInfo
getNetworkTimeInfo(): ZegoNetworkTimeInfo
Obtain synchronization network time information.
Declared in ZegoExpressEngine.js

Obtain synchronization network time(NTP), including timestamp and maximum deviation.

  • Use cases: When performing multi-terminal synchronization behaviors, network time synchronization is required.
  • When to call: It needs to be called after [createEngine].
  • Available since: 2.9.0
  • Restrictions: None.

Network time information.

onNetworkModeChanged

onNetworkModeChanged
onNetworkModeChanged(mode: ZegoNetworkMode): void
Network mode changed callback.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
modeZegoNetworkModeCurrent network mode.

Details

Network mode changed callback. When to trigger: This callback will be triggered when the device's network mode changed, such as switched from WiFi to 5G, or when network is disconnected.

  • Available since: 1.20.0
  • Restrictions: None.

onNetworkSpeedTestError

onNetworkSpeedTestError
onNetworkSpeedTestError(errorCode: number, type: ZegoNetworkSpeedTestType): void
Network speed test error callback.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
errorCodenumberNetwork speed test error code. Please refer to error codes document https://docs.zegocloud.com/en/5548.html for details.
typeZegoNetworkSpeedTestTypeUplink or downlink.

Details

Network speed test error callback.

  • Use cases: This function can be used to detect whether the network environment is suitable for pushing/pulling streams with specified bitrates. When to
  • Trigger: If an error occurs during the speed test, such as: can not connect to speed test server, this callback will be triggered.
  • Available since: 1.20.0
  • Restrictions: None.

onNetworkSpeedTestQualityUpdate

onNetworkSpeedTestQualityUpdate
onNetworkSpeedTestQualityUpdate(quality: ZegoNetworkSpeedTestQuality, type: ZegoNetworkSpeedTestType): void
Network speed test quality callback.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
qualityZegoNetworkSpeedTestQualityNetwork speed test quality.
typeZegoNetworkSpeedTestTypeUplink or downlink.

Details

Network speed test quality callback when the network can be connected.

  • Use cases: This function can be used to detect whether the network environment is suitable for pushing/pulling streams with specified bitrates. When to
  • Trigger: After call [startNetworkSpeedTest] start network speed test, this callback will be triggered. The trigger period is determined by the parameter value specified by call [startNetworkSpeedTest], default value is 3 seconds
  • Caution: When error occurred during network speed test or [stopNetworkSpeedTest] called, this callback will not be triggered.
  • Available since: 1.20.0
  • Restrictions: None.

onNetworkQuality

onNetworkQuality
onNetworkQuality(userID: string, upstreamQuality: ZegoStreamQualityLevel, downstreamQuality: ZegoStreamQualityLevel): void
The network quality callback of users who are publishing in the room.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
userIDstringUser ID, empty means local user
upstreamQualityZegoStreamQualityLevelUpstream network quality
downstreamQualityZegoStreamQualityLevelDownstream network quality

Details

The uplink and downlink network callbacks of the local and remote users, that would be called by default every two seconds for the local and each playing remote user's network quality. Versions 2.10.0 to 2.13.1:

  1. Developer must both publish and play streams before you receive your own network quality callback.
  2. When playing a stream, the publish end has a play stream and the publish end is in the room where it is located, then the user's network quality will be received. Versions 2.14.0 to 2.21.1:
  3. As long as you publish or play a stream, you will receive your own network quality callback.
  4. When you play a stream, the publish end is in the room where you are, and you will receive the user's network quality. Version 2.22.0 and above:
  5. As long as you publish or play a stream, you will receive your own network quality callback.
  6. When you play a stream, the publish end is in the room where you are, and you will receive the user's network quality.
  7. Estimate the network conditions of the remote stream publishing user. If the remote stream publishing user loses one heartbeat, the network quality will be called back as unknown; if the remote stream publishing user's heartbeat loss reaches 3 Second, call back its network quality to die. Use case: When the developer wants to analyze the network condition on the link, or wants to know the network condition of local and remote users. When to
  • Trigger: After publishing a stream by called [startPublishingStream] or playing a stream by called [startPlayingStream].
  • Available since: 2.10.0

enableCustomVideoCapture

enableCustomVideoCapture
enableCustomVideoCapture(enable: boolean, channel: ZegoPublishChannel): void
Enables or disables custom video capture (for the specified channel).
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
enablebooleanenable or disable
channelZegoPublishChannelpublish channel

Details

If the value of enable is true, the video collection function is enabled. If the value of enable is false, the video collection function is disabled. Use case: The App developed by the developer uses the beauty SDK of a third-party beauty manufacturer to broadcast non-camera collected data.

  • Default value: When this function is not called, custom video collection is disabled by default.
  • When to call: After [createEngine], call [startPreview], [startPublishingStream], [createRealTimeSequentialDataManager], and call [logoutRoom] to modify the configuration.
  • Caution: Custom video rendering can be used in conjunction with custom video capture, but when both are enabled, the local capture frame callback for custom video rendering will no longer be triggered, and the developer should directly capture the captured video frame from the custom video capture source.
  • Related callbacks: When developers to open a custom collection, by calling [setCustomVideoCaptureHandler] can be set up to receive a custom collection start-stop event notification.
  • Available since: 1.9.0

enableExternalRender

enableExternalRender
enableExternalRender(enable: boolean): void
enable/disable external render, when external rendering is enabled, data rendering will no longer take place inside the SDK.
Declared in ZegoExpressEngine.js
NameTypeDescription
enablebooleantrue-enable/false-disable

registerCustomVideoCapturePlugin

registerCustomVideoCapturePlugin
registerCustomVideoCapturePlugin(plugin: Number, channel: ZegoPublishChannel, config: Object): void
register custom video capture plugin
Declared in ZegoExpressEngine.js
NameTypeDescription
pluginNumbervideo capture plugin
channelZegoPublishChannelpublish channel
configObjectcustom config. type(1-blend/0-default) is_render-default enable(true-Enable/false-Disable)render.

unregisterCustomVideoCapturePlugin

unregisterCustomVideoCapturePlugin
unregisterCustomVideoCapturePlugin(plugin: Number): void
unregister custom video capture plugin
Declared in ZegoExpressEngine.js
NameTypeDescription
pluginNumbervideo capture plugin

enableCameraVideoDataCapturePlugin

enableCameraVideoDataCapturePlugin
enableCameraVideoDataCapturePlugin(enable: boolean, channel: ZegoPublishChannel): void
Enable or disable the camera video data capture plugin
Declared in ZegoExpressEngine.js
NameTypeDescription
enablebooleanEnable/Disable
channelZegoPublishChannelpublish channel

getCameraVideoDataCapturePlugin

getCameraVideoDataCapturePlugin
getCameraVideoDataCapturePlugin(channel: ZegoPublishChannel): number
Get the camera video data capture plugin, it needs to call interface [enableCameraVideoDataCapturePlugin] open to use.
Declared in ZegoExpressEngine.js
NameTypeDescription
channelZegoPublishChannelpublish channel

Return

The plugin ID

setCustomVideoCaptureFillMode

setCustomVideoCaptureFillMode
setCustomVideoCaptureFillMode(mode: ZegoViewMode, channel: ZegoPublishChannel): void
Sets the video fill mode of custom video capture (for the specified channel).
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
modeZegoViewModeView mode
channelZegoPublishChannelPublishing stream channel

Details

When the custom video collection function is enabled, you can use this interface to set the video zooming and filling mode.

  • Use cases: If the customized collection resolution and SDK coding resolution are inconsistent, THE SDK will process the video frame according to the fill mode and adjust it to the coding resolution.
  • When to call: Before [sendCustomVideoCaptureRawData], [sendCustomVideoCaptureTextureData], [sendCustomVideoCapturePixelBuffer], [sendCustomVideoCaptureEncodedData].
  • Available since: 1.10.0

setCustomVideoCaptureRegionOfInterest

setCustomVideoCaptureRegionOfInterest
setCustomVideoCaptureRegionOfInterest(rectList: Array<ZegoRoiRect>, rectCount: number, channel: ZegoPublishChannel): void
Set the region of interest (ROI) for encoder of custom video capture (for the specified channel).
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
rectListArray<ZegoRoiRect>ROI rectangle area list, currently supports up to 6 areas.
rectCountnumberLength of the rectangle list (count of rectangle).
channelZegoPublishChannelPublish channel

Details

You can set the video encoder's region of interest rectangle areas of custom video capture (for the specified channel) through this function.

  • When to call: After the callback [onStart] is received.
  • Caution: This function is currently an experimental feature, please contact ZEGO technical support before using it.
  • Available since: 2.16.0.
  • Restrictions: Currently, only certain video encoders support this function, please contact ZEGO technical support before using it.

enableCustomVideoProcessing

enableCustomVideoProcessing
enableCustomVideoProcessing(enable: boolean, channel: ZegoPublishChannel): void
Enables or disables custom video processing, and support specifying the publish channel.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
enablebooleanenable or disable. Required: Yes.
channelZegoPublishChannelPublishing stream channel.Required: No.Default value: Main publish channel.

Details

When the developer opens custom pre-processing, by calling [setCustomVideoProcessHandler] you can set the custom video pre-processing callback.

  • Use cases: After the developer collects the video data by himself or obtains the video data collected by the SDK, if the basic beauty and watermark functions of the SDK cannot meet the needs of the developer (for example, the beauty effect cannot meet the expectations), the ZegoEffects SDK can be used to perform the video Some special processing, such as beautifying, adding pendants, etc., this process is the pre-processing of custom video.
  • Default value: Off by default
  • When to call: Must be set before calling [startPreview], [startPublishingStream], [createRealTimeSequentialDataManager]. If you need to modify the configuration, please call [logoutRoom] to log out of the room first, otherwise it will not take effect.
  • Related APIs: Call the [setCustomVideoProcessHandler] function to set the callback before custom video processing.
  • Available since: 2.2.0 (Android/iOS/macOS native), 2.4.0 (Windows/macOS C++).
  • Restrictions: None.

registerCustomVideoProcessPlugin

registerCustomVideoProcessPlugin
registerCustomVideoProcessPlugin(plugin: number, channel: ZegoPublishChannel): void
Register custom video process plugin
Declared in ZegoExpressEngine.js
NameTypeDescription
pluginnumberVideo process plugin
channelZegoPublishChannelPublish channel

setCustomVideoProcessCutRegion

setCustomVideoProcessCutRegion
setCustomVideoProcessCutRegion(left: number, top: number, right: number, bottom: number, channel: ZegoPublishChannel): void
Set the custom video process crop region
Declared in ZegoExpressEngine.js
NameTypeDescription
leftnumberThe value at the left of the horizontal axis of the rectangle
topnumberThe value at the top of the vertical axis of the rectangle
rightnumberThe value at the right of the horizontal axis of the rectangle
bottomnumberThe value at the bottom of the vertical axis of the rectangle
channelZegoPublishChannelPublish channel

enableCustomAudioCaptureProcessing

enableCustomAudioCaptureProcessing
enableCustomAudioCaptureProcessing(enable: boolean, config: ZegoCustomAudioProcessConfig): void
Enable local collection and custom audio processing(before ear return).
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
enablebooleanWhether to enable local capture custom audio processing.
configZegoCustomAudioProcessConfigCustom audio processing configuration.

Details

Enable custom audio processing(before ear return), developers can receive locally collected audio frames through [onProcessCapturedAudioData], and can modify the audio data.

  • Use cases: If the developer wants to implement special functions (such as voice change, bel canto, etc.) through custom processing after the audio data is collected or before the remote audio data is drawn for rendering.
  • When to call: It needs to be called before [startPublishingStream], [startPlayingStream], [startPreview], [createMediaPlayer], [createAudioEffectPlayer] and [createRealTimeSequentialDataManager] to be effective.
  • Available since: 1.13.0
  • Restrictions: None.

registerCustomAudioProcessPlugin

registerCustomAudioProcessPlugin
registerCustomAudioProcessPlugin(plugin: Number, type: ZegoCustomAudioProcessConfigureType): void
Register custom audio processing plugin.
Declared in ZegoExpressEngine.js
NameTypeDescription
pluginNumberAudio processing plugin.
typeZegoCustomAudioProcessConfigureTypeCustom audio process configure type.

unregisterCustomAudioProcessPlugin

unregisterCustomAudioProcessPlugin
unregisterCustomAudioProcessPlugin(type: ZegoCustomAudioProcessConfigureType): void
Unregister custom audio processing plugin.
Declared in ZegoExpressEngine.js
NameTypeDescription
typeZegoCustomAudioProcessConfigureTypeCustom audio process configure type.

enableCustomAudioCaptureProcessingAfterHeadphoneMonitor

enableCustomAudioCaptureProcessingAfterHeadphoneMonitor
enableCustomAudioCaptureProcessingAfterHeadphoneMonitor(enable: boolean, config: ZegoCustomAudioProcessConfig): void
Turn on local collection and custom audio processing (after ear return).
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
enablebooleanWhether to enable local capture custom audio processing.
configZegoCustomAudioProcessConfigCustom audio processing configuration.

Details

Enable custom audio processing(after ear return), developers can receive locally collected audio frames through [onProcessCapturedAudioData], and can modify the audio data.

  • Use cases: If the developer wants to implement special functions (such as voice change, bel canto, etc.) through custom processing after the audio data is collected or before the remote audio data is drawn for rendering.
  • When to call: It needs to be called before [startPublishingStream], [startPlayingStream], [startPreview], [createMediaPlayer], [createAudioEffectPlayer] and [createRealTimeSequentialDataManager] to be effective.
  • Available since: 1.13.0
  • Restrictions: None.

enableCustomAudioIO

enableCustomAudioIO
enableCustomAudioIO(enable: boolean, config?: ZegoCustomAudioConfig, channel: ZegoPublishChannel): void
Enables the custom audio I/O function (for the specified channel), support PCM, AAC format data.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
enablebooleanWhether to enable custom audio IO, default is false.
configZegoCustomAudioConfigCustom audio IO config.
channelZegoPublishChannelSpecify the publish channel to enable custom audio IO.

Details

Enable custom audio IO function, support PCM, AAC format data.

  • Use cases: If the developer wants to implement special functions (such as voice change, bel canto, etc.) through custom processing after the audio data is collected or before the remote audio data is drawn for rendering.
  • When to call: It needs to be called before [startPublishingStream], [startPlayingStream], [startPreview], [createMediaPlayer], [createAudioEffectPlayer] and [createRealTimeSequentialDataManager] to be effective.
  • Available since: 1.10.0
  • Restrictions: None.

registerCustomAudioCapturePlugin

registerCustomAudioCapturePlugin
registerCustomAudioCapturePlugin(plugin: Number, channel: ZegoPublishChannel): void
register custom audio capture plugin
Declared in ZegoExpressEngine.js
NameTypeDescription
pluginNumberaudio capture plugin
channelZegoPublishChannelpublish channel

unregisterCustomAudioCapturePlugin

unregisterCustomAudioCapturePlugin
unregisterCustomAudioCapturePlugin(plugin: Number): void
unregister custom audio capture plugin
Declared in ZegoExpressEngine.js
NameTypeDescription
pluginNumberaudio capture plugin

createCopyrightedMusic

createCopyrightedMusic
createCopyrightedMusic(): ZegoCopyrightedMusic
Creates a copyrighted music instance.
Declared in ZegoExpressEngine.js

Creates a copyrighted music instance. Use case: Often used in online KTV chorus scenarios, users can use related functions by creating copyrighted music instance objects.

  • When to call: It can be called after the engine by [createEngine] has been initialized.
  • Available since: 2.13.0
  • Restrictions: The SDK only supports the creation of one instance of CopyrightedMusic. Multiple calls to this function return the same object.

copyrighted music instance, multiple calls to this function return the same object.

destroyCopyrightedMusic

destroyCopyrightedMusic
destroyCopyrightedMusic(copyrightedMusic: ZegoCopyrightedMusic): void
Destroys a copyrighted music instance.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
copyrightedMusicZegoCopyrightedMusicThe copyrighted music instance object to be destroyed.

Details

Destroys a copyrighted music instance.

  • When to call: It can be called before the engine by [destroyEngine]
  • Available since: 2.13.0

onDownloadProgressUpdate

onDownloadProgressUpdate
onDownloadProgressUpdate(resourceID: string, progressRate: number): void
Callback for download song or accompaniment progress rate.
Declared in ZegoExpressEngine.js
NameTypeDescription
resourceIDstringThe resource ID of the song or accompaniment that triggered this callback.
progressRatenumberdownload progress rate.

onCurrentPitchValueUpdate

onCurrentPitchValueUpdate
onCurrentPitchValueUpdate(resourceID: string, currentDuration: number, pitchValue: number): void
Real-time pitch line callback.
Declared in ZegoExpressEngine.js
NameTypeDescription
resourceIDstringThe resource ID of the song or accompaniment that triggered this callback.
currentDurationnumberCurrent playback progress.
pitchValuenumberReal-time pitch accuracy or value.

getScreenCaptureSources

getScreenCaptureSources
getScreenCaptureSources(thumbnailWidth: number, thumbnailHeight: number, iconWidth: number, iconHeight: number): promise<Array<ZegoScreenCaptureSourceInfo>>
Get a list of screens or windows in a screen.
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
thumbnailWidthnumberGet the thumbnail width corresponding to the window, the thumbnail can be used to draw on the window selection interface. (unit is pixel)
thumbnailHeightnumberGet the thumbnail height corresponding to the window, the thumbnail can be used to draw on the window selection interface. (unit is pixel)
iconWidthnumberGet the width of the icon corresponding to the program. (unit is pixel)
iconHeightnumberGet the height of the icon corresponding to the program. (unit is pixel)

Details

Get a list of screens or windows in a screen.

  • Available since: 3.1.0
  • Restrictions: Only support in Windows/macOS.

Return

List of capture source info objects.

createScreenCaptureSource

createScreenCaptureSource
createScreenCaptureSource(sourceId: number, sourceType: ZegoScreenCaptureSourceType): ZegoScreenCaptureSource
Create the screen capture source
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
sourceIdnumberThe specified screen ID or window ID.
sourceTypeZegoScreenCaptureSourceTypeThe specified screen source type.

Details

Creates a screen capture source object based on the provided source ID and source type.

  • Use cases: It is used when you need to record and share the screen or window.
  • When to call: It needs to be called after [createEngine].
  • Platform differences: Only supports Windows and macOS.

Return

The screen capture instance, null will be returned when the maximum number is exceeded.

destroyScreenCaptureSource

destroyScreenCaptureSource
destroyScreenCaptureSource(source: ZegoScreenCaptureSource): void
Destroy the screen capture source instance
Declared in ZegoExpressEngine.js

Parameters

NameTypeDescription
sourceZegoScreenCaptureSourceThe screen capture source instance to be destroyed.

Details

Destroy the [ZegoScreenCaptureSource] instance object.

  • Use cases: When you no longer need to use the screen capture function, you can use this function to destroy the instance object created by the [createScreenCaptureSource] function
  • When to call: When you need to the screen capture source object needs to be destroyed
  • Platform differences: Only supports Windows and macOS.
  • Restrictions: After destroy the instance, you need to release the [ZegoScreenCaptureSource] instance object you hold by yourself, and don’t call the function of this instance object after the destruction.

ZegoMediaPlayer

Declared in ZegoExpressMediaPlayer.js

Methods

loadResource

loadResource
loadResource(path: string): Promise<Object>
Load local or network media resource.
Declared in ZegoExpressMediaPlayer.js

Parameters

NameTypeDescription
pathstringThe absolute resource path or the URL of the network resource and cannot be null or "". Android can set this path string with Uri.

Details

Load media resources. Use case: Developers can load the absolute path to the local resource or the URL of the network resource incoming.

  • When to call: It can be called after the engine by [createEngine] has been initialized and the media player has been created by [createMediaPlayer].
  • Related APIs: Resources can be loaded through the [loadResourceWithPosition] or [loadResourceFromMediaData] function.
  • Caution: If the mediaplayer has already loaded resources or is in the process of playing, please first call the [stop] interface to halt the playback, and then proceed to call the interface to load the media resources; failure to do so will result in an unsuccessful load.

Return

Callback result of loading media resource.

loadResourceWithPosition

loadResourceWithPosition
loadResourceWithPosition(path: string, startPosition: number): Promise<Object>
Load local or network media resource and specify the start position.
Declared in ZegoExpressMediaPlayer.js

Parameters

NameTypeDescription
pathstringThe absolute resource path or the URL of the network resource and cannot be null or "". Android can set this path string with Uri.
startPositionnumberThe progress at which the playback started.

Details

Load media resources, and specify the progress, in milliseconds, at which playback begins. Use case: Developers can load the absolute path to the local resource or the URL of the network resource incoming.

  • When to call: It can be called after the engine by [createEngine] has been initialized and the media player has been created by [createMediaPlayer].
  • Related APIs: Resources can be loaded through the [loadResource] or [loadResourceFromMediaData] function.
  • Caution: 1.When [startPosition] exceeds the total playing time, it will start playing from the beginning. 2.If the mediaplayer has already loaded resources or is in the process of playing, please first call the [stop] interface to halt the playback, and then proceed to call the interface to load the media resources; failure to do so will result in an unsuccessful load.

Return

Callback result of loading media resource.

loadCopyrightedMusicResourceWithPosition

loadCopyrightedMusicResourceWithPosition
loadCopyrightedMusicResourceWithPosition(resourceID: string, startPosition: number): Promise<Object>
Load copyrighted music resource.
Declared in ZegoExpressMediaPlayer.js

Parameters

NameTypeDescription
resourceIDstringThe resource ID obtained from the copyrighted music module.
startPositionnumberThe progress at which the playback started.

Details

Load media resources, and specify the progress, in milliseconds, at which playback begins. Use case: Developers can load the resource ID of copyrighted music.

  • When to call: It can be called after the engine by [createEngine] has been initialized and the media player has been created by [createMediaPlayer].
  • Caution: 1.When [startPosition] exceeds the total playing time, it will start playing from the beginning. 2.If the mediaplayer has already loaded resources or is in the process of playing, please first call the [stop] interface to halt the playback, and then proceed to call the interface to load the media resources; failure to do so will result in an unsuccessful load.

Return

Callback result of loading media resource.

start

start
start(): void
Start playing.
Declared in ZegoExpressMediaPlayer.js

You need to load resources before playing

stop

stop
stop(): void
Stop playing.
Declared in ZegoExpressMediaPlayer.js

pause

pause
pause(): void
Pause playing.
Declared in ZegoExpressMediaPlayer.js

resume

resume
resume(): void
Resume playing.
Declared in ZegoExpressMediaPlayer.js

seekTo

seekTo
seekTo(millisecond: number): Promise<Object>
Set the specified playback progress.
Declared in ZegoExpressMediaPlayer.js

Parameters

NameTypeDescription
millisecondnumberPoint in time of specified playback progress

Details

Unit is millisecond

Return

The result notification of set the specified playback progress

enableRepeat

enableRepeat
enableRepeat(enable: boolean): void
Whether to repeat playback.
Declared in ZegoExpressMediaPlayer.js
NameTypeDescription
enablebooleanrepeat playback flag. The default is false.

enableAux

enableAux
enableAux(enable: boolean): void
Whether to mix the player's sound into the stream being published.
Declared in ZegoExpressMediaPlayer.js

Parameters

NameTypeDescription
enablebooleanAux audio flag. The default is false.

Details

This interface will only mix the media player sound into the main channel

muteLocal

muteLocal
muteLocal(mute: boolean): void
Whether to play locally silently.
Declared in ZegoExpressMediaPlayer.js

Parameters

NameTypeDescription
mutebooleanMute local audio flag, The default is false.

Details

If [enableAux] switch is turned on, there is still sound in the publishing stream. The default is false.

setPlayerView

setPlayerView
setPlayerView(view: ZegoView): void
Set the view of the player playing video.
Declared in ZegoExpressMediaPlayer.js
NameTypeDescription
viewZegoViewVideo rendered view object

setVolume

setVolume
setVolume(volume: number): void
Set mediaplayer volume. Both the local play volume and the publish volume are set.
Declared in ZegoExpressMediaPlayer.js
NameTypeDescription
volumenumberThe range is 0 ~ 200. The default is 60.

setPlayVolume

setPlayVolume
setPlayVolume(volume: number): void
Set mediaplayer local playback volume.
Declared in ZegoExpressMediaPlayer.js
NameTypeDescription
volumenumberThe range is 0 ~ 200. The default is 60.

setPublishVolume

setPublishVolume
setPublishVolume(volume: number): void
Set mediaplayer publish volume.
Declared in ZegoExpressMediaPlayer.js
NameTypeDescription
volumenumberThe range is 0 ~ 200. The default is 60.

setProgressInterval

setProgressInterval
setProgressInterval(millisecond: number): void
Set playback progress callback interval.
Declared in ZegoExpressMediaPlayer.js

Parameters

NameTypeDescription
millisecondnumberInterval of playback progress callback in milliseconds

Details

This function can control the callback frequency of [onMediaPlayerPlayingProgress]. When the callback interval is set to 0, the callback is stopped. The default callback interval is 1s This callback are not returned exactly at the set callback interval, but rather at the frequency at which the audio or video frames are processed to determine whether the callback is needed to call

getPlayVolume

getPlayVolume
getPlayVolume(): number
Gets the current local playback volume of the mediaplayer, the range is 0 ~ 200, with the default value of 60.
Declared in ZegoExpressMediaPlayer.js

current volume

getPublishVolume

getPublishVolume
getPublishVolume(): number
Gets the current publish volume of the mediaplayer, the range is 0 ~ 200, with the default value of 60.
Declared in ZegoExpressMediaPlayer.js

current volume

getTotalDuration

getTotalDuration
getTotalDuration(): number
Get the total progress of your media resources.
Declared in ZegoExpressMediaPlayer.js

You should load resource before invoking this function, otherwise the return value is 0

Unit is millisecond

getCurrentProgress

getCurrentProgress
getCurrentProgress(): number
Get current playing progress.
Declared in ZegoExpressMediaPlayer.js

You should load resource before invoking this function, otherwise the return value is 0

current progress

getCurrentRenderingProgress

getCurrentRenderingProgress
getCurrentRenderingProgress(): number
Get current rendering progress.
Declared in ZegoExpressMediaPlayer.js

You should load resource before invoking this function, otherwise the return value is 0

current rendering progress

getAudioTrackCount

getAudioTrackCount
getAudioTrackCount(): number
Get the number of audio tracks of the playback file.
Declared in ZegoExpressMediaPlayer.js

Number of audio tracks

setAudioTrackIndex

setAudioTrackIndex
setAudioTrackIndex(index: number): void
Set the audio track of the playback file.
Declared in ZegoExpressMediaPlayer.js
NameTypeDescription
indexnumberAudio track index, the number of audio tracks can be obtained through the [getAudioTrackCount] function.

getCurrentState

getCurrentState
getCurrentState(): ZegoMediaPlayerState
Get the current playback status.
Declared in ZegoExpressMediaPlayer.js

current state

getIndex

getIndex
getIndex(): number
Get media player index.
Declared in ZegoExpressMediaPlayer.js

Get media player index.

  • When to call: It can be called after [createMediaPlayer].
  • Restrictions: None.

Media player index.

takeSnapshot

takeSnapshot
takeSnapshot(): Promise<Object>
Take a screenshot of the current playing screen of the media player.
Declared in ZegoExpressMediaPlayer.js

Only in the case of calling [setPlayerCanvas] to set the display controls and the playback state, can the screenshot be taken normally

snapshot error code(errorCode) and base64 string of the image in jpg format(image)

enableSoundLevelMonitor

enableSoundLevelMonitor
enableSoundLevelMonitor(enable: boolean, millisecond: number): void
Whether to enable sound level monitoring.
Declared in ZegoExpressMediaPlayer.js

Parameters

NameTypeDescription
enablebooleanWhether to enable monitoring, true is enabled, false is disabled.
millisecondnumberMonitoring time period of the sound level, in milliseconds, has a value range of [100, 3000].

Details

Whether to enable sound level monitoring.

  • When to call: It can be called after the engine by [createEngine] has been initialized and the media player has been created by [createMediaPlayer].
  • Related callbacks: After it is turned on, user can use the [onMediaPlayerSoundLevelUpdate] callback to monitor sound level updates.
  • Available since: 2.15.0
  • Restrictions: None.

enableFrequencySpectrumMonitor

enableFrequencySpectrumMonitor
enableFrequencySpectrumMonitor(enable: boolean, millisecond: number): void
Whether to enable frequency spectrum monitoring.
Declared in ZegoExpressMediaPlayer.js

Parameters

NameTypeDescription
enablebooleanWhether to enable monitoring, true is enabled, false is disabled.
millisecondnumberMonitoring time period of the frequency spectrum, in milliseconds, has a value range of [10, 3000]. Note that on v3.19.0 and older version, the value range is [100, 3000].

Details

Whether to enable frequency spectrum monitoring.

  • When to call: It can be called after the engine by [createEngine] has been initialized and the media player has been created by [createMediaPlayer].
  • Related APIs: After it is turned on, user can use the [onMediaPlayerFrequencySpectrumUpdate] callback to monitor frequency spectrum updates.
  • Available since: 2.15.0
  • Restrictions: None.

getMediaInfo

getMediaInfo
getMediaInfo(): ZegoMediaPlayerMediaInfo
Get meida information such as video resolution from media file.
Declared in ZegoExpressMediaPlayer.js

Get meida information such as video resolution from media file.

  • When to call: It can be called after the engine by [createEngine] has been initialized and the media player has been created by [createMediaPlayer].
  • Available since: 3.6.0
  • Restrictions: None.

Media file info.

enablePublishVideo

enablePublishVideo
enablePublishVideo(enable: boolean, channel: number): void
Whether to mix the player's video into the stream being published.
Declared in ZegoExpressMediaPlayer.js
NameTypeDescription
enablebooleanenable publish video
channelnumberchannel

getCustomVideoCapturePlugin

getCustomVideoCapturePlugin
getCustomVideoCapturePlugin(): number
Get the custom video capture plugin of the media player
Declared in ZegoExpressMediaPlayer.js

The plugin ID

registerCustomAudioProcessPlugin

registerCustomAudioProcessPlugin
registerCustomAudioProcessPlugin(plugin: Number): void
Register custom audio data processing plugin for mediaplayer.
Declared in ZegoExpressMediaPlayer.js
NameTypeDescription
pluginNumberCustom audio processing plugin for mediaplayer.

unregisterCustomAudioProcessPlugin

unregisterCustomAudioProcessPlugin
unregisterCustomAudioProcessPlugin(): void
Unregister custom audio processing plugin for mediaplayer.
Declared in ZegoExpressMediaPlayer.js

enableLiveAudioEffect

enableLiveAudioEffect
enableLiveAudioEffect(enable: boolean, mode: ZegoLiveAudioEffectMode): void
Enable live audio effect.
Declared in ZegoExpressMediaPlayer.js

Parameters

NameTypeDescription
enablebooleanWhether to enable live audio effect.
modeZegoLiveAudioEffectModeLive audio effect mode.

Details

When the live audio effect is turned on, the spatial sense is enhanced and the instrument sounds become more prominent, without any increase in delay.

  • Use cases: It is commonly used in voice chat rooms and karaoke scenarios to enhance the live audio effects of the accompaniment.
  • When to call: It can be called after the engine by [createEngine] has been initialized and the media player has been created by [createMediaPlayer].
  • Caution: To enhance the live audio effect experience, it is recommended to configure dual-channel stereo encoding. Developers can achieve this configuration by using the [setAudioCaptureStereoMode] method. Failure to configure dual-channel stereo encoding may significantly diminish the effects of certain songs, as the left and right channel effects may cancel each other out when synthesizing mono audio, resulting in less noticeable effects.
  • Available since: 3.10.0

enableLocalCache

enableLocalCache
enableLocalCache(enable: boolean, cacheDir: string): void
Enable local caching of http/https network resources.
Declared in ZegoExpressMediaPlayer.js

Parameters

NameTypeDescription
enablebooleanWhether to enable local caching.
cacheDirstringCache dir. If left blank, the directory specified internally by SDK will be used.

Details

When playing http/https network resources, when the local cache is enabled, the network resources will be saved locally and the cache information will be called back through [onMediaPlayerLocalCache].

  • When to call: It can be called after the engine by [createEngine] has been initialized and the media player has been created by [createMediaPlayer]. Called after [loadResource] or during playback, it will take effect next playback.
  • Caution: Only http/https single file type network resources are supported. If there is a [seek] operation during playback, the cache will fail.
  • Available since: 3.12.0

onMediaPlayerStateUpdate

onMediaPlayerStateUpdate
onMediaPlayerStateUpdate(state: ZegoMediaPlayerState, errorCode: number): void
MediaPlayer playback status callback.
Declared in ZegoExpressMediaPlayer.js

Parameters

NameTypeDescription
stateZegoMediaPlayerStateMedia player status.
errorCodenumberError code, please refer to the error codes document https://docs.zegocloud.com/en/5548.html for details.

Details

MediaPlayer playback status callback.

  • Trigger: The callback triggered when the state of the media player changes.
  • Available since: 1.3.4
  • Restrictions: None.

onMediaPlayerNetworkEvent

onMediaPlayerNetworkEvent
onMediaPlayerNetworkEvent(networkEvent: ZegoMediaPlayerNetworkEvent): void
The callback triggered when the network status of the media player changes.
Declared in ZegoExpressMediaPlayer.js

Parameters

NameTypeDescription
networkEventZegoMediaPlayerNetworkEventNetwork status event.

Details

The callback triggered when the network status of the media player changes.

  • Trigger: When the media player is playing network resources, this callback will be triggered when the status change of the cached data.
  • Related APIs: [setNetWorkBufferThreshold].
  • Available since: 1.3.4
  • Restrictions: The callback will only be triggered when the network resource is played.

onMediaPlayerPlayingProgress

onMediaPlayerPlayingProgress
onMediaPlayerPlayingProgress(millisecond: number): void
The callback to report the current playback progress of the media player.
Declared in ZegoExpressMediaPlayer.js

Parameters

NameTypeDescription
millisecondnumberProgress in milliseconds.

Details

The callback triggered when the network status of the media player changes. Set the callback interval by calling [setProgressInterval]. When the callback interval is set to 0, the callback is stopped. The default callback interval is 1 second.

  • Trigger: When the media player is playing network resources, this callback will be triggered when the status change of the cached data.
  • Related APIs: [setProgressInterval].
  • Available since: 1.3.4
  • Restrictions: None.

onMediaPlayerRenderingProgress

onMediaPlayerRenderingProgress
onMediaPlayerRenderingProgress(millisecond: number): void
The callback to report the current rendering progress of the media player.
Declared in ZegoExpressMediaPlayer.js

Parameters

NameTypeDescription
millisecondnumberProgress in milliseconds.

Details

The callback to report the current rendering progress of the media player. Set the callback interval by calling [setProgressInterval]. When the callback interval is set to 0, the callback is stopped. The default callback interval is 1 second.

  • Trigger: This callback will be triggered when the media player starts playing resources.
  • Related APIs: [setProgressInterval].
  • Available since: 3.8.0
  • Restrictions: None.

onMediaPlayerVideoSizeChanged

onMediaPlayerVideoSizeChanged
onMediaPlayerVideoSizeChanged(width: number, height: number): void
The callback triggered when when the resolution of the playback video changes.
Declared in ZegoExpressMediaPlayer.js

Parameters

NameTypeDescription
widthnumberwidth.
heightnumberheight.

Details

The callback triggered when when the resolution of the playback video changes.

  • Trigger: When the media player is playing a video resource, This callback will be triggered when playback starts and the resolution of the video changes.
  • Available since: 3.11.0

onMediaPlayerLoadResource

onMediaPlayerLoadResource
onMediaPlayerLoadResource(errorCode: number, seq: number): void
Callback to the result of media player loading resources.
Declared in ZegoExpressMediaPlayer.js
NameTypeDescription
errorCodenumberError code, please refer to the error codes document https://docs.zegocloud.com/en/5548.html for details.
seqnumberThe serial number of the calling interface.

onMediaPlayerVideoData

onMediaPlayerVideoData
onMediaPlayerVideoData(videoParam: ZegoVideoFrameObject): void
Callback to mediaplayer video data.
Declared in ZegoExpressMediaPlayer.js
NameTypeDescription
videoParamZegoVideoFrameObjectvideo param.

onMediaPlayerRecvSEI

onMediaPlayerRecvSEI
onMediaPlayerRecvSEI(data: ArrayBuffer): void
The callback triggered when the media player got media side info.
Declared in ZegoExpressMediaPlayer.js

Parameters

NameTypeDescription
dataArrayBufferSEI content.

Details

The callback triggered when the media player got media side info.

  • Trigger: When the media player starts playing media files, the callback is triggered if the SEI is resolved to the media file.
  • Caution: The callback does not actually take effect until call [on] to register it.
  • Available since: 2.2.0
  • Restrictions: Not available for WebGL.

onMediaPlayerSoundLevelUpdate

onMediaPlayerSoundLevelUpdate
onMediaPlayerSoundLevelUpdate(soundLevel: number): void
The callback of sound level update.
Declared in ZegoExpressMediaPlayer.js

Parameters

NameTypeDescription
soundLevelnumberSound level value, value range: [0.0, 100.0] (This value only represents the range of the sound level value returned by the callback, not the precision.).

Details

The callback of sound level update.

  • Trigger: The callback frequency is specified by [EnableSoundLevelMonitor].
  • Caution: The callback does not actually take effect until call [on] to register.
  • Related APIs: To monitor this callback, you need to enable it through [EnableSoundLevelMonitor].
  • Available since: 2.15.0

onMediaPlayerFrequencySpectrumUpdate

onMediaPlayerFrequencySpectrumUpdate
onMediaPlayerFrequencySpectrumUpdate(spectrumList: Array<number>): void
The callback of frequency spectrum update.
Declared in ZegoExpressMediaPlayer.js

Parameters

NameTypeDescription
spectrumListArray<number>Locally captured frequency spectrum value list. Spectrum value range is [0-2^30].

Details

The callback of frequency spectrum update.

  • Trigger: The callback frequency is specified by [EnableFrequencySpectrumMonitor].
  • Caution: The callback does not actually take effect until call [on] to register.
  • Related APIs: To monitor this callback, you need to enable it through [EnableFrequencySpectrumMonitor].
  • Available since: 2.15.0

onMediaPlayerFirstFrameEvent

onMediaPlayerFirstFrameEvent
onMediaPlayerFirstFrameEvent(event: ZegoMediaPlayerFirstFrameEvent): void
The callback triggered when the media player plays the first frame.
Declared in ZegoExpressMediaPlayer.js

Parameters

NameTypeDescription
eventZegoMediaPlayerFirstFrameEventThe first frame callback event type.

Details

The callback triggered when the media player plays the first frame.

  • Trigger: This callback is generated when the media player starts playing.
  • Caution: The callback does not actually take effect until call [on] to register.
  • Related APIs: You need to call the [setPlayerCanvas] interface to set the view for the media player in order to receive the video first frame event callback.
  • Available since: 3.5.0

onMediaPlayerLocalCache

onMediaPlayerLocalCache
onMediaPlayerLocalCache(errorCode: number, resource: string, cachedFile: string): void
The callback triggered when the media player caches http/https network resource locally.
Declared in ZegoExpressMediaPlayer.js

Parameters

NameTypeDescription
errorCodenumberError code.
resourcestringPlayed resource
cachedFilestringCached file

Details

The callback triggered when the media player caches http/https network resource locally.

  • Trigger: This callback occurs after the media player caches http/https network resources.
  • Caution: This callback will not take effect until the [enableLocalCache] API is called and the http/https network resources are played.
  • Related APIs: Need to call the [enableLocalCache] interface.
  • Available since: 3.12.0

setVoiceChangerParam

setVoiceChangerParam
deprecated
setVoiceChangerParam(audioChannel: ZegoMediaPlayerAudioChannel, param: ZegoVoiceChangerParam): void
[Deprecated] Setting up the specific voice changer parameters.
Declared in ZegoExpressMediaPlayer.js
NameTypeDescription
audioChannelZegoMediaPlayerAudioChannelThe audio channel to be voice changed
paramZegoVoiceChangerParamVoice changer parameters
Deprecated
Deprecated since 3.15.0, please use [enableVoiceChanger] instead.

ZegoScreenCaptureSource

Declared in ZegoExpressScreenCaptureSource.js

Methods

updateCaptureSource

updateCaptureSource
updateCaptureSource(sourceId: number, sourceType: ZegoScreenCaptureSourceType): void
Create the screen capture source
Declared in ZegoExpressScreenCaptureSource.js

Parameters

NameTypeDescription
sourceIdnumberThe specified screen ID or window ID.
sourceTypeZegoScreenCaptureSourceTypeThe specified screen source type.

Details

Update a screen capture source object based on the provided source ID and source type.

  • Use cases: It is used when you need to record and share the screen or window.
  • When to call: It can be called after the engine by [createScreenCaptureSource] has been initialized.
  • Restrictions: Only available on Windows/macOS.

startCapture

startCapture
startCapture(): void
Start screen capture.
Declared in ZegoExpressScreenCaptureSource.js

Start screen capture.

  • When to call: It can be called after the engine by [createScreenCaptureSource] has been initialized.
  • Available since: 3.1.0

stopCapture

stopCapture
stopCapture(): void
Stop screen capture.
Declared in ZegoExpressScreenCaptureSource.js

Stop screen capture.

  • Available since: 3.1.0

getCaptureSourceRect

getCaptureSourceRect
getCaptureSourceRect(): ZegoRect
Gets the rectangle of the screen capture source.
Declared in ZegoExpressScreenCaptureSource.js

Gets the rectangle of the screen capture source.

  • Available since: 3.6.0
  • Restrictions: Called after starting [startScreenCapture] acquisition, only support in Windows/macOS.

Rect information about the capture resource.

updateCaptureRegion

updateCaptureRegion
updateCaptureRegion(rect: ZegoRect): void
Update the area captured by the screen.
Declared in ZegoExpressScreenCaptureSource.js

Parameters

NameTypeDescription
rectZegoRectThe position of the area to be captured relative to the entire screen or window.

Details

Update the area captured by the screen.

  • When to call: It can be called after the engine by [createScreenCaptureSource] has been initialized.
  • Available since: 3.1.0
  • Restrictions: Only support in Windows/macOS.

updatePublishRegion

updatePublishRegion
updatePublishRegion(rect: ZegoRect): void
Update the streaming area of ​​the screen capture.
Declared in ZegoExpressScreenCaptureSource.js

Parameters

NameTypeDescription
rectZegoRectThe position of the area to be pushed relative to the upper left corner of the capture screen, the actual capture screen size can be obtained through [onAvailableFrame].

Details

Update the streaming area of ​​the screen capture.

  • When to call: After updating the screen capture source [updateScreenCaptureSource].
  • Caution: The set area cannot exceed the size returned by [onAvailableFrame], otherwise the setting will fail and the original frame will be pushed. The failure of the streaming area will be notified through [onExceptionOccurred].
  • Available since: 3.8.0
  • Restrictions: Every time the screen capture source [updateScreenCaptureSource] is updated, the area will be cleared and needs to be reset, only support in Windows/macOS.

setExcludeWindowList

setExcludeWindowList
setExcludeWindowList(list: Array<number>): void
Sets the filtered list of windows.
Declared in ZegoExpressScreenCaptureSource.js

Parameters

NameTypeDescription
listArray<number>List of IDs to filter windows.

Details

Specify a list of windows, and filter these windows when capturing the screen, and not display them on the screen.

  • When to call: It can be called after the engine by [createScreenCaptureSource] has been initialized.
  • Available since: 3.1.0
  • Restrictions: Only available on Windows/macOS.

enableWindowActivate

enableWindowActivate
enableWindowActivate(active: boolean): void
Whether to activate the promotion of the window to the foreground.
Declared in ZegoExpressScreenCaptureSource.js

Parameters

NameTypeDescription
activebooleanWhether to activate the window. true to activate the window, false to not activate the window, the default is true.

Details

When the capture target is a window, set whether to activate the window to be displayed in the foreground during the first capture.

  • When to call: It can be called after the engine by [createScreenCaptureSource] has been initialized.
  • Available since: 3.1.0
  • Restrictions: Only available on Windows/macOS.

enableCursorVisible

enableCursorVisible
enableCursorVisible(visible: boolean): void
Set whether to show the cursor
Declared in ZegoExpressScreenCaptureSource.js

Parameters

NameTypeDescription
visiblebooleanWhether to show the cursor. true to show the cursor, false to not show the cursor, the default is true.

Details

Set whether to show the cursor.

  • When to call: It can be called after the engine by [createScreenCaptureSource] has been initialized.
  • Available since: 3.1.0
  • Restrictions: Only available on Windows/macOS.

enableHightLight

enableHightLight
enableHightLight(enable: boolean, config: ZegoLayerBorderConfig): void
Set whether to highlight the capture area
Declared in ZegoExpressScreenCaptureSource.js

Parameters

NameTypeDescription
enablebooleanWhether to highlight the capture area. true to highlight, false to not highlight, the default is false.
configZegoLayerBorderConfigHighlight capture area border configuration.

Details

Set whether to highlight the capture area.

  • When to call: It can be called after the engine by [createScreenCaptureSource] has been initialized.
  • Available since: 3.21.0
  • Restrictions: Only available on Windows/macOS.

getIndex

getIndex
getIndex(): number
Get screen capture source index.
Declared in ZegoExpressScreenCaptureSource.js

Index of the screen capture source.

onExceptionOccurred

onExceptionOccurred
onExceptionOccurred(exceptionType: ZegoScreenCaptureSourceExceptionType): void
The callback triggered when a screen capture source exception occurred
Declared in ZegoExpressScreenCaptureSource.js

Parameters

NameTypeDescription
exceptionTypeZegoScreenCaptureSourceExceptionTypeCapture source exception type.

Details

The callback triggered when a screen capture source exception occurred.

  • Trigger: This callback is triggered when an exception occurs after the screen start capture.
  • Caution: The callback does not actually take effect until call [on] to register.
  • Available since: 3.1.0
  • Restrictions: Only available on Windows/macOS.

onCaptureTypeExceptionOccurred

onCaptureTypeExceptionOccurred
onCaptureTypeExceptionOccurred(sourceType: ZegoScreenCaptureSourceType, exceptionType: ZegoScreenCaptureSourceExceptionType): void
The callback triggered when a screen capture source capture type exception occurred
Declared in ZegoExpressScreenCaptureSource.js

Parameters

NameTypeDescription
sourceTypeZegoScreenCaptureSourceTypeCapture source type.
exceptionTypeZegoScreenCaptureSourceExceptionTypeCapture source exception type.

Details

The callback triggered when a screen capture source capture type exception occurred.

  • Trigger: This callback is triggered when an exception occurs after the screen start capture.
  • Caution: The callback does not actually take effect until call [setEventHandler] to set.
  • Available since: 3.21.0
  • Restrictions: Only available on Windows/macOS.

onWindowStateChanged

onWindowStateChanged
onWindowStateChanged(windowState: ZegoScreenCaptureWindowState, windowRect: ZegoRect): void
The callback will be triggered when the state of the capture target window change.
Declared in ZegoExpressScreenCaptureSource.js

Parameters

NameTypeDescription
windowStateZegoScreenCaptureWindowStateCapture window state.
windowRectZegoRectCapture window rect.
  • Caution: The callback does not actually take effect until call [on] to register.
  • Available since: 3.4.0
  • Restrictions: Only available on Windows/macOS.

onRectChanged

onRectChanged
onRectChanged(captureRect: ZegoRect): void
The callback will be triggered when the state of the capture target window change.
Declared in ZegoExpressScreenCaptureSource.js

Parameters

NameTypeDescription
captureRectZegoRectCapture source rect.
  • Caution: The callback does not actually take effect until call [on] to register.
  • Available since: 3.7.0
  • Restrictions: Only available on Windows/macOS.

enableAudioCapture

enableAudioCapture
deprecated
enableAudioCapture(enable: boolean, audioParam: ZegoAudioFrameParam): void
[Deprecated] Whether to collect the sound of the window process during window collection
Declared in ZegoExpressScreenCaptureSource.js

Parameters

NameTypeDescription
enablebooleanWhether to collect sound. true for collection, false for no collection, default false.
audioParamZegoAudioFrameParamAudio collection parameters.

Details

Whether to collect the sound of the window process during window collection.

  • When to call: Before starting the collection [startScreencapture]. [setAudioSource] Set the acquisition source to ZegoAudioSourceTypeCustom, and the screen acquisition and streaming channels are the same.
  • Available since: 3.13.0
  • Restrictions: Only applicable to Windows 10 and above versions.
Deprecated
Deprecated since 3.23.0, please use the method with the same name with [config] parameter instead.

Previous

Function Overview

Next

Struct

On this page

Back to top