Class
| ZegoAudioEffectPlayer | ZegoCopyrightedMusic |
| ZegoExpressEngine | ZegoExpressPlayer |
| ZegoExpressRangeAudio | ZegoLocalStream |
| ZegoRealTimeSequentialDataManager | ZegoStreamCompositor |
| ZegoStreamView |
ZegoAudioEffectPlayer
Audio effect player
Details
Detailed description: When you need to play short sound effects, such as applause, cheers, etc., you can use the sound effect player to achieve.
Methods
start
start(audioEffectID: string, options?: ZegoAudioEffectPlayOptions, onStart?: Function, onEnd?: Function): voidParameters
| Name | Type | Description |
|---|---|---|
| audioEffectID | string | ID of the sound resource. |
| options | ZegoAudioEffectPlayOptions | Option settings for sound playback. |
| onStart | Function | Callback method for the start of sound playback. |
| onEnd | Function | Callback method for the end of sound playback. |
Details
Start playing the sound at the specified sound ID. The sound effect ID can be a preloaded sound effect [loadAudioEffect] or an online audio resource specified by providing the parameter [option.path] to load and play.
- Use cases: When you need to play short sound effects, such as applause, cheers, etc., you can use this interface to achieve.
- When to call /Trigger: Callable after [createAudioEffectPlayer].
Related interfaces: Stop playing the sound effect Interface [stop].
- Caution:
- The same sound effect ID cannot be played repeatedly until the [onEnd] callback is triggered before the sound effect of the sound effect ID is played.
- Pausing the audio interface [pause] will not end the audio playback and will not trigger the [onEnd] callback.
- Available since: 2.15.0
stop
stop(audioEffectID?: string): booleanParameters
| Name | Type | Description |
|---|---|---|
| audioEffectID | string | The ID of the sound effect resource. If no parameter is passed, all stoppable sound effects will be stopped. |
Details
End playing sound effects.
- When to call /Trigger: The specified [audioEffectID] is already [start] .
Related interfaces: Ending playing a sound effect will trigger the [onEnd] callback method of the start playing sound effect interface [start].
- Caution: none.
- Available since: 2.15.0
Return
Whether the interface call is successful.
pause
pause(audioEffectID?: string): booleanParameters
| Name | Type | Description |
|---|---|---|
| audioEffectID | string | The ID of the sound effect resource. If no parameter is passed, all pauseable sound effects will be paused. |
Details
Pauses the specified sound effect [audioEffectID].
- When to call /Trigger: The specified [audioEffectID] has been [started].
Related interfaces: Start playing audio interface [start] , resume playing interface [resume].
- Available since: 2.15.0
Return
Whether the interface call is successful.
resume
resume(audioEffectID?: string): booleanParameters
| Name | Type | Description |
|---|---|---|
| audioEffectID | string | The ID of the sound effect resource. If no parameters are passed, all recoverable sound effects will be restored. |
Details
Resume playing the specified sound effect [audioEffectID].
- When to call /Trigger: The specified [audioEffectID] is in the [pause] state.
Related interfaces: Start playing audio interface [start] , pause playing interface [pause].
- Available since: 2.15.0
Return
Whether the interface call is successful.
setVolume
setVolume(audioEffectID: string, volume: number): booleanParameters
| Name | Type | Description |
|---|---|---|
| audioEffectID | string | ID of the sound resource. |
| volume | number | The volume value, the value range: the range is [0,100], the default value: 100. |
Details
Setting the playback volume of a single sound effect will set both the local playback volume and the streaming volume.
- Use cases: Adjust the volume of the playing sound effect.
- When to call /Trigger: Callable after [createAudioEffectPlayer].
- Available since: 2.15.0
Return
Whether the interface call is successful.
getTotalDuration
getTotalDuration(audioEffectID: string): numberParameters
| Name | Type | Description |
|---|---|---|
| audioEffectID | string | The ID of the sound effect resource. |
Details
Get the total length of the specified sound effect resource, in milliseconds.
- When to call /Trigger: It must be called after loading the resource, otherwise the return value is 0.
Related interfaces: Start playing the audio interface [start] and load the audio interface [loadAudioEffect].
- Available since: 2.15.0
Return
The total duration of the audio, in milliseconds.
getCurrentProgress
getCurrentProgress(audioEffectID: string): numberParameters
| Name | Type | Description |
|---|---|---|
| audioEffectID | string | The ID of the sound effect resource. |
Details
Get the current playback progress of the specified sound effect. The unit is milliseconds.
- When to call /Trigger: The sound effect needs to have been played via [start], otherwise the return value is 0.
Related interfaces: Start playing the audio interface [start] .
- Available since: 2.15.0
Return
Sound effect playback progress, in milliseconds.
seekTo
seekTo(audioEffectID: string, time: number): booleanParameters
| Name | Type | Description |
|---|---|---|
| audioEffectID | string | The ID of the sound effect resource. |
| time | number | The duration of the specified playback progress. The value range is [0, the total duration] . |
Details
Get the current playback progress of the specified sound effect. The unit is milliseconds.
Use case: Load an audio resource with multiple sound effects, and play the sound effects at the corresponding position through this interface.
When to call/
- Trigger: The specified [audioEffectID] has been [started] and has not finished playing.
Related interfaces: Start playing the audio interface [start] .
- Available since: 2.15.0
Return
Identifies whether the call was successful.
ZegoCopyrightedMusic
Copyrighted Music
Details
Detailed description: It is often used in KTV singing scenes. Users can use genuine music-related functions by creating copyrighted music instance objects.
Methods
getInstance
destroyInstance
destroyInstance(): voidinitCopyrightedMusic
initCopyrightedMusic(config: ZegoCopyrightedMusicConfig): Promise<number>Parameters
| Name | Type | Description |
|---|---|---|
| config | ZegoCopyrightedMusicConfig | Copyright music configuration. |
Details
Initialize the copyright music for subsequent use of copyright music functions.
- When to call: After the engine instance calls the login room [loginRoom].
- Caution: Real user information must be passed in, otherwise song resources cannot be obtained for playback. 2. The user ID and user name set when initializing copyrighted music need to be consistent with the user ID and user name set when logging into the room.
- Available since: 2.24.5
Return
Error code, please refer to the common error code document for details. https://docs.zegocloud.com/article/6707
on
on<K extends keyof ZegoCopyrightedMusicEvent >(event: K, callBack: ZegoCopyrightedMusicEvent[K]): booleanParameters
| Name | Type | Description |
|---|---|---|
| event | K | Listener event name. |
| callBack | ZegoCopyrightedMusicEvent[K] | Callback. |
Details
The interface used to handle the SDK's initiative to notify developers of callbacks. By registering different events, you can receive callbacks of different functions. The event callback that can be monitored can be viewed in ZegoCopyrightedMusicEvent.
Use case: Callback processing for registering business events related to copyrighted music functions.
Timing of calling: After calling the interface createCopyrightedMusic to create the instance and before calling the interface loginRoom to log in to the room.
The same event can be registered multiple, the same registered event will be triggered in sequence according to the order of registration.
Related interface: call interface off to cancel the corresponding callback event processing.
Return
Whether the registration is successful.
sendExtendedRequest
sendExtendedRequest(command: string, params: any): Promise<ZegoCopyrightedMusicSendExtendedRequestResponse>Parameters
| Name | Type | Description |
|---|---|---|
| command | string | Request commands. For specific supported commands, please refer to https://doc-zh.zego.im/online-ktv-web/client-api/send-extended-request. |
| params | any | Request parameters, each request command has corresponding request parameters, please refer to https://doc-zh.zego.im/online-ktv-web/client-api/send-extended-request. |
Details
Send an extended function request to access the copyright song library to obtain related song lists and list song information.
-
Use cases: Used to get a list of songs.
-
When to call: After initializing copyrighted music [initCopyrightedMusic] successfully.
- Available since: 2.24.5
Return
Promise returns the request result asynchronously.
requestResource
requestResource(config: ZegoCopyrightedMusicRequestConfig, type: ZegoCopyrightedMusicResourceType): Promise<ZegoCopyrightedMusicRequestResourceResponse>Parameters
| Name | Type | Description |
|---|---|---|
| config | ZegoCopyrightedMusicRequestConfig | Get the configuration of sharing song resources. |
| type | ZegoCopyrightedMusicResourceType | Copyright music resource type. 0 is the normal song, 1 is the accompaniment, and 2 is the climactic segment. |
Details
You can get the basic information of the song (duration, song title, singer, etc.), and the most important resource id that can be used for local playback, as well as some related authentication information.
-
Use cases: Obtain copyrighted songs for local playback and sharing.
-
When to call: After initializing copyrighted music [initCopyrightedMusic].
-
Caution: This interface triggers billing. Each resource has a unique resource ID.
-
Related APIs: After a user in the room calls this interface to obtain a music resource successfully, other users in the room can call the [getSharedResource] interface to obtain the music resource once for free.
- Available since: 2.24.5
Return
Promise returns the request result asynchronously.
getSharedResource
getSharedResource(config: ZegoCopyrightedMusicRequestConfig, type: ZegoCopyrightedMusicResourceType): Promise<ZegoCopyrightedMusicRequestResourceResponse>Parameters
| Name | Type | Description |
|---|---|---|
| config | ZegoCopyrightedMusicRequestConfig | Get the configuration of sharing song resources. |
| type | ZegoCopyrightedMusicResourceType | Copyright music resource type. 0 is the normal song, 1 is the accompaniment, and 2 is the climactic segment. |
Details
You can get the basic information of the song (duration, song title, singer, etc.), and the most important resource id that can be used for local playback, as well as some related authentication information.
-
Use cases: Obtain copyrighted songs for local playback and sharing.
-
When to call: After initializing copyrighted music [initCopyrightedMusic].
-
Caution: Each resource has a unique resource ID.
-
Related APIs: After a user in the room calls the [requestResource] interface to obtain a music resource successfully, other users in the room can call this interface to obtain the music resource once for free.
- Available since: 2.24.5
Return
Promise returns the request result asynchronously.
getLrcLyric
getLrcLyric(songID: string, vendorID: ZegoCopyrightedMusicVendorID): Promise<ZegoCopyrightedMusicGetLrcLyricResponse>Parameters
| Name | Type | Description |
|---|---|---|
| songID | string | The ID of the song or accompaniment, the song and accompaniment of a song share the same ID. |
| vendorID | ZegoCopyrightedMusicVendorID | copyright party. |
Details
Get the lyrics in lrc format, and support line-by-line parsing of lyrics.
- Use cases: Used to display lyrics line by line.
- When to call: After initializing copyrighted music [initCopyrightedMusic] successfully.
- Available since: 2.24.5
Return
Promise returns the lyrics result in lrc format asynchronously.
getKrcLyricByToken
getKrcLyricByToken(krcToken: string): Promise<ZegoCopyrightedMusicGetKrcLyricByTokenResponse>Parameters
| Name | Type | Description |
|---|---|---|
| krcToken | string | Get the krcToken obtained from the music resource [requestResource]. For details, please refer to the lyrics resource interface description https://doc-zh.zego.im/online-ktv-electron/client-api/apis-to-obtain-songs-and-lyrics#2_2. |
Details
Get lyrics in krc format, support word by word parsing of lyrics.
- Use cases: Used to display lyrics verbatim.
- Caution: After initializing copyrighted music [initCopyrightedMusic] successfully.
- Available since: 2.24.5
Return
Promise returns the request result asynchronously.
download
download(resourceID: string): Promise<ZegoCopyrightedMusicDownloadResponse>Parameters
| Name | Type | Description |
|---|---|---|
| resourceID | string | The resource ID corresponding to the song or comp. |
Details
Download a song or accompaniment, it can be played only after the download is successful.
- Use cases: After obtaining the copyright song or accompaniment authorization, use this interface to load the corresponding song or accompaniment resource.
- When to call: After calling the get resource interface [requestResource] or [getSharedResource] to get the resourceID successfully.
- Caution: Loading songs or accompaniment resources is affected by the network.
- Available since: 2.24.5
Return
Promise returns the request result asynchronously.
clearCache
clearCache(): voidWhen using this module, some cache files may be generated, which can be cleared through this interface.
- Use cases: Used for caching of songs.
- When to call /Trigger: After creating copyrighted music [createCopyrightedMusic].
- Available since: 2.24.5
startScore
startScore(params: ZegoStartScoreParams): Promise<number>Parameters
| Name | Type | Description |
|---|---|---|
| params | ZegoStartScoreParams | Start scoring task related parameters. |
Details
To start the scoring interface, you need to specify the resourceID of the media stream, song player, and song resource for the microphone collection. The SDK will start the scoring task based on this information.
- Use cases: Can be used to display singing scores on views.
- When to call: It can be called after getting the verbatim lyrics of krc and playing the accompaniment resource of copyright music.
Cautions: The H5 player playing the accompaniment must start playing to call this interface to start scoring, otherwise there may be a problem that the scoring is not aligned with the progress of the song.
Related interfaces: stopScore End scoring interface, used to end the scoring task. Only one scoring task can be performed at a time, and the current task needs to be completed before the next one can be performed.
- Available since: 2.26.0
Return
Asynchronously returns the call result status code, 0 means the call is normal.
stopScore
stopScore(resourceID: string): numberParameters
| Name | Type | Description |
|---|---|---|
| resourceID | string | The resource ID for the accompaniment or climactic clip. |
Details
Ending the current rating will stop the [OnCurrentPitchValueUpdate] callback, but the average or total score can still be obtained normally.
- Use cases: When grading is in progress, this interface can be called to end grading.
- When to call: Callable while scoring is in progress.
Related interfaces: Start scoring interface startScore .
- Available since: 2.26.0
Return
Status code, 0 means the call is normal.
pauseScore
pauseScore(resourceID: string): numberParameters
| Name | Type | Description |
|---|---|---|
| resourceID | string | The resource ID for the accompaniment or climactic clip. |
Details
Pause scoring in progress.
- Use cases: Called when a pause is required during singing.
- When to call: Callable while scoring is in progress.
Related interfaces: Resume scoring interface resumeScore .
- Available since: 2.26.0
Return
Status code, 0 means the call is normal.
resumeScore
resumeScore(resourceID: string): numberParameters
| Name | Type | Description |
|---|---|---|
| resourceID | string | The resource ID for the accompaniment or climactic clip. |
Details
Pause scoring in progress.
- Use cases: During the singing process, it is necessary to resume singing and scoring after a break.
- When to call: After calling start scoring interface startScore and suspending scoring.
Related interfaces: Pause scoring interface pauseScore.
- Available since: 2.26.0
Return
Status code, 0 means the call is normal.
resetScore
resetScore(resourceID: string): numberParameters
| Name | Type | Description |
|---|---|---|
| resourceID | string | The resource ID for the accompaniment or climactic clip. |
Details
Reset the score that has been scored for this scoring task.
- Use cases: I sang part of this scoring task but want to start over and re-score.
- When to call: After calling the scoring interface startScore.
- Available since: 2.26.0
Return
Status code, 0 means the call is normal.
getPreviousScore
getPreviousScore(resourceID: string): Promise<number>Parameters
| Name | Type | Description |
|---|---|---|
| resourceID | string | The resource ID for the accompaniment or climactic clip. |
Details
The return value is to get the score of the previous sentence.
- Use cases: Can be used to display the score of each sentence on the view.
- When to call: It can be called after playing the copyright accompaniment or climax clip and starting to score.
- Available since: 2.26.0
Return
The return value is to get the score of the previous sentence.
getAverageScore
getAverageScore(resourceID: string): Promise<number>Parameters
| Name | Type | Description |
|---|---|---|
| resourceID | string | The resource ID for the accompaniment or climactic clip. |
Details
Get the average rating.
- Use cases: Can be used to display the average rating on the view.
- When to call: It can be called after playing the copyright accompaniment or climax clip and starting to score.
- Available since: 2.26.0
Return
Returns the average rating.
getTotalScore
getTotalScore(resourceID: string): Promise<number>Parameters
| Name | Type | Description |
|---|---|---|
| resourceID | string | The resource ID for the accompaniment or climactic clip. |
Details
Get the total score.
- Use cases: Can be used to display the total score on the view.
- When to call: It can be called after playing the copyright accompaniment or climax clip and starting to score.
- Available since: 2.26.0
Return
Return the score.
getFullScore
getFullScore(resourceID: string): Promise<number>Parameters
| Name | Type | Description |
|---|---|---|
| resourceID | string | The resource ID for the accompaniment or climactic clip. |
Details
Get full marks.
- Use cases: Can be used to display full marks on views.
- When to call: It can be called after playing the copyright accompaniment or climax clip and starting to score.
- Available since: 2.26.0
Return
Return the score.
getStandardPitch
getStandardPitch(resourceID: string): Promise<ZegoCopyrightedMusicGetStandardPitchResponse>Parameters
| Name | Type | Description |
|---|---|---|
| resourceID | string | The resource ID for the accompaniment or climactic clip. |
Details
Get standard pitch data.
- Use cases: Can be used to display standard pitch lines on a view.
- When to call: It can be called after calling requestResource to request the corresponding copyright accompaniment or climax clip.
Cautions: Only accompaniment or climax clip assets have pitchlines.
- Available since: 2.26.0
Return
Returns the standard pitch data result.
getCurrentPitch
getCurrentPitch(resourceID: string): Promise<number>Parameters
| Name | Type | Description |
|---|---|---|
| resourceID | string | The resource ID for the accompaniment or climactic clip. |
Details
Get real-time pitch data.
- Use cases: Can be used to display the pitch buoy position on the view.
- When to call: It can be called after playing the copyright accompaniment or climax clip and starting to score.
- Available since: 2.26.0
Return
Returns the real-time pitch value.
setScoringLevel
setScoringLevel(level: number): voidParameters
| Name | Type | Description |
|---|---|---|
| level | number | Rate the difficulty level. The value range of level is 0~4. The difficulty of scoring decreases gradually from 0 to 4. |
Details
Users can set the scoring difficulty level through this interface.
- Default value: When this function is not called, the scoring difficulty level defaults to 4, the lowest level of difficulty.
- When to call: After the call to initialize copyright music is successful, call [startScore] before starting scoring.
- Available since: 2.26.0
ZegoExpressEngine
Express Video SDK
Details
This class is used to initialize the express SDK engine instance.
Properties
version
static version: string Detailed description: SDK version number.
Methods
setGeoFence
setGeoFence(type: ZegoGeoFenceType, areaList: number[]): voidParameters
| Name | Type | Description |
|---|---|---|
| type | ZegoGeoFenceType | Geo fence type. Description: Used to set the geo fence type. |
| areaList | 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.
- Available since: 2.26.0
- Restrictions: If you need to use the geo fence feature, please contact ZEGO Technical Support.
setEngineOptions
setEngineOptions(options: any): voidParameters
| Name | Type | Description |
|---|---|---|
| options | any | Advanced engine configuration. |
Details
Set the advanced configuration of the engine.
- Use cases: Used when special configuration operations are required for the SDK engine, please consult ZEGO technical support for details.
- When to call: Must be set before calling new to take effect, otherwise it will fail.
- Available since: 2.26.0 and above.
use
use(module: any): voidParameters
| Name | Type | Description |
|---|---|---|
| module | any | Functional module. |
Details
You can use this interface to introduce other functional modules as needed, such as background blur, AI noise reduction and other functional modules.
- When to call /Trigger: After initializing the ZegoExpressEngine instance.
- Available since: 2.10.0
presetLogConfig
presetLogConfig(config: ZegoLogConfig): booleanParameters
| Name | Type | Description |
|---|---|---|
| config | ZegoLogConfig | Log related advanced configuration |
- Default value: Both the local log and upload level are info.
- When to call: before initialization.
Usage restriction: None, but it is recommended to call it only once in the entire life cycle.
Unless there is a clear special requirement, please do not call this interface to change the default configuration.
- Related callbacks: None
Related interface: The difference from setLogConfig is that it can be called before initializing the instance.
Return
Whether the call is successful; failure condition: the input parameter format is wrong
setCloudProxyConfig
setCloudProxyConfig(proxyList: ZegoProxyInfo[], token: string, enable: boolean): voidParameters
| Name | Type | Description |
|---|---|---|
| proxyList | ZegoProxyInfo[] | List of proxy server information. |
| token | string | Authentication information. |
| enable | boolean | Whether to enable proxy. |
- When to call: Called before initialization.
Usage restriction: This interface cannot be called to modify the configuration after initializing the instance to avoid unexpected errors.
setLocalProxyConfig
setLocalProxyConfig(proxyConfig: ZegoLocalProxyConfig, enable: boolean): voidParameters
| Name | Type | Description |
|---|---|---|
| proxyConfig | ZegoLocalProxyConfig | Domain name and path configuration information of the proxy server. |
| enable | boolean | Whether to enable proxy. |
- When to call: Called before initialization.
Usage restriction: 1. This interface cannot be called to modify the configuration after initializing the instance to avoid unexpected errors. 2. It cannot be used together with setCloudProxyConfiguration.
createStreamCompositor
createStreamCompositor(): voidCreate a broadcast station instance object, which is used to combine multiple media streams into one.
- Use cases: When you need to combine multiple video streams and pictures of local users into one video stream, such as online education, remote conferences, live broadcasts, etc., you can use the broadcast station to achieve this.
- Caution:
- Each broadcast station object can only output one mixed stream.
- Mobile terminal is not supported yet.
- Available since: 3.0.0
uploadLog
uploadLog(): Promise<{ errorCode: number; extendedData: string }>Read local logs and upload them. (Before version 3.11.0, you need to contact ZEGO technical support to enable the local storage function for logs in order to use it.)
- Use cases: When a user has a problem, he can click to upload the offline log saved in the browser by the SDK to the ZEGO background, so that ZEGO technical staff can help and troubleshoot user problems.
- When to call: After logging into the room.
- Caution: none.
- Related APIs: none.
- Related callbacks: none.
- Available since: 2.26.0.
- Restrictions: Token version 04 is required to log in to the room.
"errorCode" is the returned error code, 0 means the upload is successful, and 1102022 means the upload failed; "extendedData" is the description of the error code information.
setSEIConfig
setSEIConfig(config: ZegoSEIConfig): voidParameters
| Name | Type | Description |
|---|---|---|
| config | ZegoSEIConfig | SEI function related configuration. |
- When to call: after initialization.
s: None.
- Related callbacks: None.
setRoomScenario
setRoomScenario(scenario: ZegoScenario): booleanParameters
| Name | Type | Description |
|---|---|---|
| scenario | ZegoScenario | the value of scenario |
Details
Developers can set the usage scenarios of the room, and the SDK will adopt different optimization strategies for different scenarios to obtain better results; the function of this function is exactly the same as the [scenario] parameter in the initialization engine instance [options] configuration.
- Use cases: This function is suitable for modifying the settings of various audio and video business scenarios, such as 1v1 audio and video call scenarios and show live broadcast scenarios; this function can be used to switch scenarios under the premise of the same engine instance.
- Default value: none
- When to call /Trigger: It must be set before calling [loginRoom], and it will be generated in [createStream] called later, and it will not be generated for the stream that has already been created.
- Caution: 1.Users in the same room recommend using the same room scene for best results. 2.Setting the scene will affect the audio and video configurations such as audio and video bit rate, frame rate, resolution, encoding type, 3A, ear return, etc. If developers have special needs, they can call other various APIs to set the above configuration after setting the room scene. 3.Calling this function will overwrite the scene specified when [new ZegoExpressEngine] was called or the scene set by the previous call to this function.
- Available since: Supported version: 1.0.0 and above
- Restrictions: Once you log in to the room, you are no longer allowed to modify the room scene. If you need to modify the scene, you need to log out of the room first. If you log in to multiple rooms, you need to log out of all rooms before modifying.
Return
true means the setting is successful, false means the setting fails
setEngineConfig
setEngineConfig(config: any): voidParameters
| Name | Type | Description |
|---|---|---|
| config | any | Advanced engine configuration. |
Details
2.21.0 and above.
Detailed description: Set the advanced configuration of the engine.
Business scenario: Used when special configuration operations are required for the SDK engine, please consult ZEGO technical support for details.
destroyEngine
destroyEngine(): void-
Default value: no default value.
-
When to call: the last API called by the same engine instance.
After destroying the engine, the instantiated object should be cleared in time, and other interfaces of the engine object should not be called, otherwise unexpected problems may occur.
setTurnServer
setTurnServer(turnServers: ZegoTurnServer[]): voidParameters
| Name | Type | Description |
|---|---|---|
| turnServers | ZegoTurnServer[] | Domain name and path configuration information of the proxy server. |
- When to call: Called before initiating push or pull streaming.
callExperimentalAPI
callExperimentalAPI(params: Object): Promise<any>Parameters
| Name | Type | Description |
|---|---|---|
| params | Object | The passed-in parameters are in JSON Object. Please consult ZEGO technical support for details. |
- When to call: After initialization.
checkSystemRequirements
checkSystemRequirements<T extends keyof ZegoCheckSingleType>(checkType?: T, checkLevel: 0 | 1): Promise<ZegoCapabilityDetection>Parameters
| Name | Type | Description |
|---|---|---|
| checkType | T | Specify to check the capabilities that a browser can support, such as: webRTC, VP8, etc. This parameter is not passed by default to check all supported capabilities. |
| checkLevel | 0 | 1 | For the level of detection coding format, 0 means fast detection with high accuracy; 1 means accurate detection with long time consuming and higher accuracy. |
- Default value: none
- When to call: After initialization, it is called before the flow is created.
Restrictions on use: None
- The real support depends not only on the browser, but also on the system, so there is a low probability of inaccurate monitoring.
- When you choose to check the camera or microphone capability, the browser will prompt a pop-up box to ask for permission to allow the device.
- In the case of using only play stream but not publish stream, you don't need to check the device capability, only need to check "webRTC", "H264" or "VP8". Example:
const result = await zg.checkSystemRequirements("webRTC").
Scope of influence: None
- Related callbacks: None
Related interface: None
- Platform differences: None
off
off<K extends keyof ZegoEvent>(event: K, callBack?: ZegoEvent[K]): booleanParameters
| Name | Type | Description |
|---|---|---|
| event | K | Listener event name |
| callBack | ZegoEvent[K] | Callback, optional |
- When to call: after registration, before exiting the room.
- Default value: none
Restrictions on use: None
When there are multiple events of the same type, they will all be deleted.
Scope of influence: None
- Related callbacks: None
Related interface: None
- Platform differences: None
on
on<K extends keyof ZegoEvent>(event: K, callBack: ZegoEvent[K]): booleanParameters
| Name | Type | Description |
|---|---|---|
| event | K | Listener event name. |
| callBack | ZegoEvent[K] | Callback. |
Details
Supported version: 1.0.0 and above
Detailed description: ZegoEvent includes ZegoRTCEvent and [ZegoRTMEvent](https://doc- en.zego.im/article/api?doc=Express_Video_SDK_APIjavascript_webinterface~ZegoRTMEvent), which is used to handle the API that SDK actively notifies developers of callbacks. By registering events of different events, you can receive callbacks of different functions.
Business scenario: General interface, used to monitor SDK business events.
Timing of calling: After initializing the instance, before calling the interface loginRoom to log in to the room.
The same event can be registered multiple, the same registered event will be triggered in sequence according to the order of registration.
Related interface: call interface off to cancel the corresponding callback event processing.
Return
Whether the registration is successful.
getNetworkTimeInfo
getNetworkTimeInfo(): { timestamp: number; maxDeviation: number; }Get the current network time (NTP), including the timestamp and maximum error of the current network time.
- Use cases: When performing multi-terminal behavior synchronization, it is necessary to obtain the synchronization network time to calibrate the current time.
- When to call: After initializing a ZegoExpresEngine instance.
- Available since: 3.0.0
Return the network timestamp information, timestamp is the synchronized network timestamp, 0 means not yet synchronized; maxDeviation is the maximum error value.
createStream
createStream(source?: ZegoLocalStreamConfig): Promise<MediaStream>Parameters
| Name | Type | Description |
|---|---|---|
| source | ZegoLocalStreamConfig | Parameter configuration related to the source of creating a MediaStream, If not upload, the default is to create the media stream of the camera |
Details
Create media stream and set push stream related parameters, including camera capture streams, screen sharing capture streams, local or online media streams and other types.
- Use cases: Used to enable functions such as camera capture or screen sharing.
- Default value: The default is the camera capture stream, and the default is the high-definition format.
- When to call: It can be called after initializing and calling the interface checkSystemRequirements to check that the returned result is supported.
- Caution: 1. The understanding of the video width and height is different between the mobile terminal and the PC terminal. The two are exactly the opposite. The same resolution is horizontal screen on the PC terminal and vertical screen on the mobile terminal.
- The interface must be called under the secure domain name (https, localhost, 127.0.0.1).
- When pushing a third-party stream, the input corresponding to the <video> tag must be loaded successfully (oncanplay callback of media tag) before calling this interface.
- Set the start bitrate parameter startBitrate to "target" (supported by chrome kernel only), the bitrate will increase rapidly when streaming, and if the network is poor, freezes or screens may occur, so it is recommended to use the default slow increase method.
- If there is a need to temporarily open and close the audio or video, it is recommended to push the audio and video stream first, and then set the enable corresponding to the unnecessary audio or video track to false, and to turn on the audio or video track after pushing the stream, you can call replaceTrack interface.
- When the screen sharing setting source.screen.audio is true (only supported by windows), only the system sound will be pushed, not the microphone sound.
- Although the API supports setting the resolution, many devices do not support custom resolutions. It is recommended to use several resolutions preset by the parameter source.camera.videoQuality or source.screen.videoQuality.
- camera.channelCount and custom.channelCount are only supported by chrome kernel browser.
- Related callbacks: Publishing stream quality callback The content of the quality message of publishQualityUpdate will be related to the setting parameters; the media stream will be automatically destroyed when the screen sharing interrupt callback screenSharingEnded is triggered.
- Related APIs: Destroy the created media stream interface destroyStream and start pushing the stream interface startPublishingStream.
- Available since: 1.0.0 and above.
Return
Promise to return the streaming object asynchronously. Creation failure returns error code: 1103064, which means media stream-related device permissions. 1103065 indicates that the specified device cannot be used to capture media streams, and the camera or microphone may be occupied by other applications. 1103066 Indicates that the related constraint parameters for creating the stream are incorrect, possibly the specified device ID is invalid. 1103061 Indicates that the acquisition of the media stream failed. For the specific failure reason, please refer to the document "getUserMedia exceptions" (https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#exceptions).
createZegoStream
createZegoStream(source?: ZegoStreamOptions): Promise<ZegoLocalStream>Parameters
| Name | Type | Description |
|---|---|---|
| source | ZegoStreamOptions | Parameter configuration related to the source of creating a MediaStream, If not upload, the default is to create the media stream of the camera |
Details
Create an instance of ZegoLocalStream, a streaming object, and set the relevant parameters of the capture, streaming bitrate, and playback preview container. Capture related parameter settings include camera capture stream, screen sharing capture stream, local or online media stream, etc.
- Use cases: Used to enable functions such as camera capture or screen sharing.
- Default value: The default is the camera capture stream, and the default is the high-definition format.
- When to call: It can be called after initializing and calling the interface checkSystemRequirements to check that the returned result is supported.
- Caution: 1. The understanding of the video width and height is different between the mobile terminal and the PC terminal. The two are exactly the opposite. The same resolution is horizontal screen on the PC terminal and vertical screen on the mobile terminal.
- The interface must be called under the secure domain name (https, localhost, 127.0.0.1).
- When pushing a third-party stream, the input corresponding to the <video> tag must be loaded successfully (oncanplay callback of media tag) before calling this interface.
- Set the start bitrate parameter startBitrate to "target" (supported by chrome kernel only), the bitrate will increase rapidly when streaming, and if the network is poor, freezes or screens may occur, so it is recommended to use the default slow increase method.
- If there is a need to temporarily open and close the audio or video, it is recommended to push the audio and video stream first, and then Then call [mutePublishStreamVideo] to open and close the video, [mutePublishStreamAudio] to open and close the audio. If you want to update the capture audio or video track after pushing the stream, you can call [start Capture Camera], [startCapture Microphone] and other capture APIs on the ZegoLocalStream instance, and combine it with [updatePublishingStream] to update the audio and video in the push stream.
- When the screen sharing setting source.screen.audio is true (only supported by windows), only the system sound will be pushed, not the microphone sound.
- Although the API supports setting the resolution, many devices do not support custom resolutions. It is recommended to use several resolutions preset by the parameter source.camera.video.quality or source.screen.video.quality.
- camera.audio.channelCount and custom.audio.channelCount are only supported by chrome kernel browser.
- Related callbacks: Publishing stream quality callback The content of the quality message of publishQualityUpdate will be related to the setting parameters; the media stream will be automatically destroyed when the screen sharing interrupt callback screenSharingEnded is triggered.
- Related APIs: Destroy the created media stream interface destroyStream and start pushing the stream interface startPublishingStream.
- Available since: 3.0.0 and above.
Return
Promise to return the streaming object asynchronously. Creation failure returns error code: 1103064, which means media stream-related device permissions. 1103065 indicates that the specified device cannot be used to capture media streams, and the camera or microphone may be occupied by other applications. 1103066 Indicates that the related constraint parameters for creating the stream are incorrect, possibly the specified device ID is invalid. 1103061 Indicates that the acquisition of the media stream failed. For the specific failure reason, please refer to the document "getUserMedia exceptions" (https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#exceptions).
updatePublishingStream
updatePublishingStream(zegoStream: ZegoLocalStream, updateType: ZegoStreamUpdateType): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| zegoStream | ZegoLocalStream | ZegoLocalStream instance object created by createZegoStream |
| updateType | ZegoStreamUpdateType |
Details
Used to update audio and video tracks of ZegoLocalStream instances that are being pushed.
-
Use cases: Call [createZegoStream] to create a ZegoLocalStream instance object. After [startPublishingStream] successfully pushes the stream, you need to update the audio and video being pushed by the ZegoLocalStream instance.
-
Caution: ZegoLocalStream is required to successfully capture audio and video streams for update.
- Available since: 3.0.0
getPublishingStreamQuality
getPublishingStreamQuality(streamID: string): ZegoPublishStats | nullParameters
| Name | Type | Description |
|---|---|---|
| streamID | string | ID of stream. |
Details
Actively obtain the streaming quality that is being pushed.
- Use cases: Obtain the quality parameters such as the resolution, frame rate, and bit rate of the current push stream.
- When to call: [startPublishingStream] After the push stream is successful.
- Related APIs: Publishing stream quality callback [publishQualityUpdate].
- Available since: 2.15.0
- Restrictions: Since the streaming quality parameters of the SDK are updated every 3 seconds, it is recommended that the calling interval of this interface should not be less than 3 seconds.
Return
Publishing stream quality information, if the acquisition fails, it will return null.
getElectronScreenSources
getElectronScreenSources(): Promise<ZegoElectronScreenSource[]>supported version: 2.11.0
detailed description: called when screen sharing is required in the electron framework to return screen list data.
business scenario: called when screen sharing is required in the electron framework.
call timing: after initialization.
precautions: none.
related callback: none.
related interface: createstream.
Electronic screen source list data
setCaptureAudioFrameCallback
setCaptureAudioFrameCallback(stream: MediaStream|ZegoLocalStream, callback: ((audioData:ZegoAudioFrame)=>void) | null, options?: AudioFrameOptions): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| stream | MediaStream|ZegoLocalStream | ZegoLocalStream created by createZegoStream or MediaStream created by createStream |
| callback | ((audioData:ZegoAudioFrame)=>void) | null | The callback function that receives audio data. If set to null, the audio data will no longer be called back. |
| options? | AudioFrameOptions | The option of callback function that receives audio data |
- Default value: None
Timing of calling: After the stream is the stream is collected successfully.
Restrictions on use: None
- The stream has an audio.
- It is only valid for RTC streams or L3 streams, and cannot operate CDN pull streams.
- Chrome browser support 85 above.
- Due to browser limitations, data callbacks are only available after interaction with the page.
Scope of influence: None
- Related callbacks: None
Related interface: None
- Platform differences: None
destroyStream
destroyStream(localStream: MediaStream | ZegoLocalStream): voidParameters
| Name | Type | Description |
|---|---|---|
| localStream | MediaStream | ZegoLocalStream | The stream created by createStream or the ZegoLocalStream instance object created by createZegoStream |
- Default value: None
- When to call: it can only be called after the stream is created.
Restrictions on use: None
In the process of streaming, destroying the streaming will cause the streaming to be interrupted. Please stop the streaming before destroying the streaming, otherwise the peer screen will be stuck.
Scope of influence: None
- Related callbacks: None
Related interface: create push stream data source createStream.
- Platform differences: None
checkVideoTrackIsActive
checkVideoTrackIsActive(stream: MediaStream | ZegoLocalStream): Promise<boolean>Parameters
| Name | Type | Description |
|---|---|---|
| stream | MediaStream | ZegoLocalStream | The stream created by createStream or the ZegoLocalStream instance object created by createZegoStream. |
- Default value: None
- When to call: it can only be called after the stream is created.
Restrictions on use: None
Only valid for local capture streams generated by createStream.
Scope of influence: None
- Related callbacks: None
Related interface: create push stream data source createStream.
- Platform differences: None
checkAudioTrackIsActive
checkAudioTrackIsActive(stream: MediaStream): Promise<boolean>Parameters
| Name | Type | Description |
|---|---|---|
| stream | MediaStream | The stream created by createStream or the ZegoLocalStream instance object created by createZegoStream. |
- Default value: None
- When to call: it can only be called after the stream is created.
Restrictions on use: None
Only valid for local capture streams generated by createStream.
Scope of influence: None
- Related callbacks: None
Related interface: create push stream data source createStream.
- Platform differences: None
startPublishingStream
startPublishingStream(streamID: string, localStream: MediaStream | ZegoLocalStream, publishOption?: ZegoWebPublishOption): booleanParameters
| Name | Type | Description |
|---|---|---|
| streamID | string | Stream ID, a string of up to 256 characters in length. Precautions: 1. The stream ID is defined by yourself. 2. It needs to be globally unique within the entire AppID. If it appears in the same AppID and different users push a stream with the same stream name, the user who pushed the stream later will fail to push the stream. 3. Only numbers, English characters and '-', '_' are supported. |
| localStream | MediaStream | ZegoLocalStream | The stream created by createStream or the ZegoLocalStream instance object created by createZegoStream. |
| publishOption | ZegoWebPublishOption | Push pull additional parameters (authentication, video coding), optional. |
- Default value: publishOption.videoCodec uses H.264 to push streaming by default. If you have special needs, you can choose VP8. For more scenarios, please consult ZEGO's pre-sales engineers.
- When to call: After the stream is successfully created.
- Related callbacks: Push quality callback PublishQualityUpdate, the thrill state callback PublisherstateUpdate (can be judged by this interface to determine if the stream is successful).
Related interface: End the stream by calling the interface StoppublishingStream.
Return
true means that the client sends the request successfully, and the stream is successfully pushed to the server and needs to be judged through the stream status callback interface.
stopPublishingStream
stopPublishingStream(streamID: string): booleanParameters
| Name | Type | Description |
|---|---|---|
| streamID | string | Push stream ID, consistent with push stream ID |
- Default value: None
Timing of calling: after successful push.
Restrictions on use: None
Stopping streaming will not cause the rendered <video> screen to be paused. Developers need to destroy the <video> by themselves.
Scope of influence: None
- Related callbacks: push stream quality callback publishQualityUpdate, push stream state callback publisherStateUpdate.
Related interface: startPublishingStream.
- Platform differences: None
sendSEI
sendSEI(streamID: string, inData: Uint8Array): booleanParameters
| Name | Type | Description |
|---|---|---|
| streamID | string | streamID |
| inData | Uint8Array | SEI data |
Details
While pushing the stream to transmit the audio and video stream data, the stream media enhancement supplementary information is sent to synchronize some other additional information.
- Use cases: Generally used in scenes such as synchronizing music lyrics or precise video layout, you can choose to send SEI.
- When to call: After starting to push the stream [startPublishingStream].
- Caution: 1. Supported browsers: Chrome 86 and above, Firefox 117 and above, Safari 15.4 and above, Android WeChat browser.
- Since the SEI information follows the video frame, there may be frame loss due to network problems, so the SEI information may also be lost. In order to solve this situation, it should be sent several times within the restricted frequency.
- SEI has high performance requirements, and simultaneous SEI operation on multiple streams may have an impact
- Related APIs: After the pusher sends the SEI, the puller can obtain the SEI content by monitoring the callback of [on] event "PlayerRecvSEI".
- Related callbacks: none.
- Available since: 2.16.0
- Restrictions: Do not exceed 30 times per second, and the SEI data length is limited to 4096 bytes.
setVideoConfig
setVideoConfig(localStream: MediaStream | ZegoLocalStream, constraints: ZegoPublishStreamConfig): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| localStream | MediaStream | ZegoLocalStream | The stream created by createStream or the ZegoLocalStream instance object created by createZegoStream. |
| constraints | ZegoPublishStreamConfig | Flow constraints |
- Default value: The default video capture resolution is 640 * 480, frame rate is 15, and bitrate is 800 kbps.
Timing of calling: After calling the interface createStream or createZegoStream to create a stream successfully. 2.15.0 and earlier versions can call this interface only after the stream is pushed successfully.
Restrictions on use: None
The modified localStream must be obtained by calling the createStream or createZegoStream method of the SDK.
Scope of influence: None
- Related callbacks: push stream quality callback publishQualityUpdate.
Related interface: None
- Platform differences: None
setAudioConfig
setAudioConfig(localStream: MediaStream | ZegoLocalStream, constraints: ZegoPublishStreamAudioConfig): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| localStream | MediaStream | ZegoLocalStream | The stream created by createStream or the ZegoLocalStream instance object created by createZegoStream. |
| constraints | ZegoPublishStreamAudioConfig | Flow constraints |
- Default value: None
Timing of calling: After calling the interface createStream or createZegoStream to create a stream successfully. 2.15.0 and earlier versions can call this interface only after the stream is pushed successfully.
Restrictions on use: None
The modified localStream must be obtained by calling the createStream or createZegoStream method of the SDK.
Scope of influence: None
- Related callbacks: push stream quality callback publishQualityUpdate.
Related interface: None
- Platform differences: None
replaceTrack
replaceTrack(localStream: MediaStream, mediaStreamTrack: MediaStreamTrack): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| localStream | MediaStream | Stream created by stream |
| mediaStreamTrack | MediaStreamTrack | Audio and video track |
- Default value: None
Timing of calling: This interface can be called only after the flow is successfully created.
Restrictions on use: None
The localStream to be replaced must be obtained by calling the createStream method of the SDK.
Scope of influence: None
- Related callbacks: None
Related interface: None
- Platform differences: None
addTrack
addTrack(localStream: MediaStream, track: MediaStreamTrack): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| localStream | MediaStream | Stream created by stream. |
| track | MediaStreamTrack | Video track. |
- Default value: None
Timing of calling: This interface can be called only after the flow is successfully created.
Restrictions on use: None
The localStream to be replaced must be obtained by calling the createStream method of the SDK.
Scope of influence: None
Related interface: removeTrack
removeTrack
removeTrack(localStream: MediaStream, track: MediaStreamTrack): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| localStream | MediaStream | Stream created by stream. |
| track | MediaStreamTrack | Video track. |
Details
Supported version: 2.22.0
Detailed description: Remove video track from media stream.
Timing of calling: This interface can be called only after the flow is successfully created.
The localStream to be replaced must be obtained by calling the createStream method of the SDK.
Related interface: addTrack
setCaptureVolume
setCaptureVolume(localStream: MediaStream | ZegoLocalStream, volume: number): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| localStream | MediaStream | ZegoLocalStream | The mediaStream or ZegoLocalStream instance object whose volume needs to be modified |
| volume | number | Volume size, 0-100 |
- Default value: None
- When to call: After the flow is successfully created.
Restrictions on use: None
This interface can only be called after the stream is successfully created. After mixing, it is only valid for the collected audio tracks. Please use the setMixingAudioVolume interface to adjust the volume of the mixing part.
Scope of influence: None
- Related callbacks: None
Related interface: None
- Platform differences: None
setDummyCaptureImagePath
setDummyCaptureImagePath(filePath: string, localStream: MediaStream | ZegoLocalStream): Promise<boolean>Parameters
| Name | Type | Description |
|---|---|---|
| filePath | string | Picture path |
| localStream | MediaStream | ZegoLocalStream | The stream object that needs to send pictures when the stream or ZegoLocalStream instance object is closed |
- When to call: After the flow is successfully created.
- Caution: This API can only be called after the stream is created successfully. The higher the static image resolution, the more performance is consumed. Therefore, it is recommended to select the required image size according to the required streaming resolution.
setStreamExtraInfo
setStreamExtraInfo(streamID: string, extraInfo: string): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| streamID | string | Stream ID |
| extraInfo | string | Stream additional information; extraInfo is a json format string |
- Default value: None
Timing of calling: after successful push.
Restrictions on use: None
Only strings are supported.
Scope of influence: None
- Related callbacks: Users who log in to the room for the first time can obtain additional stream information through roomStreamUpdate, and users who have already pulled streams in the room can obtain updated stream additional information through the stream additional information update callback streamExtraInfoUpdate.
Related interface: None
- Platform differences: None
enableVideoCaptureDevice
enableVideoCaptureDevice(localStream: MediaStream | ZegoLocalStream, enable?: boolean): Promise<boolean>Parameters
| Name | Type | Description |
|---|---|---|
| localStream | MediaStream | ZegoLocalStream | Create the camera media stream obtained by the stream or ZegoLocalStream instance object created. |
| enable | boolean | Identifies start or stop collection; true means start collection; false means stop collection; the default is true. |
- When to call: after the stream is created successfully.
- Caution:
- The premise of opening/closing the streaming screen is that the media stream must be a camera stream.
- If the track is replaced through the [replaceTrack] or [addTrack] interface, it is not supported to call this interface to stop the camera capture, and you can call the [MediaStreamTrack.stop] method to stop the camera capture.
Usage restrictions: Closing or opening the camera on hardware is a time-consuming operation, and there is a certain performance overhead when users operate frequently. It is generally recommended to use [mutePublishStreamVideo].
- Related callbacks: Calling the stop camera interface will trigger the camera status callback [remoteCameraStatusUpdate] of the corresponding stream on the streaming end.
- Related APIs: Turn on/off the sending stream video data interface [mutePublishStreamVideo] The response is faster and does not affect the video capture state.
Return
Promise returns a boolean indicating whether the call was successful.
addPublishCdnUrl
addPublishCdnUrl(streamID: string, targetURL: string): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| streamID | string | Stream ID |
| targetURL | string | CDN retweet address, the supported retweet address format is rtmp |
- Default value: None
Timing of calling: after successful push.
Restrictions on use: None
It is recommended to use the server-side dynamic retweet CDN to add the retweet CDN address API instead of the client API. This interface call may fail. If it returns a success, it only means that the instant server is notified of success, and it cannot be judged whether the instant server retweets the CDN successfully.
Scope of influence: None
- Related callbacks: None
Related interface: Notify the instant server to stop forwarding the stream to CDN removePublishCdnUrl.
- Platform differences: None
removePublishCdnUrl
removePublishCdnUrl(streamID: string, targetURL: string): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| streamID | string | Stream ID |
| targetURL | string | CDN retweet address, the supported retweet address format is rtmp |
- Default value: None
- When to call: After the retweet is successful
Restrictions on use: None
It is recommended to use the server-side dynamic retweet CDN to add the retweet CDN address API instead of the client API. This interface call may fail. If it returns a success, it only means that the instant server is notified of success, and it cannot be judged whether the instant server retweets the CDN successfully.
Scope of influence: None
- Related callbacks: None
Related interface: notify the instant server to push the stream to CDN addPublishCdnUrl.
- Platform differences: None
mutePublishStreamVideo
mutePublishStreamVideo(localStream: MediaStream | ZegoLocalStream, mute: boolean, retain?: boolean): booleanParameters
| Name | Type | Description |
|---|---|---|
| localStream | MediaStream | ZegoLocalStream | The stream created by createStream or the ZegoLocalStream instance object created by createZegoStream. |
| mute | boolean | Whether to stop sending the video stream; true means not sending the video stream; false means sending the video stream; the default is true. |
| retain | boolean | Whether to keep the preview screen, boolean value. true to keep, false not to keep, the default is false. |
-
When to call: After the flow is successfully created.
The prerequisite for opening/closing the stream screen is that the original stream must have a video track, and the stream cannot be pure audio when it is created.
-
Related callbacks: pull streaming camera status callback remoteCameraStatusUpdate.
Related interface: Turn on/off the streaming sound mutePublishStreamAudio that is being pushed.
Return
Identifies whether the push screen is successfully closed
mutePublishStreamAudio
mutePublishStreamAudio(localStream: MediaStream, mute: boolean): booleanParameters
| Name | Type | Description |
|---|---|---|
| localStream | MediaStream | Create stream obtained stream |
| mute | boolean | Whether to stop sending audio streams; true means not sending audio streams; false means sending video streams; the default is true. |
- When to call: After the flow is successfully created.
- The premise of turning on/off streaming sound is that the original stream must have an audio track, and it cannot be pure video when creating the stream.
- This interface will turn off all streaming sounds, including microphones, mixed-stream background music and other sounds, while muteMicrophone will only turn off the microphone sounds.
- Related callbacks: pull streaming microphone status callback remoteMicStatusUpdate.
Related interface: Close/open the streaming video mutePublishStreamVideo that is being pushed; close/open the microphone sound interface muteMicrophone.
setEffectsBeauty
setEffectsBeauty(localStream: MediaStream | ZegoLocalStream, enable: boolean, options?: ZegoEffectsBeautyParam): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| localStream | MediaStream | ZegoLocalStream | The stream created by createStream or the ZegoLocalStream instance object created by createZegoStream. |
| enable | boolean | Whether to enable beauty, true means on, false means off. |
| options | ZegoEffectsBeautyParam | Beauty options, including smoothIntensity (smoothing), whitenIntensity (whitening), rosyIntensity (rosy), sharpenIntensity (sharpening) four parameters, can be used to achieve beauty effects. The four intensity parameters range from 0 to 100, and the default value is 50. The options parameter is not required. |
Details
You can switch the beautification and adjust the beautification parameters through this interface to achieve a natural beautification effect.
- Use cases: Portrait beautify on the camera screen.
- When to call: After calling the interface createStream or createZegoStream to obtain the media stream.
- Caution: 1. The beauty effect is bound to the corresponding MediaStream, and the beauty effect of the active stream will not be changed when useVideoDevice and replaceTrack are called.
- The beautification process takes up resources and consumes performance. When you do not need to use the beautification, you need to call setEffectsBeauty(localStream,false) to close it in time.
- When calling destroyStream to destroy the stream, the SDK will close the beautifying effect. In other cases, the SDK will not actively close the beautifying process, and you need to call setEffectsBeauty(localStream,false) to close it.
- The browser of the mobile device does not support enabling beauty.
- Function setEffectsBeauty is asynchronous. You cannot start streaming during the opening process. If you need to enable beauty before publishing stream, you need to wait for the beauty interface to complete asynchronously before calling the startPublishingStream interface.
- Related callbacks: none.
- Available since: 2.13.0
setLowlightEnhancement
setLowlightEnhancement(localStream: MediaStream | ZegoLocalStream, mode: ZegoLowlightEnhancementMode): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| localStream | MediaStream | ZegoLocalStream | The stream created by createStream or the ZegoLocalStream instance object created by createZegoStream. |
| mode | ZegoLowlightEnhancementMode | Low light enhanced mode. |
Details
According to the set low-light enhancement mode, the brightness of the image captured by the camera is enhanced, which is compatible with the beauty function. Users can watch the effect while previewing and toggle the low-light enhancement mode in real time.
- Use cases: The environment on the streaming end is dark, or the frame rate set by the camera is high, which causes the picture to be dark, and the subject cannot be displayed or recognized normally.
- Default value: close.
- When to call: After calling createstream or createZegoStream to create the preview stream.
- Caution: The interface compatibility is the same as setEffectsBeauty, but not compatible with mobile browsers.
- Available since: 2.18.0
enableDualStream
enableDualStream(localStream: MediaStream | ZegoLocalStream): voidParameters
| Name | Type | Description |
|---|---|---|
| localStream | MediaStream | ZegoLocalStream | The stream created by createStream or the ZegoLocalStream instance object created by createZegoStream. |
Details
supported version: 2.18.0 and above.
detailed description: you can switch the size flow through this interface.
business scenario: Different terminals are required to display video streams of different quality or to maintain a smooth connection to the microphone in a poor network environment.
call timing: after successfully calling the create stream interface, before pushing the stream interface.
precautions: none.
related callback: none.
setLowStreamParameter
setLowStreamParameter(localStream: MediaStream | ZegoLocalStream, param: { width: number; height: number; frameRate: number; bitRate: number }): voidParameters
| Name | Type | Description |
|---|---|---|
| localStream | MediaStream | ZegoLocalStream | The stream created by createStream or the ZegoLocalStream instance object created by createZegoStream. |
| param | { width: number; height: number; frameRate: number; bitRate: number } | low stream parameters, resolution, frame rate and bitrate. |
Details
supported version: 2.18.0 and above.
detailed description: you can set small flow parameters through this interface.
business scenario: Different terminals are required to display video streams of different quality or to maintain a smooth connection to the microphone in a poor network environment.
call timing: after successfully calling the create stream interface, before pushing the stream interface.
precautions: None.
related callback: none.
enableHardwareEncoder
enableHardwareEncoder(enable: boolean): voidParameters
| Name | Type | Description |
|---|---|---|
| enable | boolean | Whether to enable hardware coding; true means enable hard coding; false means turn off hard coding; the default is false. |
- When to call: The settings can only take effect before pushing the stream. If the settings are set after the stream is pushed, it can take effect when the stream is restarted after the push is stopped.
- Caution: Since the hard-coding support of a small number of devices is not particularly good, the SDK uses the software coding method by default. If the developer finds that the device heats up when the audio and video streams are pushed to a larger resolution when testing some models, consider calling this function to enable hard coding.
enableAutoSwitchDevice
enableAutoSwitchDevice(config: ZegoAutoSwitchDeviceConfig): voidParameters
| Name | Type | Description |
|---|---|---|
| config | ZegoAutoSwitchDeviceConfig | Related configuration of device automatic switching |
Details
Pass in the relevant configuration to enable or disable the automatic switching of related devices. After the device is unplugged, it supports automatic switching of other available devices currently in use. The SDK disables automatic device switching by default.
- Use cases: After the SDK is created and initialized, the compatible operation of device plugging and unplugging.
- Available since: 2.20.0 and above.
initBackgroundModule
initBackgroundModule(segmentation: Segmentation, assetsURL: string): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| segmentation | Segmentation | background segmentation mode. |
| assetsURL | string | resource file path. |
Details
Initialize the background processing module.
- Use cases: Replace the real background with a custom image.
- Default value: None.
- When to call /Trigger: After new ZegoExpressEngine.
- Currently only supports the use of the PC terminal, the mobile terminal is not currently supported.
- Available since: 2.24.0
setBackgroundBlurOptions
setBackgroundBlurOptions(localStream: MediaStream | ZegoLocalStream, options: BackgroundBlurOptions): Promise<boolean>Parameters
| Name | Type | Description |
|---|---|---|
| localStream | MediaStream | ZegoLocalStream | The stream created by createStream or the ZegoLocalStream instance object created by createZegoStream. |
| options | BackgroundBlurOptions | Parameters for background blur processing. |
Details
Set parameters for background blur of the stream.
- Use cases: Blur the real scene around the user.
- Default value: None
- When to call /Trigger: After calling the interface the initBackgroundModule successfully and calling the interface createStream or createZegoStream to create a stream successfully.
- Currently only supports the use of the PC terminal, the mobile terminal is not currently supported;
- Available since: 2.24.0
setVirtualBackgroundOptions
setVirtualBackgroundOptions(localStream: MediaStream | ZegoLocalStream, options: BackgroundVirtualOptions): Promise<boolean>Parameters
| Name | Type | Description |
|---|---|---|
| localStream | MediaStream | ZegoLocalStream | The stream created by createStream or the ZegoLocalStream instance object created by createZegoStream. |
| options | BackgroundVirtualOptions | parameters for virtual background processing. |
Details
Set parameters for virtual background processing
- Use cases: Process virtual background for streaming
- Default value: None
- When to call /Trigger: After calling the interface initBackgroundModule and calling the interface createStream to create a stream successfully.
- Currently only supports the use of the PC terminal, the mobile terminal is not currently supported;
- Before use, you need to call the ZegoExpressEngine.use method to import the virtual background module.
- Available since: 2.24.0
setTransparentBackgroundOptions
setTransparentBackgroundOptions(localStream: MediaStream): Promise<boolean>Parameters
| Name | Type | Description |
|---|---|---|
| localStream | MediaStream | media stream. |
Details
Set parameters for transparent background processing
- Use cases: Process transparent background for streaming
- Default value: None
- When to call /Trigger: After calling the interface initBackgroundModule and calling the interface createStream or createZegoStream to create a stream successfully.
- Currently only supports the use of the PC terminal, the mobile terminal is not currently supported;
- Before use, you need to call the ZegoExpressEngine.use method to import the virtual background module.
- Available since: 2.24.0
enableBackgroundProcess
enableBackgroundProcess(localStream: MediaStream | ZegoLocalStream, enable: boolean, segmentation: Segmentation): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| localStream | MediaStream | ZegoLocalStream | The stream created by createStream or the ZegoLocalStream instance object created by createZegoStream. |
| enable | boolean | turn background processing on or off. |
| segmentation | Segmentation | background segmentation mode. |
Details
Perform background processing on stream.
- Use cases: Perform background processing on the pushed stream.
- Default value: None
- When to call /Trigger: When to call /Trigger: After calling the interface createStream or createZegoStream to create a stream successfully.
- Currently only supports the use of the PC terminal, the mobile terminal is not currently supported;
- Available since: 2.24.0
setVoiceChangerParam
setVoiceChangerParam(localStream: MediaStream | ZegoLocalStream, voiceParam: number): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| localStream | MediaStream | ZegoLocalStream | The stream created by createStream or the ZegoLocalStream instance object created by createZegoStream. |
| voiceParam | number | The pitch parameter voiceParam has a value range of [-12.0, 12.0]. The larger the value, the sharper the sound. Setting it to 0.0 will turn off the voice changer. |
Details
Customize the voice changing effect through parameter settings.
- Use cases: Switch voice changer reduction before or during streaming.
- Default value: None
- When to call /Trigger: After calling the interface createStream or createZegoStream to create a stream successfully.
- Currently only supports voice changer reduction for a specific stream, and does not support simultaneous noise reduction for multiple streams; 2.The pitch parameter voiceParam has a value range of [-12.0, 12.0]. The larger the value, the sharper the sound. Setting it to 0.0 will turn off the voice changer.
- Available since: 2.23.0
setVoiceChangerPreset
setVoiceChangerPreset(preset: ZegoVoiceChangerPreset, localStream: MediaStream | ZegoLocalStream): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| preset | ZegoVoiceChangerPreset | Preset value for changing sound. |
| localStream | MediaStream | ZegoLocalStream | The stream created by createStream or the ZegoLocalStream instance object created by createZegoStream. |
Details
Perform voice changer reduction processing on the pushed media stream.
- Use cases: Switch voice changer reduction before or during streaming.
- Default value: None
- When to call /Trigger: After calling the interface createStream or createZegoStream to create a stream successfully.
- Currently only supports voice changer reduction for a specific stream, and does not support simultaneous noise reduction for multiple streams;
- Available since: 2.23.0
setReverbPreset
setReverbPreset(localStream: MediaStream | ZegoLocalStream, preset: ZegoReverbPreset): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| localStream | MediaStream | ZegoLocalStream | Media streams or ZegoLocalStream instance object created by createZegoStream that require reverb processing. |
| preset | ZegoReverbPreset | Reverb preset enumeration value. |
Details
You can set the preset reverb effect by calling this function.
- Use cases: It is often used in live broadcast, chat room and KTV and other scenarios.
- Default value: None
- When to call /Trigger: After calling the interface createStream or createZegoStream to create a stream successfully.
- Currently, only one specific stream is supported for audio mixing, and simultaneous reverberation for multiple streams is not supported.
- The effect of using this function and [setVoiceChangerPreset] at the same time may be different from the expected effect. If you need to use it at the same time, it is recommended to enable the voice changer first, and then enable the reverberation.
- Available since: 3.0.0
enableVirtualStereo
enableVirtualStereo(localStream: MediaStream | ZegoLocalStream, enable: boolean, angle: number): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| localStream | MediaStream | ZegoLocalStream | Media streams or ZegoLocalStream instance object created by createZegoStream that require reverb processing. |
| enable | boolean | true means to enable virtual stereo, and false means to disable virtual stereo. |
| angle | number | The angle of the sound source in the virtual stereo, the range is -1 ~ 360, 90 is the front, 0 / 180 / 270 correspond to the rightmost / leftmost / directly behind respectively; especially, when setting -1, it is a full-scale virtual stereo effect. |
Details
You can turn on/off the virtual stereo effect when streaming by calling this function.
- Use cases: It is often used in live broadcast, chat room and KTV and other scenarios.
- Default value: None
- When to call: After calling the interface createStream or createZegoStream to create a stream successfully.
- Currently, only one specific stream is supported for audio mixing, and simultaneous reverberation for multiple streams is not supported.
- It is necessary to call [createStream] or [createZegoStream] to set the parameters of the two-channel virtual stereo to take effect.
- The effects of the virtual stereo and reverb functions conflict, and the effects may not meet expectations, so do not use them in combination.
- The virtual stereo function is not supported on Mac Safari and mobile device browsers.
- Available since: 3.0.0
enableAiDenoise
enableAiDenoise(localStream: MediaStream | ZegoLocalStream, enable: boolean): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| localStream | MediaStream | ZegoLocalStream | AI noise reduction incoming media stream the ZegoLocalStream instance object created by createZegoStream |
| enable | boolean | Turn on/off AI noise reduction |
Details
Perform AI noise reduction processing on the pushed media stream.
- Use cases: Switch AI noise reduction before or during streaming.
- Default value: None
- When to call /Trigger: After calling the interface createStream or createZegoStream to create a stream successfully.
- Currently using the AI noise reduction function requires a special editing package for technical support;
- Currently only supports the use of the PC terminal, the mobile terminal is not currently supported;
- Currently only supports AI noise reduction for a specific stream, and does not support simultaneous noise reduction for multiple streams;
- Available since: 2.19.0
setAiDenoiseMode
setAiDenoiseMode(localStream: MediaStream | ZegoLocalStream, mode: AiDenoiseMode): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| localStream | MediaStream | ZegoLocalStream | AI noise reduction incoming media stream the ZegoLocalStream instance object created by createZegoStream |
| mode | AiDenoiseMode | the ai denoise mode |
Details
Perform AI noise reduction processing on the pushed media stream.
- Use cases: Switch AI noise reduction before or during streaming.
- Default value: None
- When to call /Trigger: After calling the interface createStream or createZegoStream to create a stream successfully.
- Currently using the [setAiDenoiseMode] requires a special editing package for technical support;
- Currently only supports the use of the PC terminal, the mobile terminal is not currently supported;
- Available since: 3.3.0
setStreamAlignmentProperty
setStreamAlignmentProperty(streamID: string, alignment: number): Promise<boolean>Parameters
| Name | Type | Description |
|---|---|---|
| streamID | string | The streamID of the push stream. |
| alignment | number | Whether to enable alignment, 0 is off, 1 is on. |
- Default value: If this interface is not adjusted, the default is not aligned.
- When to call: After the push is successful.
Related interface: Start the mixing interface startMixerTask. After the mixing task turns on the precise alignment function, the aligned streams will be aligned.
Return
Asynchronously returns a Boolean value to identify whether the call is successful.
startPlayingStream
startPlayingStream(streamID: string, playOption?: ZegoWebPlayOption): Promise<MediaStream>Parameters
| Name | Type | Description |
|---|---|---|
| streamID | string | Stream ID, required. |
| playOption | ZegoWebPlayOption | Pull flow additional parameters, optional. |
Details
Supported version: 1.0.0 and above.
Detailed description: call the streaming interface to obtain the streaming address.
Business scenario: Required when pulling streams.
Calling time: after receiving the new pull stream, that is, after the roomStreamUpdate callback.
- Before pulling the stream, make sure that the stream has been successfully pushed (pushed to the ZEGO server), that is, the stream is pulled after the roomStreamUpdate callback.
Related Tonance: Padd Quality Pick-up PlayqualityUpdate, drawing Status Tune PlayerstateUpdate (can be judged by this callback to determine if the draw is successful).
Related interface: Call the interface [stopPlayingStream] to stop.
Return
Promise returns the streaming media object asynchronously.
stopPlayingStream
stopPlayingStream(streamID: string): voidParameters
| Name | Type | Description |
|---|---|---|
| streamID | string | Stream ID,Required |
- Default value: None
Timing of calling: After the stream is successfully pulled.
Restrictions on use: None
The player will not be destroyed after the streaming is stopped, and the player must be destroyed by the developer.
Scope of influence: None
- Related callbacks: pull stream quality callback playQualityUpdate, pull stream state callback playerStateUpdate.
Related interface: start streaming startPlayingStream.
- Platform differences: None
mutePlayStreamVideo
mutePlayStreamVideo(streamID: string, mute: boolean): Promise<boolean>Parameters
| Name | Type | Description |
|---|---|---|
| streamID | string | stream ID |
| mute | boolean | Whether to pull the video stream, true means stop drawing; false means resume drawing |
- Default value: None
Timing of calling: After the stream is successfully pulled.
Restrictions on use: None
- The premise of stopping or resuming the video stream is that the original stream must have a video track, and the stream cannot be pure audio.
- It is only valid for RTC streams or L3 streams, and cannot operate CDN pull streams.
Scope of influence: None
- Related callbacks: None
Related interface: Stop or resume pulling the audio stream mutePlayStreamAudio.
- Platform differences: None
setAudioFrameCallback
setAudioFrameCallback(streamID: string, callback: ((audioData:ZegoAudioFrame)=>void) | null, options?: AudioFrameOptions): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| streamID | string | stream ID |
| callback | ((audioData:ZegoAudioFrame)=>void) | null | The callback function that receives audio data. If set to null, the audio data will no longer be called back. |
| options? | AudioFrameOptions | The option of callback function that receives audio data |
- Default value: None
Timing of calling: After the stream is pulled successfully or the stream is collected successfully.
Restrictions on use: None
- The stream has an audio.
- It is only valid for RTC streams or L3 streams, and cannot operate CDN pull streams.
- Chrome browser support 85 above.
- Due to browser limitations, data callbacks are only available after interaction with the page.
Scope of influence: None
- Related callbacks: None
Related interface: None
- Platform differences: None
setPlayStreamVideoType
setPlayStreamVideoType(streamID: string, streamType: number): Promise<boolean>Parameters
| Name | Type | Description |
|---|---|---|
| streamID | string | stream ID |
| streamType | number | play stream type, 0 is small flow, 1 is large flow, 2 is automatic |
- Default value: None
Timing of calling: After the stream is successfully pulled.
Restrictions on use: None
None
Scope of influence: None
- Related callbacks: None
Related interface: None
- Platform differences: None
muteAllPlayAudioStreams
muteAllPlayAudioStreams(mute: boolean): Promise<boolean>Parameters
| Name | Type | Description |
|---|---|---|
| mute | boolean | Stop or resume pulling all audio streams, true means stop pulling; false means resume pulling. |
Details
Supported version: 3.3.0
Detailed description: During the real-time audio and video interaction process, local users can use this function to control whether to receive the audio data of all remote users when pulling streams (including those pushed by users who newly join the room after calling this function). audio stream). By default, users can receive audio data pushed by all remote users after joining the room. This reduces hardware and network overhead when developers do not receive audio receipts.
Business scenario: When developers need to quickly close and restore remote audio, they can call this function. Compared with re-pulling streams, it can greatly reduce time consumption and improve interactive experience.
Timing of calling: After initializing the engine.
Related interface: You can call the [mutePlayStreamAudio] function to control whether to receive a single piece of audio data.
muteAllPlayVideoStreams
muteAllPlayVideoStreams(mute: boolean): Promise<boolean>Parameters
| Name | Type | Description |
|---|---|---|
| mute | boolean | Stop or resume pulling all video streams, true means stop pulling; false means resume pulling. |
Details
Supported version: 3.3.0
Detailed description: During the real-time audio and video interaction process, the local user can use this function to control whether to receive the video data of all remote users when pulling the stream (including those pushed by users who newly join the room after calling this function). video streaming). By default, users can receive video data pushed by all remote users after joining the room. Reduces hardware and network overhead when developers do not receive video receipts.
Business scenario: When developers need to quickly close and restore remote video, they can call this function. Compared with re-pulling streams, it can greatly reduce time consumption and improve interactive experience.
Timing of calling: After initializing the engine.
Related interface: You can call the [mutePlayStreamVideo] function to control whether to receive a single piece of video data.
mutePlayStreamAudio
mutePlayStreamAudio(streamID: string, mute: boolean): Promise<boolean>Parameters
| Name | Type | Description |
|---|---|---|
| streamID | string | stream ID |
| mute | boolean | Whether to pull the audio stream, true means stop drawing; false means resume drawing |
- Default value: None
Timing of calling: After the stream is successfully pulled.
Restrictions on use: None
- The prerequisite for stopping or resuming the audio stream is that the original stream must have an audio track, and the stream cannot be pure video.
- It is only valid for RTC streams or L3 streams, and cannot operate CDN pull streams.
Scope of influence: None
- Related callbacks: None
Related interface: Stop or resume pulling the video stream mutePlayStreamVideo.
- Platform differences: None
getPlayingStreamQuality
getPlayingStreamQuality(streamID: string): ZegoPlayStats | nullParameters
| Name | Type | Description |
|---|---|---|
| streamID | string | ID of stream. |
Details
Actively obtain the stream quality that is being playing.
- Use cases: Obtain the quality parameters such as the resolution, frame rate, and bit rate of the current playing stream.
- When to call: [startPlayingStream] After the push stream is successful.
- Related APIs: Pull streaming quality callback [playQualityUpdate].
- Available since: 2.15.0
- Restrictions: Since the streaming quality parameters of the SDK are updated every 3 seconds, it is recommended that the calling interval of this interface should not be less than 3 seconds.
Return
Playing stream quality information, if the acquisition fails, it will return null.
createLocalStreamView
createLocalStreamView(localStream: MediaStream): ZegoStreamViewParameters
| Name | Type | Description |
|---|---|---|
| localStream | MediaStream | Local media stream, obtained through the createStream interface. |
Details
Creates an instance object of the Media Stream Player component for playing the preview stream.
- Use cases: You need to play media streaming images such as camera and screen sharing on the interface.
- When to call /Trigger: You need to call the interface createstream to obtain the media stream object as an input parameter.
- Caution: Only one instance object of the media stream player component can be created corresponding to each media stream object.
- Available since: 2.17.0
Return
The media stream player component instance.
createRemoteStreamView
createRemoteStreamView(remoteStream: MediaStream): ZegoStreamViewParameters
| Name | Type | Description |
|---|---|---|
| remoteStream | MediaStream | The remote media stream, obtained through the [startPlayingStream] interface. |
Details
Create a media stream player component instance object for playing the pull stream.
- Use cases: The pulled remote media streaming screen needs to be displayed on the page.
- When to call /Trigger: You need to call the interface [startPlayingStream] to get the media stream object as an input parameter.
- Caution: Only one instance object of the media stream player component can be created corresponding to each media stream object.
- Available since: 2.17.0
Return
The media stream player component instance.
startAutoMixerTask
startAutoMixerTask(task: ZegoAutoMixerTask): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| task | ZegoAutoMixerTask | Automatic mixed flow task object. |
Details
Local users can call this function to start the automatic mixing task to mix all streams in the room. Currently, only audio streams are automatically mixed. After starting the automatic mixing, the audio of all streams in the room will be automatically mixed, and the push streams initiated in this room will also be automatically mixed into the final output stream.
- Use cases: It is often used in voice chat room scenarios when the client needs to initiate an automatic streaming task.
- When to call: After creating the engine, if the target room has been created, you can call this function to start automatic streaming in the target room.
- Caution: Before starting the next automatic stream mixing task in the same room, please call the [stopAutoMixerTask] function to end the previous automatic stream mixing task first, so as to avoid the situation where the audience is still pulling the output stream of the previous automatic stream mixing task when a host has started the next automatic stream mixing task to mix with other hosts. If the user does not actively end the current automatic stream mixing task, the task will automatically end after the room no longer exists or the input stream does not exist for 90 seconds.
Security reminder: Please do not fill in sensitive user information in this interface, including but not limited to mobile phone number, ID number, passport number, real name, etc.
- Related APIs: You can call the [stopAutoMixerTask] function to stop the automatic stream mixing task.
- Available since: 3.5.0 and above.
startMixerTask
startMixerTask(mixStreamConfig: ZegoMixStreamConfig): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| mixStreamConfig | ZegoMixStreamConfig | Mixed flow parameter configuration |
Details
Combine multiple streams into one stream according to the calling requirements. Since the actual action is operated on the server side, there is no restriction on browser performance, and the delay between each stream is low, which can ensure the synchronization of the pictures and sounds of multiple streams being mixed.
- Use cases: It is usually used in the scenario where multiple anchors are connected to the PK. The audio and video streams of multiple anchors are mixed into one stream, and the audience only needs to pull this stream.
- When to call: After calling the interface startPublishingStream to publish the streams successfully.
- Caution: The corresponding AppID enables the muxing function; the mixed stream must exist on the ZEGO server.
Security reminder: Please do not fill in sensitive user information in this interface, including but not limited to mobile phone number, ID number, passport number, real name, etc.
- Related APIs: Use the interface stopMixerTask to stop server-side mixing. Failure to stop the mixing function in time will affect billing.
- Available since: 1.5.2 and above.
- Restrictions: Before mixing, you need to ensure that the stream still exists, and avoid triggering the muxing and stream deletion operations at the same time, so as to avoid the muxing failure. if the muxing stream stops pushing the stream, you need to perform the muxing process again, otherwise the peer screen will be stuck.
stopAutoMixerTask
stopAutoMixerTask(task : { taskID: string; roomID: string; }): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| task | { taskID: string; roomID: string; } | The taskID of the task corresponding to the stop mixing task and the roomID of the room. |
Details
Local users can call this function to end the automatic stream mixing task.
- Use cases: It is often used in voice chat room scenarios when the client needs to initiate an automatic streaming task.
- When to call: After calling the interface startAutoMixerTask and mixing successfully.
Security reminder: Please do not fill in sensitive user information in this interface, including but not limited to mobile phone number, ID number, passport number, real name, etc.
- Related APIs: startAutoMixerTask
- Available since: 3.5.0 and above.
stopMixerTask
stopMixerTask(taskID: string): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| taskID | string | Mixed-flow task ID (customized by the customer, must be unique), required, the maximum length is 256 characters, only supports numbers, English characters and'~','!','@','#','$', '','^','&','*','(',')','_','+','=','-',',';',''', ' ,',' |
Details
used to stop the server-side mixed-flow task corresponding to taskID.
- Use cases: It is usually used in the scenario where multiple anchors are connected to the microphone PK, and the muxing is stopped after the use of the muxing screen is finished.
- When to call: After calling the interface startMixerTask and mixing successfully.
- Caution: You must initiate a stop muxing when you close the page, to avoid abnormally closing the muxing without stopping, which will affect the billing; if the muxing stream stops pushing, you need to do the muxing process again, otherwise the peer screen will be stuck.
Security reminder: Please do not fill in sensitive user information in this interface, including but not limited to mobile phone number, ID number, passport number, real name, etc.
- Related APIs: startMixerTask
- Available since: 1.5.2 and above.
setMixerTaskConfig
setMixerTaskConfig(config: ZegoMixStreamAdvance): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| config | ZegoMixStreamAdvance | Mixed flow advanced function settings. |
Details
Advanced settings for muxing function, you can set the video background and video encoding format.
- Use cases: 1. Set the background of mixed flow picture; 2. Video coding conversion to be compatible with the playback of some browsers.
- When to call: It must be called before startMixerTask is used to take effect and stream is successfully published.
Security reminder: Please do not fill in sensitive user information in this interface, including but not limited to mobile phone number, ID number, passport number, real name, etc.
- Related APIs: startMixerTask
- Available since: 1.5.2 and above.
startMixingAudio
startMixingAudio(streamID: string | MediaStream | ZegoLocalStream, mediaList: Array<HTMLMediaElement>): booleanParameters
| Name | Type | Description |
|---|---|---|
| streamID | string | MediaStream | ZegoLocalStream | The stream ID or MediaStream object or ZegoLocalStream instance object that needs to be mixed. |
| mediaList | Array<HTMLMediaElement> | 1. Local array of <audio> or <video> objects. 2. The operation of the sound effect (including pause/resume) needs to be completed by operating the <audio> or <video> object. |
Details
Mix the sound being played by the HTMLMediaElement object into the push stream corresponding to the streamID, that makes the stream being published contain mixed sound.
- Use cases: usually used for background music and sound effects.
- When to call: After calling the interface createStream or createZegoStream to create a stream successfully. 2.15.0 and earlier versions can call this interface only after the stream is pushed successfully.
- Caution: - You need to make sure that the HTMLMediaElement loads properly. For example, to avoid cross-domain resource load failure, set the property crossOrigin = 'anonymous' on HTMLMediaElement
- Since version 86 of the Chrome browser, the local audio tag is set to mute, and the mixed background sound cannot be heard on the streaming end.
- Affected by the Safari browser policy, if the audio tag is set to mute, it will automatically pause after playback and multiple audios cannot be mixed too.
Security reminder: Please do not fill in sensitive user information in this interface, including but not limited to mobile phone number, ID number, passport number, real name, etc.
- Impacts on other APIs: Most interfaces can be called after logging in to the room.
- Related APIs: You can call the interface stopMixingAudio to stop mixing.
- Available since: 1.7.0 and above.
- Restrictions: Do not include more than 6 in the mix, and the length of the mediaList should not be greater than 6, otherwise performance problems will occur and the page will freeze.
stopMixingAudio
stopMixingAudio(streamID: string | MediaStream, mediaList?: Array<HTMLMediaElement>): booleanParameters
| Name | Type | Description |
|---|---|---|
| streamID | string | MediaStream | The stream ID or MediaStream object being mixed. |
| mediaList | Array<HTMLMediaElement> | 1. Local array of <audio> or <video> objects, optional. 2. The operation of the sound effect (including pause/resume) needs to be completed by operating the <audio> or <video> object. |
Details
Control the pause of one or more music through the mediaList passed in, and stop all mixing of the stream if this parameter is not passed in.
- Use cases: Usually used to control the pause of background music and sound effects.
- When to call: After calling startMixingAudio. After version 2.16.0, the preview stage operation mixing is supported.
- Caution: It is checked that "customCapture" is false through the capability check interface checkSystemRequirements, that is, the browser does not support obtaining the MediaStream of the media element, and this interface cannot be used.
Security reminder: Please do not fill in sensitive user information in this interface, including but not limited to mobile phone number, ID number, passport number, real name, etc.
- Impacts on other APIs: Most interfaces can be called after logging in to the room.
- Related APIs: startMixingAudio
- Available since: 1.7.0 and above.
setMixingAudioVolume
setMixingAudioVolume(streamID: string | MediaStream, volume: number, media: HTMLMediaElement): booleanParameters
| Name | Type | Description |
|---|---|---|
| streamID | string | MediaStream | stream ID or MediaStream object. |
| volume | number | volume, the range is 0~100, 100 represents the original volume. |
| media | HTMLMediaElement | Media tags < video > or < audio >. |
Details
Adjust the mixing volume of the media element through the incoming volume value and media element.
- Use cases: Usually used to adjust the volume of background music or sound effects.
- When to call: After calling startMixingAudio. 2.16.0 and later versions support the preview stage to manipulate mixes.
- Caution: Since version 86 of the Chrome browser, the local audio tag is set to mute, and there is no sound in the mixed audio at playing stream end.
Security reminder: Please do not fill in sensitive user information in this interface, including but not limited to mobile phone number, ID number, passport number, real name, etc.
- Impacts on other APIs: Most interfaces can be called after logging in to the room.
- Related APIs: startMixingAudio
- Available since: 1.18.0 and above.
enableLiveAudioEffect
enableLiveAudioEffect(player: HTMLMediaElement, enable: boolean, mode: ZegoLiveAudioEffectMode): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| player | HTMLMediaElement | H5 audio or video tag element object. |
| enable | boolean | Whether to enable live sound effects. |
| mode | ZegoLiveAudioEffectMode | Live sound effect mode. |
Details
After turning on the live sound effects, the sense of space is enhanced and the sound of musical instruments is enhanced and prominent.
- When to call: After initializing a ZegoExpresEngine instance.
Cautions:
- In order to enhance the on-site sound experience, we recommend configuring dual channel encoding. Developers can achieve this configuration by setting the parameter [ZegoCaptureMicrophone. channelCount] to 2 when using the [startCaptureMicrophone] interface. If dual channel encoding is not configured, the performance of certain songs may be significantly reduced, as the effects of the left and right channels may cancel out each other when synthesizing a single channel, resulting in less noticeable effects.
- This interface can only be effective for one h5 player. When the effect is turned on for a new audio tag, the effect will be turned off for other h5 players that have the effect turned on.
- Available since: 3.0.0
Return
Return the call result asynchronously.
setAudioChangerParam
setAudioChangerParam(player: HTMLMediaElement, pitch: number, mode: ZegoLiveAudioEffectMode): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| player | HTMLMediaElement | H5 audio or video tag element object. |
| pitch | number | Tone value, range [-12.0, 12.0], the higher the value, the sharper the sound. Set 0.0 to turn off the tone processing. |
| mode | ZegoLiveAudioEffectMode | Live sound effect mode. |
Details
It is generally used in chat rooms and karaoke scenes to realize the adjustment of the accompaniment.
- When to call: After initializing a ZegoExpresEngine instance.
Cautions: If the audio change setAudioChangerParam interface is used at the same time as the enableLiveAudioEffect interface, this interface takes effect for only one h5 player. When the new audio tag is enabled or setAudioChangerParam and enableLiveAudioEffect are passed to different h5 players, the h5 player whose effects are enabled first will be disabled. That is, the setAudioChangerParam and enableLiveAudioEffect cannot take effect on multiple audio devices.
- Available since: 3.0.0
Return
Return the call result asynchronously.
createAudioEffectPlayer
createAudioEffectPlayer(localStream: MediaStream | ZegoLocalStream): ZegoAudioEffectPlayerParameters
| Name | Type | Description |
|---|---|---|
| localStream | MediaStream | ZegoLocalStream | The stream created by createStream or the ZegoLocalStream instance object created by createZegoStream. |
Details
Create a audio effect player instance.
- Use cases: When you need to play short sound effects, such as applause, cheers, etc., you can use the sound effect player to achieve.
- When to call /Trigger: You need to call the interface createstream or createZegoStream to obtain the media stream object as an input parameter.
- Caution:
- Only one valid player instance object can be created corresponding to each media stream object.
- In version 2.15.0, you need to complete the push stream before you can operate the player corresponding to the stream. Version 2.16.0 and later supports the audio player that operates the stream before pushing the stream.
- Available since: 2.15.0
Return
The sound player instance object.
loadAudioEffect
loadAudioEffect(audioEffectID: string, path: string): Promise<string>Parameters
| Name | Type | Description |
|---|---|---|
| audioEffectID | string | ID of the sound resource. |
| path | string | Specifies the request path of the online sound effect file. The following audio formats are supported: MP3, AAC, and other audio formats supported by the browser. |
Details
Load sound resources.
- Use cases: In the scenario of frequently playing the same sound effect, the SDK provides the function of preloading the sound effect file into the memory in order to reduce the waste of network and performance resources of repeatedly reading and decoding the file.
- When to call /Trigger: Callable after [createAudioEffectPlayer].
Related interfaces: Play audio effect interface [ZegoAudioEffectPlayer.start], release audio interface [unloadEffect].
- Caution:
- Online audio files need to comply with the Same-origin policy.
- The following audio formats are supported: MP3, AAC and other audio formats supported by the browser.
- Available since: 2.15.0
Return
Asynchronously returns the sound resource ID.
unloadAudioEffect
unloadAudioEffect(audioEffectID: string): booleanParameters
| Name | Type | Description |
|---|---|---|
| audioEffectID | string | ID of the sound resource. |
Details
Unload the sound resource for the specified sound ID.
- Use cases: After the sound effect is used up, related resources can be released through this interface.
- When to call /Trigger: Callable after [loadAudioEffect].
Related interfaces: Load the audio interface [loadAudioEffect] .
- Caution: none.
- Available since: 2.15.0
Return
Whether the interface call is successful.
enumDevices
enumDevices(): Promise<ZegoDeviceInfos>- Default value: None
- When to call: after initialization, before creating a stream.
Restrictions on use: None
- This interface needs to be called under the secure domain name (https, localhost, 127.0.0.1).
- Before calling this interface, you need to obtain device permissions. You can call checkSystemRequirements("camera") to authorize camera permissions, and call checkSystemRequirements("microphone") to authorize camera permissions.
- If the interface cannot be completely trusted, it is necessary to downgrade the situation where the device information cannot be obtained, for example: prompting the customer to change the browser.
- Some platform browsers (such as: Safari, iOS) may obtain an empty device name. It is recommended to call this interface again to obtain the correct device name.
- After the page is refreshed, the device ID may change and needs to be obtained again.
- Some browsers can obtain the device ID only after calling the createStream interface to obtain permission.
- safari does not support getting speaker information.
Scope of influence: None
- Related callbacks: None
Related interfaces: createStream, useAudioDevice, useVideoDevice.
- Platform differences: None
getCameras
getCameras(): Promise<ZegoDeviceInfo[]>- Default value: None
- When to call: after initialization, before creating a stream.
Restrictions on use: None
- Due to the browser's security and privacy protection, the page needs to call this interface in a secure environment (https, localhost, 127.0.0.1). See Privacy and security.
- If the page device permission is not granted, calling this method will temporarily open the camera to trigger the browser's camera device permission application. On browsers such as Chrome 81+, Firefox, Safari, etc., accurate device information cannot be obtained without media device permissions.
Scope of influence: None
- Related callbacks: None
Related interfaces: createStream, useVideoDevice, createZegoStream.
- Platform differences: None
Return camera device list information.
getMicrophones
getMicrophones(): Promise<ZegoDeviceInfo[]>- Default value: None
- When to call: after initialization, before creating a stream.
Restrictions on use: None
- Due to the browser's security and privacy protection, the page needs to call this interface in a secure environment (https, localhost, 127.0.0.1). See Privacy and security.
- If the page device permission is not granted, calling this method will temporarily turn on the microphone to trigger the browser's request for the microphone device permission. On browsers such as Chrome 81+, Firefox, Safari, etc., accurate device information cannot be obtained without media device permissions.
- In Windows Chrome, there will be a microphone device whose deviceID is 'communications'. This microphone is an encapsulation made by Chrome based on a real microphone. The microphone will be limited by Windows' sound communication configuration. Avoid using the device for business purposes.
Scope of influence: None
- Related callbacks: None
Related interfaces: createStream,createZegoStream, useAudioDevice.
- Platform differences: None
Returns audio input device list information.
getSpeakers
getSpeakers(): Promise<ZegoDeviceInfo[]>- Default value: None
- When to call: after initialization, before creating a stream.
Restrictions on use: None
- Due to the browser's security and privacy protection, the page needs to call this interface in a secure environment (https, localhost, 127.0.0.1). See Privacy and security.
- When the page device permission is not granted, calling this method will temporarily turn on the microphone to trigger the browser's speaker device permission request. On browsers such as Chrome 81+, Firefox, Safari, etc., accurate device information cannot be obtained without media device permissions.
- Safari does not support getting speaker information.
Scope of influence: None
- Related callbacks: None
Related interfaces: Specifies the audio output device interface [useAudioOutputDevice].
- Platform differences: None
Returns audio output device list information.
useFrontCamera
useFrontCamera(localStream: MediaStream | ZegoLocalStream, enable: boolean): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| localStream | MediaStream | ZegoLocalStream | The stream created by createStream or the ZegoLocalStream instance object created by createZegoStream. |
| enable | boolean | Whether to use the front camera; "true" means use the front camera; "false" means use the rear camera。 |
- Default value: None
Timing of calling: After the stream is created successfully, and the stream type must be the camera type to collect the stream.
Restrictions on use: None
If the camera switch fails, the original stream will be retained and an error will be returned.
Scope of influence: None
- Related callbacks: None
Related interface: None
- Platform differences: None
useVideoDevice
useVideoDevice(localStream: MediaStream | ZegoLocalStream, deviceID: string): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| localStream | MediaStream | ZegoLocalStream | The stream created by createStream or the ZegoLocalStream instance object created by createZegoStream. |
| deviceID | string | Camera device ID that needs to be switched |
- Default value: None
Timing of calling: After the stream is created successfully, and the stream type must be the camera type to collect the stream.
Restrictions on use: None
If the camera switch fails, the original stream will be retained and an error will be returned.
Scope of influence: None
- Related callbacks: None
Related interface: switch the microphone useAudioDevice.
- Platform differences: None
useAudioDevice
useAudioDevice(localStream: MediaStream | ZegoLocalStream, deviceID: string): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| localStream | MediaStream | ZegoLocalStream | The stream created by createStream or the ZegoLocalStream instance object created by createZegoStream. |
| deviceID | string | The ID of the microphone device that needs to be switched |
- Default value: None
Timing of calling: After the stream is created successfully, and the stream type must be the camera type to collect the stream.
Restrictions on use: None
If you fail to switch the microphone, the original stream will be retained and an error will be returned.
Scope of influence: None
- Related callbacks: None
Related interface: switch the microphone useVideoDevice.
- Platform differences: None
useAudioOutputDevice
useAudioOutputDevice(media: HTMLMediaElement, deviceID: string): Promise<boolean>Parameters
| Name | Type | Description |
|---|---|---|
| media | HTMLMediaElement | Media tag element, <audio> or <video>. |
| deviceID | string | Audio output device ID. |
- When to call: after using [getSpeakers] to get the list of audio output devices.
caution: This interface is currently only supported by the Chrome browser.
Related interface: Get the speaker list interface [getSpeakers].
Return
Promise returns a Boolean ID indicating whether the call was successful.
setSoundLevelDelegate
setSoundLevelDelegate(bool: boolean, interval?: number, options?: SoundLevelDelegateOptions): voidParameters
| Name | Type | Description |
|---|---|---|
| bool | boolean | Turn on or off the sound wave callback |
| interval | number | The time interval to call back, the default is 1000ms, optional |
| options | SoundLevelDelegateOptions | Setting Options. |
- Default value: None
- When to call: After initializing the instance.
Restrictions on use: None
None
Scope of influence: None
Related callback: soundLevelUpdate callback.
Related interface: None
- Platform differences: None
isMicrophoneMuted
isMicrophoneMuted(): booleanGet the microphone mute status.
- Use cases: Used to determine whether the host’s own microphone is turned on.
- When to call /Trigger: After calling loginRoom interface to log in the room successfully
- Related APIs: Call muteMicrophone to turn the microphone sound interface off / on.
- Available since: 2.8.0 and above
muteMicrophone
muteMicrophone(mute: boolean): booleanParameters
| Name | Type | Description |
|---|---|---|
| mute | boolean | Whether to mute the microphone; true means to mute the microphone; false means to turn on the microphone; if not set, the default is false. |
-
When to call: After initializing the instance.
The premise of whether to mute the microphone is that the original stream must have an audio track, and it cannot be pure video when creating the stream.
Related interface: Call isMicrophoneMuted interface to get microphone mute status; Call the mutePublishStreamAudio interface to turn off / on the sound being pushed.
- Platform differences: None
createRangeAudioInstance
createRangeAudioInstance(): ZegoExpressRangeAudioOften used in voice game scenarios, users can use range voice-related functions through the created range voice instance objects.
- Use cases: Often used in shooting games and meta-universe game scenes, users can use the range voice-related functions through the created range voice instance objects.
- When to call /Trigger: Called after creating the ZegoExpressEngine instance and before calling the interface loginRoom to log in to the room.
- Caution: Use range voice function can no longer use startPublishingStream, startPlayingStream these push-pull stream interfaces and related callbacks.
- Available since: 2.10.0
Range Audio Module Instance
createRealTimeSequentialDataManager
createRealTimeSequentialDataManager(roomID: string): ZegoRealTimeSequentialDataManagerParameters
| Name | Type | Description |
|---|---|---|
| roomID | string | room ID |
Details
Create real-time sequential data instance objects.
- Use cases: it is often used in remote control scenarios. Users can use real-time sequential data related functions through the created real-time sequential data instance object.
- When to call /Trigger: call after creating ZegoExpressEngine instance.
- Available since: 2.12.2
Return
Real-time Sequential Data instance object
destroyRealTimeSequentialDataManager
destroyRealTimeSequentialDataManager(manager: ZegoRealTimeSequentialDataManager): voidParameters
| Name | Type | Description |
|---|---|---|
| manager | ZegoRealTimeSequentialDataManager | real-time sequential data object |
Details
Destroy real-time sequential data instance objects.
- Use cases: it is often used in remote control scenarios. Users can use real-time sequential data related functions through the created real-time sequential data instance object.
- When to call /Trigger: call after creating ZegoExpressEngine instance and createRealTimeSequentialDataManager.
- Available since: 2.12.2
createCopyrightedMusic
createCopyrightedMusic(): ZegoCopyrightedMusicCreate a copyright music instance object.
- Use cases: Often used in online KTV chorus scenarios, users can use related functions by creating copyrighted music instance objects.
- When to call /Trigger: After initializing the engine instance.
- Caution: The SDK only supports creating one instance, calling this function multiple times returns the same object.
- Available since: 2.24.5
The media stream player component instance.
destroyCopyrightedMusic
destroyCopyrightedMusic(): voidDestroy a copyright music instance object.
- When to call /Trigger: After initializing the engine instance.
- Available since: 2.24.5
enableMultiRoom
enableMultiRoom(enable: boolean): booleanParameters
| Name | Type | Description |
|---|---|---|
| enable | boolean | Whether to open, true means open, false means closed. |
Details
do you need to open multiple rooms, the same user can join multiple rooms at the same time, push and pull streams, send real-time messages and receive message callbacks in multiple rooms at the same time
- Use cases: super small class scenario for cross room continuous learning and online education
- Default value: multiple rooms mode is not turned on by default
- When to call: you need to call it before you first log in to the room after initializing SDK.
- Related APIs: loginRoom, logoutRoom, startPublishingStream
- Available since: 2.8.0 and above
- Restrictions: It can only be called once in a complete life cycle
setLogConfig
setLogConfig(config: ZegoLogConfig): booleanParameters
| Name | Type | Description |
|---|---|---|
| config | ZegoLogConfig | Log related advanced configuration |
- Default value: Both the local log and upload level are info.
- When to call: After initialization, it is called before any other interfaces.
Usage restriction: None, but it is recommended to call it only once in the entire life cycle.
Unless there is a clear special requirement, please do not call this interface to change the default configuration.
- Related callbacks: None
Related interface: None
Return
Whether the call is successful; failure condition: the input parameter format is wrong
setDebugVerbose
setDebugVerbose(enable: boolean): voidParameters
| Name | Type | Description |
|---|---|---|
| enable | boolean | Whether to open the debug mode; the default SDK will automatically determine |
- Default value: The default value of the test environment is “true”, which can be turned off manually.
- When to call: After initialization, call immediately.
Restrictions on use: None
It is recommended to keep the default behavior and try not to use this interface.
Scope of influence: All SDK internal errors will be prompted by a pop-up, interrupting the entire process.
- Related callbacks: None
Related interface: None
- Platform differences: None
getVersion
getVersion(): string- Default value: None
Call timing: It can be called at any timing after initialization.
Restrictions on use: None
None
Scope of influence: None
- Related callbacks: None
Related interface: None
- Platform differences: None
Is a string, such as "1.0.0. Identification"
loginRoom
loginRoom(roomID: string, token: string, user: ZegoUser, config?: ZegoRoomConfig): Promise<boolean>Parameters
| Name | Type | Description |
|---|---|---|
| roomID | string | Room ID, generated by developer, a string with a maximum length of 128 bytes. Only supports numbers, English characters and'~','!','@','#','$','','^','&','*','(',')', '_','+','=','-',',';',''',',','.','<','>','/'. |
| token | string | The login verification token is obtained by registering the project in the instant console to obtain the key plus the specified algorithm. The testing phase can be bypassed through the instantaneous interface, and the formal environment must be implemented by the user. |
| user | ZegoUser | Login user information. |
| config? | ZegoRoomConfig | Room related configuration,optional. |
Details
Log in to the room and share the stream, message, user and other information changes with the room user.
- Use cases: Log in to the room to obtain interface permissions for audio, video or message interaction with other users.
Calling time: after initialization and token acquisition.
Cautions:
- Token is the key to log in to the room and needs to be implemented by the developer. To ensure security, the token must be generated on the developer's own server.
- The default is single room mode, the same user (ie UserID) cannot log in to two and more rooms at the same time.
- If you want to monitor the changes of other users in the room, the "userUpdate" parameter under the config object must be set to "true".
- If the room does not exist, loginRoom will create and log in the room.
Privacy protection statement: Please do not fill in sensitive user information in this interface, including but not limited to mobile phone number, ID number, passport number, real name, etc.
Scope of influence: Most interfaces can be called after logging in to the room.
Related callback: Room status callback roomstatechanged, please use roomstateupdate before 2.16.0
Related interface: You can call the logoutRoom interface to exit the room.
Return
Promise returns the login result asynchronously, true means login is successful, false means login failed.
switchRoom
switchRoom(fromRoomID: string, toRoomID: string, config: ZegoSwitchRoomConfig): Promise<boolean>Parameters
| Name | Type | Description |
|---|---|---|
| fromRoomID | string | The currently logged in room ID, generated by developer, a string with a maximum length of 128 bytes. Only supports numbers, English characters and'~','!','@','#','$','','^','&','*','(',')', '_','+','=','-',',';',''',',','.','<','>','/'. |
| toRoomID | string | Room ID to be switched (must be an unlogged room ID), generated by developer, a string with a maximum length of 128 bytes. Only supports numbers, English characters and'~','!','@','#','$','','^','&','*','(',')', '_','+','=','-',',';',''',',','.','<','>','/'. |
| config | ZegoSwitchRoomConfig | Room related configuration, token required. |
Details
Switch rooms, quickly switch from the current room to another room..
- Use cases: Convenient to realize the switch between different rooms, such as switching from live room to 1v1 room.
Calling time: After successfully logging into the room.
Cautions:
- Token is the key to log into the toRoomID room, which needs to be implemented by the developer. In order to ensure security, the token must be generated on the developer's own server side.
- fromRoomID must be the logged in room ID, and toRoomID must be the logged in room ID, If the room does not exist, a new room will be created.
- Switching room will stop all push and pull streams in the current room, but will not stop the preview. If you want to stop the preview, you can call destroyStream to destroy the preview stream.
- If CDN manual retweet is set, it will not stop automatically when switching rooms, and the user needs to manually stop CDN retweet.
Privacy protection statement: Please do not fill in sensitive user information in this interface, including but not limited to mobile phone number, ID number, passport number, real name, etc.
Scope of influence: Most interfaces can be called after logging in to the room.
Related callback: Room status callback roomstatechanged, please use roomstateupdate before 2.16.0
Related interface: You can call the logoutRoom interface to exit the room.
Return
Promise returns the login result asynchronously, true means login is successful, false means login failed.
logoutRoom
logoutRoom(roomID?: string): voidParameters
| Name | Type | Description |
|---|---|---|
| roomID? | string | Keep the same as the roomID of the login room, optional |
- Default value: None
Timing of calling: After logging in to the room successfully.
Restrictions on use: None
None
Scope of influence: Most of the interfaces can no longer be called after exiting the room.
Related callback: Room status callback roomstatechanged, please use roomstateupdate before 2.16.0.
Related interface: call loginRoom interface login number room.
- Platform differences: None
renewToken
renewToken(token: string, roomID?: string): booleanParameters
| Name | Type | Description |
|---|---|---|
| token | string | Specify the token generated by the algorithm, that is, the we provides different language versions of the SDK to generate the token; |
| roomID | string | Room ID, a string with a maximum length of 128 bytes. Only supports numbers, English characters and'~','!','@','#','$','','^','&','*','(',')', '_','+','=','-',',';',''',',','.','<','>','/', |
- Default value: none
Calling time: After logging in to the room, actively change the user's permissions in the room; After logging in to the room, the token is about to expire and the callback is received;
Restrictions on use: None
The token is the key to log in to the room. This needs to be implemented by the customer. To ensure security, the token must be generated on the server.
Scope of influence: the expiration time contained in the token, the tokenWillExpire callback will be triggered 30s before the expiration
Related callback: the room token is about to expire, the callback tokenWillExpire
Related interface: none
- Platform differences: None
Return
true: Call succeeded, false: Call failed (SDK Preliminary format verification)
setRoomExtraInfo
setRoomExtraInfo(roomID: string, key: string, value: string): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| roomID | string | room ID |
| key | string | Additional message key |
| value | string | Additional message value |
- Default value: None
Timing of calling: after successfully logging in to the room.
Usage restriction: For the usage restriction of this interface, please refer to https://doc-en.zego.im/article/7616 or contact ZEGO technical support.
At present, only one key-value pair is allowed to be set in the room additional message, and the maximum length of key is 10 bytes, and the maximum length of value is 100 bytes.
Security reminder: Please do not fill in sensitive user information in this interface, including but not limited to mobile phone number, ID number, passport number, real name, etc.
Scope of influence: Most interfaces can be called after logging in to the room.
Related callback: roomExtraInfoUpdate callback for room additional information.
Related interface: None
- Platform differences: None
sendBarrageMessage
sendBarrageMessage(roomID: string, message: string): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| roomID | string | Room ID |
| message | string | Message content, the length does not exceed 1024 bytes |
Details
Send a barrage message to all users in the room corresponding to roomID. The message is not guaranteed to be reliable.
- Use cases: users in the room send barrage messages to interact.
- When to call: After calling the interface loginRoom to log in to the room successfully.
- Related callbacks: Users in the room can receive messages through the room barrage message notification callback IMRecvBarrageMessage.
- Available since: 1.0.0 and above.
- Restrictions: Please refer to the /real-time-video-web/best-practice/restrictions Or contact ZEGO technical support.
Security reminder: Please do not fill in sensitive user information in this interface, including but not limited to mobile phone number, ID number, passport number, real name, etc.
sendBroadcastMessage
sendBroadcastMessage(roomID: string, message: string): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| roomID | string | Room ID. |
| message | string | Message content, the length does not exceed 1024 bytes. |
Details
Send a text message to all users in the room corresponding to roomID.
- Use cases: Users in the room send messages to chat and interact, for example, the chat room.
- When to call: After calling the interface loginRoom to log in to the room successfully.
- Impacts on other APIs: Most interfaces can be called after logging in to the room.
Related callback: Users in other rooms can receive messages through the broadcast message notification callback IMRecvBroadcastMessage.
- Available since: 1.0.0 and above.
- Restrictions: For restrictions on the use of this interface, please refer to /real-time-video-web/best-practice/restrictions or contact ZEGO technical support.
Security reminder: Please do not fill in sensitive user information in this interface, including but not limited to mobile phone number, ID number, passport number, real name, etc.
sendCustomCommand
sendCustomCommand(roomID: string, message: string, toUserIDList: string[]): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| roomID | string | Room ID. |
| message | string | Custom message content, the length does not exceed 1024 bytes. |
| toUserIDList | string[] | Target user uerId array. Passing in an empty array means it is sent to all users in the room. |
Details
Send a custom message to the designated user in the room corresponding to roomID, and the message is guaranteed to be reliable.
- Use cases: Chat with individual users privately.
- When to call: after successfully logging in to the room.
- Impacts on other APIs: Most interfaces can be called after logging in to the room.
- Related callbacks: Users in the room can receive messages by listening to the custom command signaling callback IMRecvCustomCommand.
- Available since: 1.0.0 and above.
- Restrictions: For restrictions on the use of this interface, please refer to /real-time-video-web/best-practice/restrictions or contact ZEGO technical support.
Security reminder: Please do not fill in sensitive user information in this interface, including but not limited to mobile phone number, ID number, passport number, real name, etc.
sendTransparentMessage
sendTransparentMessage(roomID: string, message: ZegoRoomSendTransparentMessage): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| roomID | string | Room ID. |
| message | ZegoRoomSendTransparentMessage | ZegoRoomSendTransparentMessage |
Details
Send point-to-point signaling to other users who have logged into the same room.
- Use cases: Generally used for remote control signaling or message sending between users.
- When to call: after successfully logging in to the room.
- Impacts on other APIs: Most interfaces can be called after logging in to the room.
- Related callbacks: When sending a message, Mode is specified for ZegoRoomTransparentMessageModeOnlyClient or ZegoRoomTransparentMessageModeClientAndServer can pass [recvRoomTransparentMessage] received sends the message content.
- Available since: 3.11.0 and above.
- Restrictions: The frequency of sending barrage messages in the same room cannot be higher than 20 messages/s. For restrictions on the use of this function, please contact ZEGO technical support.
Security reminder: Please do not fill in sensitive user information in this interface, including but not limited to mobile phone number, ID number, passport number, real name, etc.
ZegoExpressPlayer
Zego Web Express SDK Player Plug-in
Details
Detailed description: Web player plug-in, used to playing live CDN streams.
Business scenario: playing CDN streams for live streaming.
Properties
played
played: boolean Read-only, Player playback status. If true, it means the CDN resource is being played.
paused
paused: boolean Read-only, player paused status, true means the player is not currently rendering CDN resources.
volume
volume: number Read-only, the volume currently set by the player. The value range is [0,100] and can be modified through the [setVolume] interface.
currentTime
currentTime: number read only, The current playback time, that is, the pts value of the current rendering frame, is accurate to the last two decimal places, and the unit is seconds. Use event callback [onTimeUpdate] to monitor changes in playback time.
muted
muted: boolean Read-only, whether the current playback status is muted. If true, it means the player is muted.
mediainfo
mediainfo: MediaInfo Read-only, currently playing media resource information, changes to this attribute can be learned by listening to the callback [onMediaInfoUpdate].
src
src: string -
Use cases:
-
Required:
-
Default value:
-
Recommended value:
-
Value range:
-
Caution:
-
Privacy reminder:
-
Platform differences:
Methods
ZegoExpressPlayer
ZegoExpressPlayer(engine: ZegoExpressEngine, config: ZegoExpressPlayerConfig): ZegoExpressPlayerParameters
| Name | Type | Description |
|---|---|---|
| engine | ZegoExpressEngine | Engine instance object for Zego Web Express SDK |
| config | ZegoExpressPlayerConfig | Initial configuration of player plug-in |
Details
Instantiate the player plug-in.
- Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.
Return
Player instance
verify
verify(token: string, userID: string): Promise<boolean>Parameters
| Name | Type | Description |
|---|---|---|
| token | string | Enter the token, which is consistent with the token generation method for room login. |
| userID | string | The user userID is consistent with the userID that generated the token and is used for player authentication. |
Details
Player authentication
- Use cases: After initializing the player plug-in, if the SDK does not log in to the room, the player plug-in needs to be authenticated.
- When to call /Trigger: Called after the player is instantiated and before other interfaces are used.
- Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.
Return
Authentication result, if the return result is true, it means the authentication is successful, if it is false, it means the authentication fails.
play
play(): voidStart playing CDN resources.
- Use cases: After the player initializes and specifies the CDN resource, it starts playing the CDN resource.
- When to call /Trigger: Called after the player is instantiated and authenticated.
- Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.
pause
pause(): voidPause CDN resource playback.
- Use cases: When playing CDN resources, pause the playback.
- Caution: When pausing playback, in order to synchronize with the latest CDN live broadcast progress as much as possible, the player will drop frames during the pause process.
- When to call /Trigger: Called after the player starts pulling CDN resources.
- Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.
resume
resume(): voidThe player re-pulls the current CDN live stream.
- Use cases: Such as CDN resource exceptions and other scenarios, used when CDN resources need to be re-pulled.
- When to call /Trigger: Called after the player pulls CDN resources.
- Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.
stop
stop(): voidStop playing CDN resources.
- Use cases: After the player starts playing CDN resources, it stops playing the resources.
- When to call /Trigger: Called after the player is instantiated and authenticated.
- Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.
fullScreen
fullScreen(): voidThe player plays in full screen.
- Use cases: The player plays CDN resources in full screen.
- When to call /Trigger: Called after the player starts pulling CDN resources.
- Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.
destroy
destroy(): voidDestroy the player and release the memory and CPU resources occupied by the player.
- Use cases: At the end of the player life cycle, when the player is no longer needed to play media resources, the player instance needs to be consumed.
- When to call /Trigger: Called after the player is instantiated.
- Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.
setVolume
setVolume(): voidSet the volume of the player, the value range is [0, 100].
- Use cases: The player sets the volume of the current playing resource.
- When to call /Trigger: Called after player instantiation and authentication.
- Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.
getPlayQuality
getPlayQuality(): QualityStatsThe player plays in full screen.
- Use cases: The player plays CDN resources in full screen.
- When to call /Trigger: Called after the player starts pulling CDN resources.
- Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.
setMuted
setMuted(mute: boolean): voidParameters
| Name | Type | Description |
|---|---|---|
| mute | boolean | Set the mute status. When the value is true, it means turning on muting. When it is false, it means turning off muting. |
Details
Set the volume of the player, the value range is [0, 100].
- Use cases: The player sets the volume of the current playing resource.
- When to call /Trigger: Called after player instantiation and authentication.
- Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.
setBufferInterval
setBufferInterval(intervals: BufferIntervals): voidParameters
| Name | Type | Description |
|---|---|---|
| intervals | BufferIntervals | buffer intervals |
Details
set buffer interval.
- When to call /Trigger: Called after the player starts pulling CDN resources.
- Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.
enableSoundLevelMonitor
enableSoundLevelMonitor(enable: boolean, millisecond?: number, options?: SoundLevelDelegateOptions): voidParameters
| Name | Type | Description |
|---|---|---|
| enable | boolean | Turn on or off the sound wave callback |
| millisecond | number | The time interval to call back, the default is 1000ms, optional |
| options | SoundLevelDelegateOptions | Setting Options. |
- Default value: None
- When to call: After initializing the instance.
Restrictions on use: Using MSE (Media Source Extensions) decoding method to play audio on Safari browser cannot obtain sound waves. If you need to obtain sound waves, avoid using MSE decoding method on Safari browser.
None
Scope of influence: None
Related callback: onSoundLevelUpdate callback.
Related interface: None
- Platform differences: None
onCanPlay
onCanPlay(): voidThe resource metadata has been parsed and the media file can be played. You can cancel rendering of the Loading control in this callback to prompt the user that the video can start playing.
- Use cases: You can listen to this callback to prompt the user that the current CDN resource can start playing.
- When to call /Trigger: Called after the player sets the CDN resource.
- Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.
onPlay
onPlay(): voidThe callback when the player starts playing CDN resources. When this callback is triggered, it means that the player has started rendering audio and video resources.
- Use cases: You can listen to this callback to determine whether the CDN resource has started rendering, and make related UI changes, such as removing video masks, etc.
- When to call /Trigger: Called after the player sets the CDN resource.
- Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.
onPaused
onPaused(): voidThe player pauses the callback of rendering CDN resources. When this callback is triggered, it means that the player pauses the rendering of audio and video resources.
- Use cases: You can listen to this callback to determine whether the CDN resource has started rendering, and make related UI changes, such as turning on the video mask or rendering the play button.
- When to call /Trigger: Called after the player sets the CDN resource.
- Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.
onLoaded
onLoaded(): voidThis callback will be triggered when the player ends loading to the CDN media resource.
- Use cases: Use this callback to determine whether the CDN resource has been loaded.
- When to call /Trigger: Called after the player sets the CDN resource.
- Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.
onTimeUpdate
onTimeUpdate(): voidThe current playback time, that is, this callback is triggered when the pts of the current rendering frame changes. The trigger frequency is up to 0.01s. The actual trigger frequency is affected by the frame rate, sampling rate and other factors of the CDN media resource.
- Use cases: You can listen to this callback to obtain the playback progress of the current live broadcast resource.
- When to call /Trigger: Called after the player sets the CDN resource.
- Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.
onWaiting
onWaiting(): voidThe player pauses rendering due to lack of CDN media data, waiting for enough data to be loaded. For related callbacks, please refer to [onPlaying].
- Use cases: You can render UI interfaces such as the Loading control in this callback to prompt the user that the video is loading.
- When to call /Trigger: Called after the player sets the CDN resource.
- Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.
onPlaying
onPlaying(): voidPlayer loads enough data and starts to resume playback. Usually after [onWaiting] is triggered, when the player buffers enough data, it unbuffers and resumes playback. If the player has been paused at this time, rendering will not automatically resume.
- Use cases: You can render UI interfaces such as the Loading control in this callback to prompt the user that the video is loading.
- When to call /Trigger: Called after the player sets the CDN resource.
- Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.
onError
onError(err: ZegoExpressPlayerError): voidParameters
| Name | Type | Description |
|---|---|---|
| err | ZegoExpressPlayerError | Error codes and error messages |
Details
When the player triggers an error, it will call back the error code and error information.
- Use cases: You can listen to this callback and perform related business processing when the player triggers an error.
- When to call /Trigger: Called after the player is initialized and authenticated.
- Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.
onMediaInfoUpdate
onMediaInfoUpdate(mediaInfo: MediaInfo): voidParameters
| Name | Type | Description |
|---|---|---|
| mediaInfo | MediaInfo | Media information of CDN resources parsed by the player |
Details
The CDN resource media information update callback parsed by the player. As the media data in the CDN resource is gradually parsed, this callback may be triggered multiple times.
- Use cases: You can listen to this callback to record relevant media information data and perform related business operations.
- When to call /Trigger: Called after the player starts playing CDN resources.
- Available since: Player plug-in version 1.0.0 and above depends on Express SDK 3.0.0 and above.
onResetPlayQuality
onResetPlayQuality(quality: QualityStats): voidParameters
| Name | Type | Description |
|---|---|---|
| quality | QualityStats | The streaming quality statistics of the player |
Details
This callback is triggered when the player resets the streaming quality statistics and throws the last streaming quality statistics.
- Use cases: You can listen for this callback to get accurate streaming quality statistics before the player reset. Resetting stream quality statistics is triggered when resources are reloaded (e.g., setting src, calling resume).
- When to call: After the player is instanced.
- Available since: Player plug-in version 1.3.1 and above, rely on Express SDK version 3.0.0 and above.
onRecvSEI
onRecvSEI(byte: Uint8Array): voidParameters
| Name | Type | Description |
|---|---|---|
| byte | Uint8Array | SEI data |
Details
This callback is triggered when the player receives SEI data.
- Use cases: You can listen for the callback to get the SEI data for the video.
- When to call: After the player is instanced.
- Available since: Player plug-in version 1.3.0 and above, rely on Express SDK version 3.0.0 and above.
onSoundLevelUpdate
onSoundLevelUpdate(soundLevel: number): voidParameters
| Name | Type | Description |
|---|---|---|
| soundLevel | number | The locally collected sound wave values range from 0.0 to 100.0. |
Details
By enabling SoundLevelMonitor to retrieve sound waves, this callback will be triggered when playing sound.
- Use cases: You can listen to this callback to obtain real-time playback of sound waves.
- When to call: After instantiating the player.
- Available since: Player plugin version 1.5.0 and above.
ZegoExpressRangeAudio
Range Audio
Details
Detailed description: Often used in chicken-eating games and meta-universe game scenarios, users can use the range voice-related functions through the created range voice instance objects.
Methods
getInstance
getInstance(engine: any, logger: any): ZegoExpressRangeAudio| Name | Type | Description |
|---|---|---|
| engine | any | - |
| logger | any |
setVoiceChangerParam
web setVoiceChangerParam(voiceParam: number): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| voiceParam | number | Voice change custom parameter value.The value range is [-12.0, 12.0]. The larger the value, the sharper the sound. Setting it to 0.0 will turn off the voice changer. |
Details
Perform voice change processing on pushed media streams with custom parameter settings.
- Use cases: Switch voice changer reduction before or during streaming.
- Default value: None
- Currently only supports voice changer reduction for a specific stream, and does not support simultaneous noise reduction for multiple streams;
- Available since: 3.0.0
setVoiceChangerPreset
web setVoiceChangerPreset(preset: ZegoVoiceChangerPreset): Promise<ZegoServerResponse>Parameters
| Name | Type | Description |
|---|---|---|
| preset | ZegoVoiceChangerPreset | Preset value for changing sound |
Details
Perform voice changer reduction processing on the pushed media stream.
- Use cases: Switch voice changer reduction before or during streaming.
- Default value: None
- When to call /Trigger: After calling the interface createStream to create a stream successfully.
- Currently only supports voice changer reduction for a specific stream, and does not support simultaneous noise reduction for multiple streams;
- Available since: 2.24.0
enableAudioSourceUpdateChecker
enableAudioSourceUpdateChecker(update: boolean, config?: ZegoRangeAudioUserUpdateCheckConfig): voidParameters
| Name | Type | Description |
|---|---|---|
| update | boolean | whether to check. |
| config? | ZegoRangeAudioUserUpdateCheckConfig | Check for in range user change configuration |
Details
Whether to check for changes to users in range.
- When to call /Trigger: After calling interface createRangeAudioInstance to create ZegoExpressRangeAudio instance.
- Related callbacks: audioSourceWithinRangeUpdate.
- Available since: 2.22.0
on
on<K extends keyof ZegoRangeAudioEvent >(event: K, callBack: ZegoRangeAudioEvent[K]): booleanParameters
| Name | Type | Description |
|---|---|---|
| event | K | Listener event name. |
| callBack | ZegoRangeAudioEvent[K] | Callback. |
Details
The interface used to handle the SDK's initiative to notify developers of callbacks. By registering different events, you can receive callbacks of different functions. The event callback that can be monitored can be viewed in ZegoRangeAudioEvent.
Use case: Used to register the callback processing of business events related to the range audio function.
Timing of calling: After calling the interface createRangeAudioInstance to create the instance and before calling the interface loginRoom to log in to the room.
The same event can be registered multiple, the same registered event will be triggered in sequence according to the order of registration.
Related interface: call interface off to cancel the corresponding callback event processing.
Return
Whether the registration is successful.
off
off<K extends keyof ZegoRangeAudioEvent >(event: K, callBack?: ZegoRangeAudioEvent[K]): booleanParameters
| Name | Type | Description |
|---|---|---|
| event | K | Listener event name. |
| callBack | ZegoRangeAudioEvent[K] | Callback. |
Details
The interface used to handle the SDK's initiative to notify developers of callbacks. By registering different events, you can receive callbacks of different functions. Used to delete the registered callback event of the same type.
Use case: It is used for callback processing of business events related to logoff range voice function.
call timing: after calling the interface createrangeaudioinstance to create an instance.
- Caution: if there is no callback method to log off, all callbacks of this event will be logged off.
Return
Whether the unregister was successful.
setAudioReceiveRange
setAudioReceiveRange(range: number): voidParameters
| Name | Type | Description |
|---|---|---|
| range | number | Audio range, the value must be greater than or equal to 0. |
Details
Set the maximum distance range of the audio reception, the sound source sound exceeding the range will be undesirable, and the situation that is not set is default the unlimited range.
- Use cases: Set the hearing range of the listener in the range voice.
- Default value: Not set, the default is unlimited, that is, hears the sound of everyone in the room.
- Caution: This range only applies to speakers from different teams.
- When to call /Trigger: Call Interface CreateRangeAudioInStance Create a ZegoExpressRangeAudio instance.
- Available since: 2.10.0
updateSelfPosition
updateSelfPosition(position: number[], axisForward: number[], axisRight: number[], axisUp: number[]): voidParameters
| Name | Type | Description |
|---|---|---|
| position | number[] | The coordinates of themselves in the world coordinate system, the parameter is the number array of length 3, and the three values represent the front, right, and coordinate values. |
| axisForward | number[] | The unit vector of the forward axis of its own coordinate system. The parameter is the number array of length 3, and the three values represent the front, right, and coordinate values. |
| axisRight | number[] | The unit vector of the right axis of the own coordinate system. The parameter is the number array of length 3, and the three values represent the front, right, and coordinate values. |
| axisUp | number[] | The unit vector of the up axis in its own coordinate system. The parameter is the number array of length 3, and the three values represent the front, right, and coordinate values. |
Details
Its own position and orientation, so that the SDK can calculate the distance between the user and the audio source and the stereo effect of the left and right ears.
- Use cases: When the character operated by the user in the game moves on the world map, the position information and head orientation of the character are updated.
- Caution: If you don't call updateSelfPosition to set the position information before calling enableSpeaker to turn on the speakers, you can't receive voices from people other than the squad.
- When to call /Trigger: After creating a ZEGOEXPRESSRANGEAUDIO instance, call the interface EnableSpeaker before.
- Available since: 2.10.0
updateAudioSource
updateAudioSource(userID: string, position: number[]): voidParameters
| Name | Type | Description |
|---|---|---|
| userID | string | Speaker user ID. |
| position | number[] | The coordinator in the world coordinate system is the number array of length 3, and the three values represent the front, right, and coordinate values. |
Details
Set the position of the audio source corresponding to the userID on the world map so that the SDK can calculate the distance and orientation of the listener to the audio source.
- Use cases: Update the position of the voice user in the game map coordinates.
- When to call /Trigger: Called after logging in to the room, the recorded audio source information will be cleared after logging out of the room.
- Available since: 2.10.0
enableSpatializer
enableSpatializer(enable: boolean): voidParameters
| Name | Type | Description |
|---|---|---|
| enable | boolean | Whether to enable, the default value is true |
Details
After the 3D sound effect is turned on, the sound effect in the actual space will be simulated according to the position of the speaker equivalent to the listener. You can intuitively feel the change in the sound volume and the difference between the left and right sound when the distance and orientation of the sound source change. When enable is true, 3D sound is turned on. When false, 3D sound is turned off.
- Use cases: Voice recognition function in first-person shooter games or social scene games.
- Default value: Before calling this interface, the default is to turn off 3D sound effects.
Use restrictions: The 3D sound effect only works on the sound of others other than the squad.
- When to call /Trigger: After calling the interface createRangeAudioInstance to initialize the instance.
Related interface: After turning on the 3D sound effect, you can call updateSelfPositon and updateAudioSource to update the position and orientation to change the stereo effect.
- Available since: 2.10.0
enableMicrophone
enableMicrophone(enable: boolean): voidParameters
| Name | Type | Description |
|---|---|---|
| enable | boolean | Whether to enable, the default value is true |
Details
When enable is true, turn on the microphone and push audio stream, when it is false, turn off the microphone and stop pushing audio stream.
- Use cases: The user turns on or off the microphone to communicate in the room.
- Default value: Before calling the interface, the microphone is turned off by default.
- When to call /Trigger: Call the interface createRangeAudioInstance to create an instance and call the interface loginRoom after successfully logging in to the room.
Related callback: get the change of microphone switch state by callback microphoneStateUpdate.
- Available since: 2.10.0
selectMicrophone
selectMicrophone(deviceID: string): Promise<boolean>Parameters
| Name | Type | Description |
|---|---|---|
| deviceID | string | Microphone device ID. |
Details
Specify the device used to turn on the microphone by passing in the deviceID of the microphone device. The deviceID can be obtained through the [ZegoExpressEngine.getMicrophones] interface.
- Use cases: Switch the microphone device used.
- Default value: Before calling the interface, the microphone device specified by the system is used by default.
- When to call /Trigger: After calling the interface createRangeAudioInstance to create an instance.
Related interface: Get the microphone device list interface [getMicrophones] .
- Available since: 2.17.0
Return
Asynchronously returns a boolean value indicating whether the switching device was successful.
selectSpeaker
selectSpeaker(deviceID: string): voidParameters
| Name | Type | Description |
|---|---|---|
| deviceID | string | Speaker device ID. |
Details
Specify the device used for range voice playback audio by passing in the deviceID of the speaker device. The deviceID can be obtained through the ZegoExpressEngine.getMicrophones interface.
- Use cases: Speaker device used by range voice switching.
- Default value: Before calling the interface, the speaker device specified by the system is used by default.
- Caution: This interface is currently only supported by the Chrome browser.
- When to call /Trigger: After calling the interface createRangeAudioInstance to create an instance.
Related interface: Get the microphone device list interface getSpeakers.
- Available since: 2.19.0
enableSpeaker
enableSpeaker(enable: boolean): voidParameters
| Name | Type | Description |
|---|---|---|
| enable | boolean | Whether to enable, the default value is true |
Details
When enable is true, it starts to pull and play the audio stream that can be pulled, and when it is false, it stops pulling and playing the audio stream.
- Use cases: The user chooses whether to receive other people's voices.
- Default value: Before calling the interface, the default is to turn off receiving audio.
- When to call /Trigger: Call interface createrangeaudioinstance to create an instance and interface loginroom to log in to the room successfully.
- Available since: 2.10.0
setRangeAudioCustomMode
setRangeAudioCustomMode(speakMode: ZegoRangeAudioSpeakMode, listenMode: ZegoRangeAudioListenMode): voidParameters
| Name | Type | Description |
|---|---|---|
| speakMode | ZegoRangeAudioSpeakMode | Range voice mode, mode is 0 means listen to everyone, 1 means only within the range, and 2 means only in range. |
| listenMode | ZegoRangeAudioListenMode | Range voice listening mode, mode is 0 means listen to everyone, 1 means only within range, and 2 means only in range. |
Details
Voice Mode and Listen Mode can be set separately to control voice and listen behavior in worlds and squads.
- Use cases: The user can decide who can listen to his voice by selecting the voice mode, and can also decide whose voice to listen to by selecting the listening mode.
- Default value: When this interface is not called, the "speak to all" mode and the "listen to all" mode are used by default, that is, the "world" mode.
- When to call /Trigger: After initializing the instance through createRangeAudioInstance.
- Related APIs: When you want to listen to the sound from the world, you need to set the sound receiving range [setAudioReceiveRange]. When you want to speak and listen in the team, you need to set [setTeamID] to join the corresponding team.
- Available since: 2.24.0
- Restrictions:
- Cannot be used with [setRangeAudioMode].
- Incompatible with versions before 2.24.0.
setRangeAudioMode
setRangeAudioMode(mode: ZegoRangeAudioMode): voidParameters
| Name | Type | Description |
|---|---|---|
| mode | ZegoRangeAudioMode | Listening mode: if the mode is 0, it means everyone is listening, and if it is 1, it means only the team |
Details
Set the listening mode, which can be set to "Everyone" mode or "Team only" mode.
- Use cases: Users want to communicate only within the squad or with everyone in the room.
- Default value: When the interface settings are not adjusted, the default is "World Mode", and you can communicate with everyone.
- When to call /Trigger: After initializing the instance through createRangeAudioInstance.
- Related APIs: You need to adjust the interface setTeamID to join the corresponding team to hear the voice in the team.
- Available since: 2.10.0
setTeamID
setTeamID(teamID?: string): voidParameters
| Name | Type | Description |
|---|---|---|
| teamID | string | Team ID, String of maximum length of 64 bytes. |
Details
After setting the team ID, you will be able to communicate with other users in the same team in the room, and the sound will not change with the distance.
- Use cases: The user wants to join the team to communicate or exit the team.
- Default value: The default value is undefined, which means not to join the team.
- When to call /Trigger: After initializing the instance through createRangeAudioInstance.
- Caution: The maximum length of the parameter TeamID is 64 bytes.
- Related APIs: When the interface setRangeAudioMode is set to team mode, only the team can communicate.
- Available since: 2.10.0
setPositionUpdateFrequency
setPositionUpdateFrequency(frequency: number): voidParameters
| Name | Type | Description |
|---|---|---|
| frequency | number | Update frequency, the value must be greater than 15ms. |
Details
Set the frequency of real-time location update within the SDK. Minimum 15 ms.
- Use cases: After updating the position, the audio fade sensitivity is very demanding.
- Default value: The default is 100 ms.
- When to call /Trigger: After initializing the instance via createRangeAudioInstance.
- Available since: 2.19.0
setRangeAudioVolume
setRangeAudioVolume(volume: number): voidParameters
| Name | Type | Description |
|---|---|---|
| volume | number | Volume level, the value range is [0,200] . |
Details
Sets the local playback volume of the range voice.
- Default value: 100.
- When to call /Trigger: After calling interface createRangeAudioInstance to create ZegoExpressRangeAudio instance.
- Available since: 2.19.0
enableAiDenoise
enableAiDenoise(enable: boolean): booleanParameters
| Name | Type | Description |
|---|---|---|
| enable | boolean | Turn on/off AI noise reduction |
Details
Perform AI noise reduction processing on the microphone sound.
- Use cases: Switch AI noise reduction before or during streaming.
- Default value: None
- When to call /Trigger: After calling the interface createStream to create a stream successfully.
- Currently using the AI noise reduction function requires a special editing package for technical support;
- Currently only supports the use of the PC terminal, the mobile terminal is not currently supported;
- Available since: Special packaged version.
Return
Identifies whether the interface call is successful. The reason for the failure may be that the browser does not support or does not use a special package.
isAudioContextRunning
isAudioContextRunning(): booleanThis interface is mainly to deal with the browser's compatibility with the auto-play strategy. Detect whether the current AudioContext object is enabled through the interface isAudioContextRunning. If it is not enabled, it will not support automatic sound playback.
- When to call /Trigger: After calling createRangeAudioInstance to create the instance.
- Related APIs: If the AudioContext object is not enabled, you can re-enable the AudioContext object through the resumeAudioContext interface.
- Available since: 2.10.0
Is the AudioContext enabled
resumeAudioContext
resumeAudioContext(): Promise<boolean>This interface is mainly to deal with the browser's compatibility with the auto-play strategy. It is detected through the interface isAudioContextRunning that the current AudioContext object is not enabled, and it can be re-enabled through this interface.
- When to call /Trigger: After calling createRangeAudioInstance to create the instance.
- Caution: This interface must be called in the JS click event to take effect.
- Related APIs: Detect that the current AudioContext object is not enabled through the interface isAudioContextRunning.
- Available since: 2.10.0
Whether the resume is successful
setStreamVocalRange
setStreamVocalRange(view: ZegoStreamView, range: number): voidParameters
| Name | Type | Description |
|---|---|---|
| view | ZegoStreamView | Pull stream playback component. |
| range | number | Audio range, the value must be greater than or equal to 0. |
Details
Set the maximum distance range for audio transmission, and the audio source sound beyond this range will not be heard.
- Use cases: Set the voice range of the streaming sound source in Range Voice.
- Default value: Default is 0.
- When to call /Trigger: Call Interface CreateRangeAudioInStance Create a ZegoExpressRangeAudio instance.
- Available since: 2.20.2
updateStreamPosition
updateStreamPosition(view: ZegoStreamView, position: number[]): voidParameters
| Name | Type | Description |
|---|---|---|
| view | ZegoStreamView | The source of the sound is the ZegoStreamView that plays the RTC pull stream. |
| position | number[] | The coordinator in the world coordinate system is the number array of length 3, and the three values represent the front, right, and coordinate values. |
Details
Set the position of the sound source corresponding to the streaming sound source on the world map so that the SDK can calculate the distance and orientation between the listener and the sound source.
- Use cases: Updates the position of the custom sound source in game map coordinates.
- When to call /Trigger: Called after logging in to the room, the recorded audio source information will be cleared after logging out of the room.
- Available since: 2.21.0
setCustomSourceVocalRange
setCustomSourceVocalRange(media: HTMLMediaElement, range: number): voidParameters
| Name | Type | Description |
|---|---|---|
| media | HTMLMediaElement | <video> or <audio> tag object. |
| range | number | Audio range, the value must be greater than or equal to 0. |
Details
Set the maximum distance range for audio transmission, the audio source sound beyond this range will not be heard, the default is 0.
- Use cases: Set the sound range of the custom sound source in Range Speech.
- Default value: Default is 0.
- When to call /Trigger: Call Interface CreateRangeAudioInStance Create a ZegoExpressRangeAudio instance.
- Available since: 2.20.2
updateCustomSourcePosition
updateCustomSourcePosition(media: HTMLMediaElement, position: number[]): voidParameters
| Name | Type | Description |
|---|---|---|
| media | HTMLMediaElement | The sound source can be passed to play a local or online audio file <video> or <audio> tag object. |
| position | number[] | The coordinator in the world coordinate system is the number array of length 3, and the three values represent the front, right, and coordinate values. |
Details
Set the position of the sound source corresponding to the custom sound source on the world map so that the SDK can calculate the distance and orientation between the listener and the sound source.
- Use cases: Updates the position of the custom sound source in game map coordinates.
- When to call /Trigger: Called after logging in to the room, the recorded audio source information will be cleared after logging out of the room.
- Available since: 2.21.0
ZegoLocalStream
zego local stream
Details
By calling createZegoStream can generate a ZegoLocalStream instance, ZegoLocalStream integrated audio and video collection, playback API.
- Use cases: Create a local stream for previewing and pushing streams.
Methods
playAudio
playAudio(options?: ZegoLocalAduioOptions): voidParameters
| Name | Type | Description |
|---|---|---|
| options | ZegoLocalAduioOptions | Set playback options parameters. |
Details
The SDK will create a media stream as needed to play the audio of the media stream that is being pushed or is being pushed.Before calling [startPublishingStream] to push the stream, the media playback content will be synchronized with the newly captured audio; After the successful push stream, ZegoLocalStream calls the capture microphone, screen share or third-party audio source again. The newly captured audio will not be updated synchronously to the audio being pushed. If it needs to be updated, it needs to call [updatePublishingStream] to update.
- Use cases: Plays the audio of a media stream that is to be pushed or is being pushed.
- When to call: After creating a ZegoLocalStream instance, and the stream is captured.
- Related callbacks: When calling the [playAudio] interface to play a video failed, the automatic playback failure event callback [autoplayFailed]of ZegoLocalStream will be triggered.
- Related APIs: Uninstall media streaming component interface [stopAudio] . Calling [destroyStream] also unloads the playback component.
- Available since: 3.0.0
playCaptureAudio
playCaptureAudio(options?: ZegoLocalAduioOptions): voidParameters
| Name | Type | Description |
|---|---|---|
| options | ZegoLocalAduioOptions | Set playback options parameters. |
Details
The SDK will create a media stream to play the latest captured media stream audio as needed.
- Use cases: Plays the latest media stream audio that is being captured.
- When to call: After creating a ZegoLocalStream instance, and the audio stream is captured.
- Related callbacks: When calling the [playCaptureAudio] interface to play a video failed, the automatic playback failure event callback [autoplayCaptureFailed]of ZegoLocalStream will be triggered.
- Related APIs: Uninstall media streaming component interface [stopPlayCaptureAudio] . Calling [destroyStream] also unloads the playback component.
- Available since: 3.0.0
playCaptureVideo
playCaptureVideo(container: HTMLElement, options?: ZegoLocalViewOptions): voidParameters
| Name | Type | Description |
|---|---|---|
| container | HTMLElement | Specify a container tag DOM element, such as div. The SDK will create a <video> element under this element to play the video track. |
| options | ZegoLocalViewOptions | Set playback options parameters (mirror, display mode, etc.). |
Details
Specify a DOM element as a container, and the SDK will create media under the element as needed to play a video of the latest captured media stream.
- Use cases: The latest media streams that are being collected are displayed on the screen.
- When to call: Run the [createZegoStream] command to create the ZegoLocalStream instance and start capturing video streams.
- Caution: A ZegoLocalStream instance where the [createZegoStream] configuration parameter [multiplacePreview] defaults to false. If [multiplacePreview] is false, it can only be mounted to a container using the [playCaptureVideo] method, and cannot be mounted multiple times. When [multiplacePreview] is true, calling [playCaptureVideo] once will perform a mount.
- Related callbacks: When the [playCaptureVideo] interface fails toplay a video, ZegoLocalStream's Autoplay failure event callback is triggered. [autoplayCaptureFailed].
- Related APIs: Stop media stream playback interface [stopPlayCaptureVideo], [stopPlayCaptureVideo] will uninstall all the playback components that play the latest collection stream. Calling [destroyStream] also uninstalls the player component.
- Available since: 3.0.0
playVideo
playVideo(container: HTMLElement, options?: ZegoLocalViewOptions): voidParameters
| Name | Type | Description |
|---|---|---|
| container | HTMLElement | Specify a container tag DOM element, such as div. The SDK will create a<video>element under this element to play video tracks. |
| options | ZegoLocalViewOptions | Set playback options parameters (mirror, display mode, etc.). |
Details
Specify a DOM element as a container, and the SDK will create a media stream under the element to play the video of the media stream to be pushed or already pushed, as needed.Before calling [startPublishingStream] to push stream, the media playback content will be synchronized with the latest video content captured at present; After the successful push, ZegoLocalStream calls the capture camera, screen sharing or third-party video source again, and the newly captured video will not be updated synchronously to the video source being pushed. If it needs to be updated, it needs to call [updatePublishingStream] to update.
- Use cases: Display media stream content on the interface.
- When to call: After creating a ZegoLocalStream instance, and the stream is captured.
- Caution: A ZegoLocalStream playback component can only be mounted on one container through the [playVideo] method, and cannot be mounted on multiple ones at the same time.
- Related callbacks: When calling the [playVideo] interface to play a video failed, the automatic playback failure event callback [autoplayFailed]of ZegoLocalStream will be triggered.
- Related APIs: Uninstall media streaming component interface [stopVideo] . Calling [destroyStream] also unloads the playback component.
- Available since: 3.0.0
stopAudio
stopAudio(): voidStop playing the audio in the stream to be pushed or being pushed.
- Use cases: Stop playing the audio in the stream to be pushed or being pushed.
- When to call: The ZegoLocalStream instance has been created with [createZegoStream] and the stream has been collected and [playAudio] has been executed.
- Related APIs: Calling [destroyStream] unmount the playback component.
- Available since: 2.17.0
stopCaptureAudio
stopCaptureAudio(): Promise<boolean>Stop capturing audio and destroy the playback component that is previewing the audio. If it is in a push stream, the audio capture of the preview stream will not stop until the audio in the push stream is stopped and captured successfully. Otherwise, stopping the audio capture fails.
- Use cases: Stop capturing audio.
- When to call: The ZegoLocalStream instance has been created with [createZegoStream].
- Available since: 3.0.0
stopCaptureVideo
stopCaptureVideo(): Promise<boolean>Stop capturing video and destroy the playback component that is previewing the video. If it is in a push stream, the video capture of the preview stream will not stop until the video in the push stream is stopped and captured successfully. Otherwise, stopping the video capture fails..
- Use cases: Stop capturing video.
- When to call: The ZegoLocalStream instance has been created with [createZegoStream] and the stream has been collected and [playVideo] has been executed.
- Related APIs: Calling [destroyStream] unmount the playback component.
- Available since: 3.0.0
stopPlayCaptureAudio
stopPlayCaptureAudio(): voidStop playing the audio of the latest captured media stream.
- Use cases: Stop playing the audio of the latest captured media stream.
- When to call: The ZegoLocalStream instance has been created with [createZegoStream] and the stream has been collected and [playCaptureAudio] has been executed.
- Related APIs: Calling [destroyStream] also unmount the playback component.
- Available since: 3.0.0
stopPlayCaptureVideo
stopPlayCaptureVideo(): voidStop the page from playing all the latest streaming videos that are being captured.
- Use cases: The latest media streams that are being collected are not displayed on the screen.
- When to call: The ZegoLocalStream instance has been created with [createZegoStream] and the stream has been collected and [playCaptureVideo] has been executed.
- Related APIs: Calling [destroyStream] also unmount the playback component.
- Available since: 3.0.0
stopVideo
stopVideo(): voidStop playing the video in the stream to be pushed or being pushed.
- Use cases: Stop playing the video in the stream to be pushed or being pushed.
- When to call: The ZegoLocalStream instance has been created with [createZegoStream] and the stream has been collected and [playVideo] has been executed.
- Related APIs: Calling [destroyStream] unmount the playback component.
- Available since: 3.0.0
resumeAudio
resumeAudio(): voidWhen video browser restrictions prevent playback, you can call this interface in the DOM click event to resume playing the video on the page.
- Use cases: Play the audio that is to be pushed or is being streamed on the page.
- When to call: The ZegoLocalStream instance has been created with [createZegoStream] and the stream has been collected and [playAudio] has been executed.
- Available since: 3.0.0
resumeVideo
resumeVideo(): voidWhen video browser restrictions prevent playback, you can call this interface in the DOM click event to resume playing the video on the page.
- Use cases: Display media stream content on the interface.
- When to call: The ZegoLocalStream instance has been created with [createZegoStream] and the stream has been collected and [playVideo] has been executed.
- Available since: 3.0.0
startCaptureCamera
startCaptureCamera(options?: ZegoCaptureCamera): ZegoServerResponseParameters
| Name | Type | Description |
|---|---|---|
| options | ZegoCaptureCamera | Capture camera configuration parameters. |
Details
Start capturing the camera stream, and the video being pushed will not be updated synchronously. If you need to update, you can call [updatePublishingStream].
-
Use cases: Capture the camera stream to preview or update the video in the push stream.
-
When to call: After creating a ZegoLocalStream instance through [createZegoStream].
-
Related APIs: 1. After the push stream is successful, the video of the push stream needs to be updated. You can call [startCaptureCamera] successfully, and then call [updatePublishingStream] to update the microphone captured by [startCaptureCamera] to the video in the push stream. 2.Call [stopCaptureVideo] to stop the video that is currently being captured.
- Call [mutePublishStreamVideo] to turn on/off the stream video that is being pushed.
- Available since: 3.0.0
startCaptureCameraAndMicrophone
startCaptureCameraAndMicrophone(cameraOptions?: ZegoCaptureCamera, microphoneOptions?: ZegoCaptureMicrophone): ZegoServerResponseParameters
| Name | Type | Description |
|---|---|---|
| cameraOptions | ZegoCaptureCamera | Capture camera configuration parameters. |
| microphoneOptions | ZegoCaptureMicrophone | Capture microphone configuration parameters. |
Details
Start capturing the camera and microphone stream, and the video or audio being pushed will not be updated synchronously. If you need to update, you can call [updatePublishingStream].
- Use cases: Capture the camera and microphone stream to preview or update the video in the push stream.
- When to call: After creating a ZegoLocalStream instance through [createZegoStream].
- Related APIs: 1. After the push stream is successful, the audio and video of the push stream needs to be updated. You can call [startCaptureCameraAndMicrophone] successfully, and then call [updatePublishingStream] to update the custom video and audio captured by [startCaptureCameraAndMicrophone] to the video camera and microphone audio in the push stream. 2.Call [stopCaptureAudio] or [stopCaptureVideo] to stop the audio or video that is currently being captured.
- Call [mutePublishStreamAudio] or [mutePublishStreamVideo] to turn on/off the stream audio or video that is being pushed.
- Available since: 3.0.0
startCaptureCustomAudio
startCaptureCustomAudio(options: ZegoCustomAudio): ZegoServerResponseParameters
| Name | Type | Description |
|---|---|---|
| options | ZegoCustomAudio | Capture custom audio configuration parameters. |
Details
Start capturing the custom audio stream, and the audio being pushed will not be updated synchronously. If you need to update, you can call [updatePublishingStream].
- Use cases: Third-party audio streams come from the same audio capture. Capture again will cause the previous capture to stop. If the audio come from the same audio or video, it is not recommended to call [startCaptureCustomVideoAndAudio] and [startCaptureCustomAudio] multiple times.
- When to call: After creating a ZegoLocalStream instance through [createZegoStream].
- Related APIs: 1. After the push stream is successful, the audio of the push stream needs to be updated. You can call [startCaptureCustomAudio] successfully, and then call [updatePublishingStream] to update the custom audio captured by [startCaptureCustomAudio] to the audio in the push stream. 2.Call [stopCaptureAudio] to stop the audio that is currently being captured.
- Call [mutePublishStreamAudio] to turn on/off the stream audio that is being pushed.
- Available since: 3.0.0
startCaptureCustomVideo
startCaptureCustomVideo(options: ZegoCustomVideo): ZegoServerResponseParameters
| Name | Type | Description |
|---|---|---|
| options | ZegoCustomVideo | Capture custom video configuration parameters. |
Details
Start capturing the custom video stream, and the video being pushed will not be updated synchronously. If you need to update, you can call [updatePublishingStream].
-
Use cases: The custom audio and video stream comes from the captrue the same video. Capture again will cause the previous capture to stop. If the audio and video come from the same video, it is not recommended to call [startCaptureCustomVideoAndAudio] and [startCaptureCustomVideo] multiple times.
-
When to call: After creating a ZegoLocalStream instance through [createZegoStream].
-
Related APIs: 1. After the push stream is successful, the video of the push stream needs to be updated. You can call [startCaptureCustomVideo] successfully, and then call [updatePublishingStream] to update the custom video captured by [startCaptureCustomVideo] to the video in the push stream. 2.Call [stopCaptureVideo] to stop the video that is currently being captured.
- Call [mutePublishStreamVideo] to turn on/off the stream video that is being pushed.
- Available since: 3.0.0
startCaptureCustomVideoAndAudio
startCaptureCustomVideoAndAudio(videoOptions: ZegoCustomVideo, audioOptions: ZegoCustomAudio): ZegoServerResponseParameters
| Name | Type | Description |
|---|---|---|
| videoOptions | ZegoCustomVideo | Capture custom video configuration parameters. |
| audioOptions | ZegoCustomAudio | Capture custom audio configuration parameters. |
Details
Start capturing the custom video and audio stream, and the video and audio being pushed will not be updated synchronously. If you need to update, you can call [updatePublishingStream].
-
Use cases: Third-party audio and video streams come from the same audio or video collection. Collection again will cause the previous collection to stop. If the audio and video come from the same audio or video, it is not recommended to call [startCaptureCustomVideoAndAudio], [startCaptureCustomVideo] and [startCaptureCustomAudio] multiple times.
-
When to call: After creating a ZegoLocalStream instance through [createZegoStream].
-
Related APIs: 1. After the push stream is successful, the audio and video of the push stream needs to be updated. You can call [startCaptureCustomVideoAndAudio] successfully, and then call [updatePublishingStream] to update the custom video and audio captured by [startCaptureCustomVideoAndAudio] to the audio and video in the push stream. 2.Call [stopCaptureAudio] or [stopCaptureVideo] to stop the audio or video that is currently being captured.
- Call [mutePublishStreamAudio] or [mutePublishStreamVideo] to turn on/off the stream audio or video that is being pushed.
- Available since: 3.0.0
startCaptureMicrophone
startCaptureMicrophone(options?: ZegoCaptureMicrophone): ZegoServerResponseParameters
| Name | Type | Description |
|---|---|---|
| options | ZegoCaptureMicrophone | Capture microphone configuration parameters. |
Details
Start capturing the microphone stream, and the audio being pushed will not be updated synchronously. If you need to update, you can call [updatePublishingStream].
- Use cases: Capture the microphone stream to preview or update the audio in the push stream.
- When to call: After creating a ZegoLocalStream instance through [createZegoStream].
- Related APIs: 1. After the push stream is successful, the audio of the push stream needs to be updated. You can call [startCaptureMicrophone] successfully, and then call [updatePublishingStream] to update the microphone captured by [startCaptureMicrophone] to the audio in the push stream. 2.Call [stopCaptureAudio] to stop the audio that is currently being captured.
- Call [mutePublishStreamAudio] to turn on/off the stream audio that is being pushed.
- Available since: 3.0.0
startCaptureScreen
startCaptureScreen(options?: ZegoCaptureScreenVideo): ZegoServerResponseParameters
| Name | Type | Description |
|---|---|---|
| options | ZegoCaptureScreenVideo | Capture screen sharing configuration parameters. |
Details
Start capturing the screen sharing video stream, and the video being pushed will not be updated synchronously. If you need to update, you can call [updatePublishingStream].
- Use cases: Capture the screen sharing video stream to preview or update the video in the push stream.
- When to call: After creating a ZegoLocalStream instance through [createZegoStream].
- Related APIs: 1. After the push stream is successful, the video of the push stream needs to be updated. You can call [startCaptureScreen] successfully, and then call [updatePublishingStream] to update the screen video captured by [startCaptureScreen] to the video in the push stream.
- Call [mutePublishStreamVideo] to turn on/off the stream video that is being pushed.
- Available since: 3.0.0
startCaptureScreenWithAudio
startCaptureScreenWithAudio(screenVideoOptions?: ZegoCaptureScreenVideo, screenAudioOptions?: ZegoCaptureScreenAudio): ZegoServerResponseParameters
| Name | Type | Description |
|---|---|---|
| screenVideoOptions | ZegoCaptureScreenVideo | Capture screen sharing video configuration parameters. |
| screenAudioOptions | ZegoCaptureScreenAudio | Capture screen sharing audio configuration parameters. |
Details
Start capturing the screen sharing video and sharing audio stream., and the video being pushed will not be updated synchronously. If you need to update, you can call [updatePublishingStream].
- Use cases: Capture the screen sharing video and sharing audio stream to preview or update the video and audio in the push stream.
- When to call: After creating a ZegoLocalStream instance through [createZegoStream].
- Related APIs: 1. After the push stream is successful, the audio and video of the push stream needs to be updated. You can call [startCaptureScreenWithAudio] successfully, and then call [updatePublishingStream] to update the screen video and audio captured by [startCaptureScreenWithAudio] to the audio and video in the push stream.
- Call [mutePublishStreamAudio] or [mutePublishStreamVideo] to turn on/off the stream audio or video that is being pushed.
- Available since: 3.0.0
getScreenDisplaySurface
getScreenDisplaySurface(): string- When to call: after create stream.
caution: This interface is currently only supported by the Chrome browser 107 above and safari 11.1 above.
Related interface: None.
- Available since: 3.12.0
Detailed description: Get the shared content type of the screen sharing stream.
The shared content type of the screen sharing stream, 'browser' | 'window' | 'monitor'.
setVolume
setVolume(volume: number): booleanParameters
| Name | Type | Description |
|---|---|---|
| volume | number | Volume level, the value range is [0,100] . |
Details
Set the volume at which to play the audio that is being pushed or is being streame.
- When to call: The ZegoLocalStream instance has been created with [createZegoStream] and the stream has been collected and [playAudio] has been executed.
- Available since: 3.0.0
Return
Whether the interface is called successfully.
useAudioOutputDevice
useAudioOutputDevice(media: HTMLMediaElement, deviceID: string): Promise<boolean>Parameters
| Name | Type | Description |
|---|---|---|
| media | HTMLMediaElement | Media tag element, <audio> or <video>. |
| deviceID | string | Audio output device ID. |
- When to call: after using [getSpeakers] to get the list of audio output devices.
caution: This interface is currently only supported by the Chrome browser.
Related interface: Get the speaker list interface [getSpeakers].
- Available since: 3.8.0
Detailed description: Sets the audio output device for the html media element.
Return
Promise returns a Boolean ID indicating whether the call was successful.
on
on<K extends keyof ZegoLocalStreamEvent >(event: K, callback: ZegoLocalStreamEvent[K]): booleanParameters
| Name | Type | Description |
|---|---|---|
| event | K | Listener event name. |
| callback | ZegoLocalStreamEvent[K] | Callback. |
Details
The interface used to handle the SDK's initiative to notify developers of callbacks. By registering different events, you can receive callbacks of different functions. The event callback that can be monitored can be viewed in ZegoLocalStreamEvent.
Use case: Callback processing for registering business events related to the functionality of the ZegoLocalStream media streaming.
Timing of calling: After calling [createZegoStream] to create the ZegoStreamView instance.
The same event can be registered multiple, the same registered event will be triggered in sequence according to the order of registration.
Related interface: call interface off to cancel the corresponding callback event processing.
Return
Whether the registration is successful.
off
off<K extends keyof ZegoLocalStreamEvent >(event: K, callback?: ZegoLocalStreamEvent[K]): booleanParameters
| Name | Type | Description |
|---|---|---|
| event | K | Listener event name. |
| callback | ZegoLocalStreamEvent[K] | Callback. |
Details
Callback processing for unregistering business events related to the ZegoLocalStream media streaming function.
Use case: Callback processing for business events of the media streaming component.
call timing: After calling [createZegoStream] to create the ZegoStreamView instance.
- Caution: If the callback function parameter [callback] to be logged off is not passed, all the callback functions of this event will be logged off.
Return
Whether the unregister was successful.
takeStreamSnapshot
takeStreamSnapshot(option?: ZegoSnapshotOptions): stringParameters
| Name | Type | Description |
|---|---|---|
| option? | ZegoSnapshotOptions |
Details
Get the video frame data of the currently played stream to be pushed or in the stream being pushed.
- Use cases: Take a screenshot of the video that is currently being streamed or is being streamed.
- When to call /Trigger: The ZegoLocalStream instance has been created with [createZegoStream] and the stream has been collected and [playVideo] has been executed.
- Available since: 3.0.0
Return
DOMString containing the data URI
ZegoRealTimeSequentialDataManager
Realtime Sequential Data Object
Details
Real time and orderly data, relying on zego RTC service, can provide developers with real-time, orderly and high-frequency data transmission and distribution functions
Methods
startBroadcasting
startBroadcasting(streamID: string): Promise<boolean>Parameters
| Name | Type | Description |
|---|---|---|
| streamID | string | Streaming ID, a string of no more than 256 length, only supports numbers, English characters and'~','!','@','#','$','','^','&', '*','(',')','_','+','=','-',',';',''',',','.','<', '>','/','' |
Details
Start broadcasting real-time sequential data channel.
- Use cases: In the remote control scenario, the control end sends instructions to the controlled end.
- Caution: Reusable RTC streaming channel.
- When to call /Trigger: Call Interface createRealTimeSequentialDataManager Create a ZegoRealTimeSequentialDataManager.
- Available since: 2.12.2
Return
true means that the client sends the request successfully, and the stream is successfully pushed to the server and needs to be judged through the stream status callback interface.
stopBroadcasting
stopBroadcasting(streamID: string): booleanParameters
| Name | Type | Description |
|---|---|---|
| streamID | string | Push stream ID, consistent with broadcasting stream ID |
Details
Stop broadcasting real-time sequential data channel.
- Use cases: In the remote control scenario, the control end stops transmitting instructions to the controlled end.
- Caution: When the RTC channel is multiplexed, stopping the broadcasting of real-time sequential data channel will not affect the RTC channel.
- When to call /Trigger: Call Interface createRealTimeSequentialDataManager Create a ZegoRealTimeSequentialDataManager.
- Available since: 2.12.2
Return
bool
sendRealTimeSequentialData
sendRealTimeSequentialData(streamID: string, data: ArrayBuffer): booleanParameters
| Name | Type | Description |
|---|---|---|
| streamID | string | stream ID |
| data | ArrayBuffer | data |
Details
send real-time Sequential Data.
- Use cases: In the remote control scenario, the control end sends instructions to the controlled end.
- Caution: Data may be lost in a weak network.
- When to call /Trigger: Call Interface createRealTimeSequentialDataManager Create a ZegoRealTimeSequentialDataManager, and call startbroadcasting API to broadcast.
- Available since: 2.12.2
Return
bool
startSubscribing
startSubscribing(streamID: string): Promise<boolean>Parameters
| Name | Type | Description |
|---|---|---|
| streamID | string | stream ID |
Details
Start broadcasting real-time sequential data channel.
- Use cases: In the remote control scenario, the controlled end receives instructions from the control end.
- Caution: Reusable RTC streaming channel.
- When to call /Trigger: Call Interface createRealTimeSequentialDataManager Create a ZegoRealTimeSequentialDataManager.
- Available since: 2.12.2
Return
bool
stopSubscribing
stopSubscribing(streamID: string): booleanParameters
| Name | Type | Description |
|---|---|---|
| streamID | string | stream ID |
Details
stop broadcasting real-time sequential data channel.
- Use cases: In the remote control scenario, the controlled end stops receiving instructions from the control end.
- Caution: When the RTC channel is multiplexed, stopping the broadcasting of real-time sequential data will not affect the RTC channe.
- When to call /Trigger: Call Interface createRealTimeSequentialDataManager Create a ZegoRealTimeSequentialDataManager.
- Available since: 2.12.2
Return
bool
on
on<K extends keyof ZegoDataChannelEvent>(event: K, callBack: ZegoDataChannelEvent[K]): voidParameters
| Name | Type | Description |
|---|---|---|
| event | K | Listener event name. |
| callBack | ZegoDataChannelEvent[K] | Callback. |
Details
The interface used to handle the SDK's initiative to notify developers of callbacks. By registering different events, you can receive callbacks of different functions. The event callback that can be monitored can be viewed in ZegoDataChannelEvent.
Use case: Used to register the callback processing of business events related to DataChannel function.
Timing of calling: After calling the interface createRealTimeSequentialDataManagerto create the instance.
The same event can be registered multiple, the same registered event will be triggered in sequence according to the order of registration.
Related interface: call interface off to cancel the corresponding callback event processing.
Return
Whether the registration is successful.
off
off<K extends keyof ZegoDataChannelEvent>(event: K, callBack: ZegoDataChannelEvent[K]): voidParameters
| Name | Type | Description |
|---|---|---|
| event | K | Listener event name. |
| callBack | ZegoDataChannelEvent[K] | Callback. |
Details
The interface used to handle the SDK's initiative to notify developers of callbacks. By registering different events, you can receive callbacks of different functions. The event callback that can be monitored can be viewed in ZegoDataChannelEvent.
Use case: Used to unregister the callback processing of business events related to DataChannel function.
Timing of calling: After calling the interface createRealTimeSequentialDataManagerto create the instance.
The same event can be registered multiple, the same registered event will be triggered in sequence according to the order of registration.
Related interface: call interface off to cancel the corresponding callback event processing.
Return
Whether the unregister was successful.
ZegoStreamCompositor
broadcast station
Methods
addImage
addImage(img: HTMLImageElement, option: ZegoStreamCompositorInputOption): voidParameters
| Name | Type | Description |
|---|---|---|
| img | HTMLImageElement | the input image |
| option | ZegoStreamCompositorInputOption | Properties of the input layer |
Details
Create an image layer for the broadcast station
- Use cases: Set the display of the image on the output canvas.
- When to call /Trigger: Calling timing: After create ZegoStreamCompositor.
- Available since: 3.0.0
removeImage
removeImage(img: HTMLImageElement): voidParameters
| Name | Type | Description |
|---|---|---|
| img | HTMLImageElement | the input image |
Details
Remove an image layer for the broadcast station
- Use cases: Remove the display of the image on the output canvas.
- When to call /Trigger: Calling timing: After create the image layer.
- Available since: 3.0.0
setInputEndpoint
setInputEndpoint(stream: MediaStream | ZegoLocalStream, option: ZegoStreamCompositorInputOption): Promise<void>Parameters
| Name | Type | Description |
|---|---|---|
| stream | MediaStream | ZegoLocalStream | MediaStream or the ZegoLocalStream instance object created by createZegoStream |
| option | ZegoStreamCompositorInputOption | Properties of the input layer |
Details
Create an input layer for the broadcast station
- Use cases: Set the display of the input stream on the output canvas.
- When to call /Trigger: Calling timing: After create ZegoStreamCompositor.
- Available since: 3.0.0
setOutputConfig
setOutputConfig(config: ZegoStreamCompositorOutputConfig): voidParameters
| Name | Type | Description |
|---|---|---|
| config | ZegoStreamCompositorOutputConfig | Output stream options |
Details
Set the properties of the compositor output
- Use cases: When you need to combine multiple video streams and pictures of local users into one video stream, such as online education, remote conferences, live broadcasts, etc., you can use the broadcast station to achieve this.
- When to call /Trigger: Calling timing: After create ZegoStreamCompositor.
- Available since: 3.0.0
startComposingStream
startComposingStream(): Promise<MediaStream>The broadcasting station will merge the contents of all input layers and output audio and video.
- Use cases: When you need to combine multiple video streams and pictures of local users into one video stream, such as online education, remote conferences, live broadcasts, etc., you can use the broadcast station to achieve this.
- When to call /Trigger: Calling timing: After create ZegoStreamCompositor.
- Available since: 3.0.0
stopComposingStream
stopComposingStream(): Promise<boolean>The broadcasting station stop composing stream.
- Use cases: When it is time to end the composition stream.
- When to call /Trigger: Calling timing: After composing stream.
- Available since: 3.0.0
ZegoStreamView
Media Stream Player Component
Details
The media stream player component class.
- Use cases: Play the media stream on the interface.
Methods
play
play(container: string | HTMLElement, options?: ZegoStreamViewOptions): voidParameters
| Name | Type | Description |
|---|---|---|
| container | string | HTMLElement | Specifies a container where the SDK will create the <video> element to play the video track. The parameter value can be a DOM element object (for example, div) or the ID of the DOM element. |
| options | ZegoStreamViewOptions | Set playback options parameters (mirror, display mode, muted, etc.). |
Details
Specify a DOM element as the container. The SDK will create a <video> element and a <audio> element under the element as needed to play the video and audio of the media stream respectively.
- Use cases: Display media stream content on the interface.
- When to call: After creating a ZegoStreamView instance.
- Caution: - A ZegoStreamView playback component can only be mounted on one container through the play method, and cannot be mounted on multiple ones at the same time.
- Due to the limitations of the browser's autoplay policy, invoking the play method without any user interaction on the page may cause playback failure. You can use the event callback [autoplayFailed] to catch the error and guide the user toplay interactive
- Related callbacks: When calling the play interface to play a video failed, the automatic playback failure event callback [autoplayFailed]of ZegoStreamView will be triggered.
- Related APIs: Uninstall media streaming component interface [stop] . Calling [stopPlayingStream] or [destroyStream] also unloads the playback component.
- Available since: 2.17.0
playVideo
playVideo(container: string | HTMLElement, options?: ZegoStreamViewOptions): voidParameters
| Name | Type | Description |
|---|---|---|
| container | string | HTMLElement | Specifies a container where the SDK will create the <video> element to play the video track. The parameter value can be a DOM element object (for example, div) or the ID of the DOM element. |
| options | ZegoStreamViewOptions | Set playback options parameters (mirror, display mode, muted, etc.). |
Details
Specify a DOM element as the container, and the SDK will create a media stream under the element as needed to play videos of the media stream to be pushed or pushed. Before executing the [startPublishingStream] streaming, the media playback content will synchronize the currently latest collected video content; after the streaming is successful, ZegoLocalStream calls the acquisition camera, screen share or third-party video source again, and the newly collected video will not be synchronized to the video source being pushed. If updates are required, [updatePublishingStream] needs to be called to update.
- Use cases: Display media streaming content on the interface.
- When to call: After creating a ZegoStreamView instance and starting to collect audio and video streams.
- Caution: A ZegoStreamView instance can only be mounted on a container through the playVideo method, and cannot be mounted multiple times at the same time.
- Related callbacks: Calling the [playVideo] interface will trigger the ZegoStreamView's autoplay failure event callback [autoplayFailed] when the video is failed to be played.
- Related APIs: Stop playing media streaming interface [stopVideo]. Calling [destroyStream] will also uninstall the playback component. [playVideo] and [playAudio] are the [play] methods that differentiate and refine the playback operations of video and audio.
- Available since: 3.8.0
playAudio
playAudio(options?: ZegoStreamViewOptions): voidParameters
| Name | Type | Description |
|---|---|---|
| options | ZegoStreamViewOptions | Set playback options parameters. |
Details
Play audio from media streams.
- Use cases: Just want to play audio from media streams, and I don't need to play videos.
- When to call: After creating a ZegoStreamView instance.
- Related callbacks: Calling the [playAudio] interface to play videos fails to play [autoplayFailed] will trigger the ZegoStreamView's autoplay failure event callback [autoplayFailed].
- Related APIs: Stop playing media streaming interface [stopAudio]. Calling [destroyStream] will also uninstall the playback component. [playVideo] and [playAudio] are the [play] methods that differentiate and refine the playback operations of video and audio.
- Available since: 3.8.0
stop
stop(): voidUninstall the media streaming component to end displaying audio and video.
- Use cases: Ends presenting the media stream content on the interface.
- When to call: After creating a ZegoStreamView instance.
- Related APIs: Calling [stopPlayingStream] or [destroyStream] also unmount the playback component.
- Available since: 2.17.0
stopVideo
stopVideo(): voidStop playing media streaming video.
- Use cases: Media streaming video content is no longer necessary on the interface.
- When to call: After creating a ZegoStreamView instance, the stream has been collected and [playVideo] has been executed.
- Related APIs: Calling [stopPlayingStream] or [destroyStream] will also uninstall the playback component.
- Available since: 3.8.0
stopAudio
stopAudio(): voidStop playing audio from media streams.
- Use cases: Media streaming video content is no longer necessary on the interface.
- When to call: After creating a ZegoStreamView instance, the stream has been collected and [playAudio] has been executed.
- Related APIs: Calling [stopPlayingStream] or [destroyStream] will also uninstall the playback component.
- Available since: 3.8.0
resume
resume(): voidWhen video browser restrictions prevent playback, you can call this interface in the DOM click event to resume playing the audio and video on the page.
- Use cases: Display media stream content on the interface.
- When to call: After creating a ZegoStreamView instance.
- Available since: 2.17.0
setAudioMuted
setAudioMuted(muted: boolean): booleanParameters
| Name | Type | Description |
|---|---|---|
| muted | boolean | Whether to disable, true means disabled, false means resume enabled. |
Details
Switch audio playback.
- Use cases: Stop or resume playing the audio of the media stream.
- When to call: Called after the [play] method of the ZegoStreamView instance is called to mount the component.
- Caution: This interface will only stop playing the audio of the media stream, and will not affect the audio transmission content of the media stream. You need to call the [mutePublishStreamAudio] interface to stop sending audio, and call the [mutePlayStreamAudio] interface to stop receiving audio.
- Available since: 2.17.0
Return
Identifies whether the interface call is successful.
setVideoMuted
setVideoMuted(muted: boolean): booleanParameters
| Name | Type | Description |
|---|---|---|
| muted | boolean | Whether to disable, true means disabled, false means resume enabled. |
Details
Switch video playback.
- Use cases: Stop or resume video of media stream.
- When to call: Called after the [play] method of the ZegoStreamView instance is called to mount the component.
- Caution: This interface will only stop playing the video of the media stream, and will not affect the video transmission content of the media stream. To stop sending videos, you need to call the [mutePublishStreamVideo] interface, and stop receiving videos and call the [mutePlayStreamVideo] interface.
- Available since: 2.17.0
Return
Identifies whether the interface call is successful.
useAudioOutputDevice
useAudioOutputDevice(deviceID: string): Promise<void>Parameters
| Name | Type | Description |
|---|---|---|
| deviceID | string | Audio output device ID. |
- When to call: after using [getSpeakers] to get the list of audio output devices.
caution: This interface is currently only supported by the Chrome browser.
Related interface: Get the speaker list interface [getSpeakers].
setVolume
setVolume(volume: number): booleanParameters
| Name | Type | Description |
|---|---|---|
| volume | number | Volume level, the value range is [0,100] . |
Details
Set the audio playback volume.
- When to call: After creating a ZegoStreamView instance.
- Caution: Setting the volume to 0 in Safari may not work, so you can use setAudioMuted to mute the audio.
- Available since: 2.17.0
Return
Whether the interface is called successfully.
on
on<K extends keyof StreamViewEvent >(event: K, callback: StreamViewEvent[K]): booleanParameters
| Name | Type | Description |
|---|---|---|
| event | K | Listener event name. |
| callback | StreamViewEvent[K] | Callback. |
Details
The interface used to handle the SDK's initiative to notify developers of callbacks. By registering different events, you can receive callbacks of different functions. The event callback that can be monitored can be viewed in StreamViewEvent.
Use case: Callback processing for registering business events related to the function of the media stream component.
Timing of calling: After creating the ZegoStreamView instance.
The same event can be registered multiple, the same registered event will be triggered in sequence according to the order of registration.
Related interface: call interface off to cancel the corresponding callback event processing.
Return
Whether the registration is successful.
off
off<K extends keyof StreamViewEvent >(event: K, callback?: StreamViewEvent[K]): booleanParameters
| Name | Type | Description |
|---|---|---|
| event | K | Listener event name. |
| callback | StreamViewEvent[K] | Callback. |
Details
The interface used to handle the SDK's initiative to notify developers of callbacks. By registering different events, you can receive callbacks of different functions. Used to delete the registered callback event of the same type.
Use case: Callback processing for business events of the media streaming component.
call timing: After the zegostreamview instance is created.
- Caution: If the callback function parameter [callback] to be logged off is not passed, all the callback functions of this event will be logged off.
Return
Whether the unregister was successful.
takeStreamSnapshot
takeStreamSnapshot(option?: ZegoSnapshotOptions): stringParameters
| Name | Type | Description |
|---|---|---|
| option? | ZegoSnapshotOptions |
Details
get the currently rendered video frame data
- Use cases: Take a screenshot of the currently (push/pull) rendered video screen.
- When to call /Trigger: After call view.play.
- Available since: 2.18.0
Return
DOMString containing the data URI
