Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Stream

The audio and video stream object.

The methods provided by the Stream interface are used to define the behavior of audio and video stream objects, such as stream playback control, audio and video encoding configuration.

You can use NERTC.createStream to create audio and video stream objects. A Stream object refers to the local audio and video stream published during a call or the remote audio and video stream subscribed.

Hierarchy

  • Stream

Index

Methods

adjustAudioMixingVolume

  • adjustAudioMixingVolume(volume: number): undefined | null | Promise<void>
  • Adjusts the volume of a music file.

    The method is used to adjust the volume of mixing audio for local playback. You can call the method when you are in a room.

    Parameters

    • volume: number

      The volume of the mixing audio that is published. Valid values: 0 to 100. The default value of 100 indicates the original volume.

    Returns undefined | null | Promise<void>

adjustResolution

  • adjustResolution(MediaType: MediaType): void
  • Sets the resolution.

    Parameters

    • MediaType: MediaType

      The media stream type.

    Returns void

cleanMediaRecording

  • cleanMediaRecording(options: { recordId: string }): Promise<void>
  • Clears the recorded audio and video.

    Parameters

    • options: { recordId: string }

      The object parameters.

      • recordId: string

        The recording ID. You can get the ID by calling the listMediaRecording method.

    Returns Promise<void>

close

  • close(options: { type: MediaType }): Promise<undefined>
  • Turns off an audio and video input device, such as a microphone, camera, and screen sharing, and stops publishing the audio and video stream.

    Parameters

    • options: { type: MediaType }

      The options used to set the object

      • type: MediaType

        Media stream type, namely audio, video or screen.

    Returns Promise<undefined>

destroy

  • destroy(): void
  • Destroy the audio and video stream object.

    Returns void

downloadMediaRecording

  • downloadMediaRecording(options: { recordId: string }): Promise<RecordStatus>
  • Downloads recorded audio and video.

    Parameters

    • options: { recordId: string }

      The object parameters.

      • recordId: string

        The recording ID. You can get the ID by calling the listMediaRecording method.

    Returns Promise<RecordStatus>

getAudioLevel

  • getAudioLevel(): string
  • Gets the current volume of the audio captured by the microphone.

    Returns string

getAudioMixingCurrentPosition

  • getAudioMixingCurrentPosition(): Promise<void>
  • Gets current playback position of the music file.

    The method gets the playback position of the mixing audio file. Unit: milliseconds. You can call the method when you are in a room.

    Returns Promise<void>

    The playback position of the music file.

getAudioMixingDuration

  • getAudioMixingDuration(): Promise<void>
  • Gets the duration of a music file.

    The method is used to get the duration of the mixing audio file. Unit: milliseconds You can call the method when you are in a room.

    Returns Promise<void>

    The duration of the music file. Unit: milliseconds.

getAudioStream

  • getAudioStream(): null | MediaStream
  • Gets an audio stream MediaStream object, which can be used to customize audio rendering.

    You can render this object using a custom renderer. For example, you can set the srcObject attribute of the audio dom node to this object.

    note

    When you use a custom audio renderer, you must turn off the default audio renderer when you play the remote stream.

    remoteStream.play({
       audio: false,
       video: true
    });
    const audioStream = remoteStream.getAudioStream();
    // audioDom is a custom DOM node.
    audioDom.srcObject = audioStream;
    

    Returns null | MediaStream

getAudioTrack

  • getAudioTrack(): null | MediaStreamTrack
  • Gets the audio stream.

    Returns null | MediaStreamTrack

getEffectsVolume

  • getEffectsVolume(): { soundId: number; volume: number }[]
  • Gets the volume of the audio all sound effect files.

    note

    You can call the method when you join a room.

    since

    V4.3.0

    Returns { soundId: number; volume: number }[]

    Possible error codes: -"No MediaHelper": localStream is not initialized by init(). Therefore, the sound effect feature cannot be used.

getId

  • getId(): null | number
  • Gets the ID of the audio and video stream.

    Returns null | number

getVideoTrack

  • getVideoTrack(): undefined | null | MediaStreamTrack
  • Gets the video stream.

    Returns undefined | null | MediaStreamTrack

hasAudio

  • hasAudio(): boolean
  • Gets the audio flag.

    This method is used to confirm whether the current audio and video stream object (Stream) contains audio resources.

    note

    This method is only valid for local streams.

    Returns boolean

    • true: The audio and video stream object contains audio resources.
    • false: The audio and video stream object does not contain audio resources.

hasScreen

  • hasScreen(): boolean
  • Gets the screen sharing flag.

    This method is used to confirm whether the current audio and video stream object (Stream) contains screen sharing resources.

    note

    This method is only valid for local streams.

    Returns boolean

    • true: The audio and video stream object contains screen sharing resources.
    • false: The audio and video stream object does not contain screen sharing resources.

hasVideo

  • hasVideo(): boolean
  • Gets the video flag.

    This method is used to confirm whether the current audio and video stream object (Stream) contains video resources.

    note

    This method is only valid for local streams.

    Returns boolean

    • true: The audio and video stream object contains video resources.
    • false: The audio and video stream object does not contain video resources.

init

  • init(): Promise<void>
  • Initializes the audio and video stream object.

    This method is used to initialize the audio and video stream objects created on the local client.

    Returns Promise<void>

isPlaying

  • isPlaying(type: MediaType): Promise<boolean>
  • Returns the status of the audio and video stream playback.

    Parameters

    Returns Promise<boolean>

    • true: The audio and video stream is being rendered or played.
    • false: The audio and video stream is not rendered.

listMediaRecording

  • listMediaRecording(): { endTime: null | number; id: number; isRecording: boolean; name: null | string; startTime: null | number; status: string; type: string }[]
  • Enumerates recorded audio and video.

    Returns { endTime: null | number; id: number; isRecording: boolean; name: null | string; startTime: null | number; status: string; type: string }[]

    Recorded audio and video information.

    • id: The recoding ID.
    • type: The recording type.
    • name: The name of the recording file.
    • status: The recording status.
    • isRecording: indicates whether the recording is running.
    • startTime: The start time when the recording starts.
    • endTime: The end time when the recording ends.

muteAudio

  • muteAudio(): Promise<void>
  • Disables the audio stream.

    Returns Promise<void>

muteScreen

  • muteScreen(): Promise<void>
  • Disables the screen sharing stream.

    If you call this method to stop publishing the screen sharing stream, the remote client will trigger the Client.on("mute-screen") callback.

    Returns Promise<void>

muteVideo

  • muteVideo(): Promise<void>
  • Disables the video stream.

    • After you disable the video stream on the local client, the remote client will trigger the Client.on("mute-video") callback.
    • For remote streams, if you call this method, the local client still receives the video stream, but stops playing.
    note

    For local streams, this method can only be used when the video parameter is set to true when you call the createStream method.

    Returns Promise<void>

on

  • on(event: "accessDenied", callback: (mediaType: "audio" | "video") => void): void
  • on(event: "notFound", callback: (mediaType: "audio" | "video") => void): void
  • on(event: "deviceError", callback: (mediaType: "audio" | "video") => void): void
  • on(event: "beOccupied", callback: (mediaType: "audio" | "video") => void): void
  • Access to the device is denied.

    Parameters

    • event: "accessDenied"
    • callback: (mediaType: "audio" | "video") => void
        • (mediaType: "audio" | "video"): void
        • Parameters

          • mediaType: "audio" | "video"

          Returns void

    Returns void

  • When you obtain microphone or camera permissions, the specified device cannot be found.

    Parameters

    • event: "notFound"
    • callback: (mediaType: "audio" | "video") => void
        • (mediaType: "audio" | "video"): void
        • Parameters

          • mediaType: "audio" | "video"

          Returns void

    Returns void

  • An unknown error occurs when you obtain permissions to access the microphone or camera.

    Parameters

    • event: "deviceError"
    • callback: (mediaType: "audio" | "video") => void
        • (mediaType: "audio" | "video"): void
        • Parameters

          • mediaType: "audio" | "video"

          Returns void

    Returns void

  • When you gain the permissions to access the microphone or camera, the device is occupied.

    Parameters

    • event: "beOccupied"
    • callback: (mediaType: "audio" | "video") => void
        • (mediaType: "audio" | "video"): void
        • Parameters

          • mediaType: "audio" | "video"

          Returns void

    Returns void

open

  • open(options: { deviceId?: string; screenAudio?: boolean; sourceId?: string; type: MediaType }): Promise<undefined>
  • Turns on an audio and video input device, such as a microphone, camera, and screen sharing, and publishes the audio and video stream.

    Parameters

    • options: { deviceId?: string; screenAudio?: boolean; sourceId?: string; type: MediaType }

      The options used to set the object.

      • Optional deviceId?: string

        The ID of the device that you want to turn on.

        You can get the list of devices by calling getDevices.

      • Optional screenAudio?: boolean

        Specifies whether to share the background sound played locally during screen sharing.

        The method is only valid when the audio is not turned on and the type is screen. For more information, see StreamOptions.screenAudio.

      • Optional sourceId?: string

        You can get the data source ID of the Electron screen sharing.

      • type: MediaType

        Media stream type, namely audio, video or screen.

    Returns Promise<undefined>

pauseAllEffects

  • pauseAllEffects(): Promise<unknown>
  • Pauses all audio effects.

    note

    You can call the method when you join a room.

    since

    V4.3.0

    Returns Promise<unknown>

    Possible error codes: -"BROWSER_NOT_SUPPORT": The browser does not support the file format. -"SOUND_NOT_EXISTS": The sound effect file specified by soundId does not exist. -"INVALID_OPERATION": Invalid operation you can use log records in the console to view the reason. In most cases, a status error occurs. -"No MediaHelper": localStream is not initialized by init(). Therefore, the sound effect feature cannot be used. -"Stream.pauseEffect:soundId": The format of the soundId parameter is invalid

pauseAudioMixing

  • pauseAudioMixing(): undefined | null | Promise<void>
  • Pauses playing a music file.

    • You can call the method when you join a room.

    Returns undefined | null | Promise<void>

pauseEffect

  • pauseEffect(soundId: number): Promise<unknown>
  • Pauses a specified audio effect.

    since

    V4.3.0

    note

    You can call the method when you join a room.

    Parameters

    • soundId: number

      The ID of the specified sound effect file. Each sound effect file has a unique ID. The ID must be a positive integer. Valid values: 1 to 10000.

    Returns Promise<unknown>

    Possible error codes: -"BROWSER_NOT_SUPPORT": The browser does not support the file format. -"SOUND_NOT_EXISTS": The sound effect file specified by soundId does not exist. -"INVALID_OPERATION": Invalid operation you can use log records in the console to view the reason. In most cases, a status error occurs. -"No MediaHelper": localStream is not initialized by init(). Therefore, the sound effect feature cannot be used. -"Stream.pauseEffect:soundId": The format of the soundId parameter is invalid.

play

  • play(view: null | HTMLElement, playOptions?: { audio?: boolean; screen?: boolean; video?: boolean }): Promise<void>
  • Plays the audio and video stream.

    Parameters

    • view: null | HTMLElement

      div tag. The dom container node of the playback.

    • Optional playOptions: { audio?: boolean; screen?: boolean; video?: boolean }

      The audio and video options for playback.

      • Optional audio?: boolean

        Specifies whether to play the audio stream.

        By default, the local audio stream is played and the remote audio stream is not played.

      • Optional screen?: boolean

        Specifies whether to play the video stream.

        By default, play the video stream.

      • Optional video?: boolean

        Specifies whether to play the video stream.

        By default, play the video stream.

    Returns Promise<void>

playEffect

  • playEffect(options: { cycle: number; filePath: string; soundId: number }): Promise<unknown>
  • Plays a specified local or online audio effect file. -The supported audio file types include MP3, AAC, and other audio formats supported by the browser. Only online URLs are supported.

    • Compared with startAudioMixing, the playEffect method is more suitable for playing smaller sound effect files and supports playing multiple sound effects at the same time.
    since

    V4.3.0

    note
    • You can call this method after you publish the audio stream.
    • You can call the method multiple times to play different sound effect files simultaneously by passing in different effectId and filePath. Various sound effects are mixed. To gain optimal user experience, we recommend you play no more than three sound effect files at the same time.

    Parameters

    • options: { cycle: number; filePath: string; soundId: number }
      • cycle: number

        The number of loops effect files are played back. The parameter is optional. The default value is 1, which indicates the sound effect file is played back for one time.

      • filePath: string

        The parameter is required. The URL address of the online effect file.

        Supported audio file types include MP3, AAC, and other audio formats supported by browsers.

      • soundId: number

        The ID of the sound effect file. The parameter is required. Each sound effect file has a unique ID. The ID must be a positive integer. Valid values: 1 to 10000.

        If you have loaded the sound effect into the memory by using preloadEffect, make sure that the soundID of the playEffect method is the same as the soundID set by preloadEffect.

    Returns Promise<unknown>

    Possible error codes:

    • ""BROWSER_NOT_SUPPORT: Unsupported browser type.
    • "INVALID_OPERATION": Invalid operation. For detailed reasons, see the log records. In most cases, a status error occurs.
    • "No MediaHelper": localStream is not initialized by init(). Therefore, the sound effect feature cannot be used.
    • "Stream.playEffect:soundId": The format of the soundId parameter is invalid.
    • "Stream.playEffect:filePath": The format of the filePath parameter is invalid.
    • "Stream.playEffect:cycle": The cycle parameter format is invalid.

playMediaRecording

  • playMediaRecording(options: { recordId: string; view: HTMLElement }): Promise<void>
  • Plays back the video recording.

    Parameters

    • options: { recordId: string; view: HTMLElement }

      The object parameters.

      • recordId: string

        The recording ID. You can get the ID by calling the listMediaRecording method.

      • view: HTMLElement

        DOM nodes of audio or video to be rendered, such as div and span.

    Returns Promise<void>

preloadEffect

  • preloadEffect(soundId: number, filePath: string): Promise<unknown>
  • Presets a specified sound effect file.

    This method caches sound effect files for quick playback. To ensure smooth communication, pay attention to control the size of the pre-loaded audio file.

    note

    You can call the method when you join a room.

    since

    V4.3.0

    Parameters

    • soundId: number

      The ID of the specified sound effect file. Each sound effect file has a unique ID. The ID must be a positive integer. Valid values: 1 to 10000.

    • filePath: string

      The parameter is required. The absolute path of the online sound effect file. MP3, AAC, and other audio formats are supported by the browser.

    Returns Promise<unknown>

    Error codes that may be returned: -"BROWSER_NOT_SUPPORT": The browser does not support the file format. -"No MediaHelper": localStream is not initialized by init(). Therefore, the sound effect feature cannot be used. -"Stream.preloadEffect:filePath": The parameter format is invalid. -"Stream.preloadEffect:soundId": The parameter format is invalid.

resumeAllEffects

  • resumeAllEffects(): Promise<unknown>
  • Resumes playing all audio effect files.

    note
    • You can call the method when you join a room.
    • The error code that may be returned is the same as resumeEffect.
    since

    V4.3.0

    Returns Promise<unknown>

resumeAudioMixing

  • resumeAudioMixing(): undefined | Promise<void>
  • Resumes playing a music file.

    You can call the method when you join a room.

    Returns undefined | Promise<void>

resumeEffect

  • resumeEffect(soundId: number): Promise<unknown>
  • Resumes playing a specified audio effect.

    note

    You can call the method when you join a room.

    since

    V4.3.0

    Parameters

    • soundId: number

      The ID of the specified sound effect file. Each sound effect file has a unique ID. The ID must be a positive integer. Valid values: 1 to 10000.

    Returns Promise<unknown>

    Possible error codes: -"BROWSER_NOT_SUPPORT": The browser does not support the file format. -"No MediaHelper": localStream is not initialized by init(). Therefore, the sound effect feature cannot be used. -"Stream.resumeEffect :soundId": The format of the soundId parameter is invalid

setAudioMixingPosition

  • setAudioMixingPosition(playStartTime: number): Promise<unknown>
  • Sets the playback position of the music file to a different starting position.

    The method sets the playback position of the mixing audio file to a different starting position. The method allows you to play the mixing audio file from the position based on your requirements rather than from the beginning.

    Parameters

    • playStartTime: number

      The playback position of the mixing audio file. Unit: milliseconds.

    Returns Promise<unknown>

setAudioOutput

  • setAudioOutput(deviceId: string, callback: (err: any) => void): Promise<void>
  • Sets the audio output device of the subscribed stream.

    This method can set the audio output device of the subscribed stream in voice scenes, and switch the speaker during the call. You can call this method before or after the subscribed stream is played.

    note
    • You can call this method before or after the subscribed stream is played.
    • Currently only the Chrome browser supports this method.

    Parameters

    • deviceId: string

      The ID of the device, which can be obtained by calling getDevices. The acquired ID contains ASCII characters, and the ID must be 1 to 265 bytes in length.

    • callback: (err: any) => void
        • (err: any): void
        • Parameters

          • err: any

          Returns void

    Returns Promise<void>

setAudioProfile

  • setAudioProfile(profile: string): void
  • Sets the audio profile.

    Parameters

    • profile: string

      The audio profile type. Valid values:

      • speech_low_quality (16 kHz sample rate, mono sound, and encoding bitrate 24 kbps)
      • speech_standard (32 kHz sample rate, mono sound, and encoding bitrate 24 kbps)
      • music_standard (48 kHz sample rate, mono sound, and encoding bitrate 40 kbps)
      • standard_stereo (48 kHz sample rate, stereo sound, and encoding bitrate 64 kbps)
      • high_quality (48 kHz sample rate, mono sound, and encoding bitrate 128 kbps)
      • high_quality_stereo (48 kHz sample rate, stereo sound, and encoding bitrate 192 kbps)

    Returns void

setAudioVolume

  • setAudioVolume(volume?: number): undefined | string
  • Sets the audio playback volume.

    Parameters

    • Optional volume: number

      The audio volume. Value range: 0 to 100. A value of 0 indicates that the audio is muted.

    Returns undefined | string

setCanvasWatermarkConfigs

  • Adds a watermark to the video canvas.

    note

    The setCanvasWatermarkConfigs method applies to the local video canvas and does not affect the video stream. When you capture a screenshot of a video stream, the screenshot does not contain a watermark.

    Parameters

    • options: NERtcCanvasWatermarkConfig

      The canvas watermarks settings. You can set text watermark, image watermark, and timestamp watermark. A value of null indicates removing the watermark.

    Returns void

setCaptureVolume

  • setCaptureVolume(volume: number): undefined | string
  • Sets the volume of the audio captured by the microphone.

    Parameters

    • volume: number

      The volume of the audio captured by the microphone. Valid values: 0 to 100. A value of 0 indicates that the audio is muted.

    Returns undefined | string

setEffectsVolume

  • setEffectsVolume(volume: number): void
  • Sets the playback volume of all sound effect files.

    note

    You can call the method when you join a room.

    since

    V4.3.0

    Parameters

    • volume: number

      The volume of the sound effect file. The ID must be an integer. Valid values: 1 to 100. The default value of 100 indicates the original volume.

    Returns void

    Error codes that may be returned: -"BROWSER_NOT_SUPPORT": The browser does not support the file format. -"Stream.setEffectsVolume:volume": The volume parameter format is invalid. -"No MediaHelper": localStream is not initialized by init(). Therefore, the sound effect feature cannot be used.

setLocalRenderMode

  • setLocalRenderMode(options: RenderMode, mediaType?: "audio" | "video" | "screen"): undefined | "INVALID_ARGUMENTS"
  • Sets a local canvas.

    Call the method to set a local video canvas. The method applies to only local users. Remote users are not affected.

    Parameters

    • options: RenderMode

      The options used to set the canvas.

    • Optional mediaType: "audio" | "video" | "screen"

      The media stream type. You can specify the camera window or screen sharing window.

    Returns undefined | "INVALID_ARGUMENTS"

setRemoteRenderMode

  • setRemoteRenderMode(options: RenderMode, mediaType?: "audio" | "video" | "screen"): void
  • Sets a remote video stream canvas.

    This method is used to associate remote users with display views. The method affects only video display viewed by local users. After a user leaves the room, the association between a remote user and the view is cleared.

    Parameters

    • options: RenderMode

      The options used to set the canvas.

    • Optional mediaType: "audio" | "video" | "screen"

      The media stream type. You can specify the camera window or screen sharing window.

    Returns void

setScreenProfile

  • Sets the screen profile for screen sharing.

    This method sets the display properties of the screen during screen sharing and must be called before Stream.init.

    note

    This method can only be called for local streams.

    Parameters

    Returns void

setSubscribeConfig

  • setSubscribeConfig(subscribeOptions: { audio?: boolean; highOrLow?: number; screen?: boolean; video?: boolean }): void
  • Sets Video stream subscription parameters.

    Parameters

    • subscribeOptions: { audio?: boolean; highOrLow?: number; screen?: boolean; video?: boolean }

      The configuration parameters.

      • Optional audio?: boolean

        Specifies whether to subscribe to the audio stream.

      • Optional highOrLow?: number

        Specifies whether to subscribe to low or high streams.

        0: the low stream. 1: the high stream.

      • Optional screen?: boolean

        Specifies whether to subscribe to the screen sharing stream.

      • Optional video?: boolean

        Specifies whether to subscribe to the video stream.

    Returns void

setVideoProfile

  • Sets the video profile.

    Parameters

    Returns void

setVolumeOfEffect

  • setVolumeOfEffect(soundId: number): Promise<unknown>
  • Adjusts the volume of a specified sound effect file.

    note

    You can call the method when you join a room.

    since

    V4.3.0

    Parameters

    • soundId: number

      The ID of the specified sound effect file. Each sound effect file has a unique ID. The ID must be a positive integer. Valid values: 1 to 10000.

    Returns Promise<unknown>

    Possible error codes: -"BROWSER_NOT_SUPPORT": The browser does not support the file format. -"No MediaHelper": localStream is not initialized by init(). Therefore, the sound effect feature cannot be used. -"Stream.setVolumeOfEffect:soundId": The parameter format is invalid. -"Stream.setVolumeOfEffect:volume": The parameter format is invalid.

startAudioMixing

  • startAudioMixing(options: { audioFilePath: string; auidoMixingEnd: null | (() => void); cycle: number; loopback: boolean; playStartTime: number; replace: boolean; volume?: number }): undefined | Promise<unknown>
  • Starts playing and mixing the music file.

    This method is used to mix the specified online audio file with the audio stream captured from the microphones. The online audio file replaces the audio stream captured from the microphone.

    note

    You can call the method after you join a join room and turn on the microphone.

    Parameters

    • options: { audioFilePath: string; auidoMixingEnd: null | (() => void); cycle: number; loopback: boolean; playStartTime: number; replace: boolean; volume?: number }

      The mixing audio settings.

      • audioFilePath: string

        The URL address of the online music file. The parameter is required.

        note

        Only online audio files are supported. The file formats are supported by browsers such as MP3.

      • auidoMixingEnd: null | (() => void)

        Notification feedback when the playback of mixing audio is complete. The parameter is optional. If you stop the mixing audio or end the call, The callback to notify the reason for stopping mixing audio will not be triggered.

      • cycle: number

        Specifies the number of loops the audio files are played back. The parameter is optional.

        note
        • If you specify the number of playback loops using cycle, you must set the loopback parameter to true. If loopback is set to false, this parameter does not take effect.
        • The default value of cycle is 0, which indicates that the playback runs in an infinite loop until the playback stops after you call stopAudioMixing.
      • loopback: boolean

        Specifies whether to play the audio file repeatedly. The default value is false.

        • true: play the audio file repeatedly. The number of playback loop can be set using cycle. The default value of cycle is 0, which indicates unlimited loops of playback.
        • false: (default value) disables playback in an infinite loop.
      • playStartTime: number

        Sets the time position at which the audio file starts to play. Unit: seconds. This parameter is optional. The default value is 0, which indicates that the playback starts from the beginning.

      • replace: boolean

        Specifies whether to replace the local audio stream with an audio file. The parameter is optional.

        • true: The content of the audio file will replace the audio stream of the local recording.
        • false: (default value) The content of the audio file will be mixed with the audio stream captured by the microphone.
      • Optional volume?: number

        The playback volume of a music file. Valid values: 0 to 100. The parameter is optional. The default value is 100, which indicates that the original volume of the audio file is used.

        note

        If you modify the volume setting during a call, the modified setting will be used by default when you call the method again during the current call.

    Returns undefined | Promise<unknown>

startMediaRecording

  • startMediaRecording(mediaRecordingOptions: { reset: boolean; type: string }): Promise<undefined | string>
  • Turns on single video recording.

    Parameters

    • mediaRecordingOptions: { reset: boolean; type: string }

      parameter object.

      • reset: boolean

        If the previously recorded video has not been downloaded, whether to reset or not, the default is false.

      • type: string

        The stream type, such as audio, video, and screen.

    Returns Promise<undefined | string>

stop

  • stop(type?: "audio" | "video" | "screen"): void
  • Stops audio and video stream.

    This method is used to stop playing the audio and video stream played by Stream.play.

    Parameters

    • Optional type: "audio" | "video" | "screen"

    Returns void

stopAllEffects

  • stopAllEffects(): Promise<unknown>
  • Stops playing all audio effects.

    note

    You can call the method when you join a room.

    since

    V4.3.0

    Returns Promise<unknown>

    Error codes that may be returned: -"BROWSER_NOT_SUPPORT": The browser does not support the file format. -"No MediaHelper": localStream is not initialized by init(). Therefore, the sound effect feature cannot be used. -"Stream.playEffect:soundId": The format of the soundId parameter is invalid

stopAudioMixing

  • stopAudioMixing(): Promise<void>
  • Stops playing a music file.

    • You can call the method when you join a room.

    Returns Promise<void>

stopEffect

  • stopEffect(soundId: number): Promise<unknown>
  • Stops playing all audio effects.

    since

    V4.3.0

    note

    You can call the method when you join a room.

    Parameters

    • soundId: number

      The ID of the specified sound effect file. Each sound effect file has a unique ID. The ID must be a positive integer. Valid values: 1 to 10000.

    Returns Promise<unknown>

    Possible error codes: -"BROWSER_NOT_SUPPORT": The browser does not support the file format. -"No MediaHelper": localStream is not initialized by init(). Therefore, the sound effect feature cannot be used. -"Stream.playEffect:soundId": The format of the soundId parameter is invalid.

stopMediaRecording

  • stopMediaRecording(options: { recordId?: string }): Promise<unknown>
  • Ends video recording.

    Parameters

    • options: { recordId?: string }

      The object parameters.

      • Optional recordId?: string

        The recording ID. You can get the ID by calling the listMediaRecording method.

    Returns Promise<unknown>

switchDevice

  • switchDevice(type: string, deviceId: string): Promise<void>
  • Switches media input devices.

    This method is used to switch local streaming media input devices, such as microphones, and video output devices such as cameras.

    note

    You do not need to publish the stream that has been published for another time after you switch the device.

    Parameters

    • type: string

      The device type.

      • "audio": audio input device
      • "video": video input device
    • deviceId: string

      The ID of the device, which can be obtained by calling getDevices. The acquired ID contains ASCII characters, and the ID must be 1 to 265 bytes in length.

    Returns Promise<void>

takeSnapshot

  • takeSnapshot(options: { mediaType?: "audio" | "video" | "screen"; name: string; uid: number }): Promise<undefined | "INVALID_OPERATION">
  • Captures the screenshots of the video stream from specified users.

    The screenshot file is saved in the default path of the browser.

    note
    • Before you call the method to capture a screenshot from the local video stream, you must first call Client.join and Client.publish to publish the local stream.
    • To capture a screenshot of the remote video stream, you must first subscribe to the remote video stream by calling Client.subscribe.
    • You can set text, timestamp, and image watermarks at the same time. If different types of watermarks overlap, the layers overlay previous layers in the image, text, and timestamp sequence.

    Parameters

    • options: { mediaType?: "audio" | "video" | "screen"; name: string; uid: number }
      • Optional mediaType?: "audio" | "video" | "screen"

        The type of the video stream from which the screenshot is captured.

      • name: string

        The name of the screenshot. The default format is uid-1.

      • uid: number

        User ID.

    Returns Promise<undefined | "INVALID_OPERATION">

unloadEffect

  • unloadEffect(soundId: number): Promise<unknown>
  • Releases a specified sound effect file.

    This method releases a pre-loaded sound effect file from the memory to save memory usage.

    note

    You can call the method when you join a room.

    since

    V4.3.0

    Parameters

    • soundId: number

      The ID of the specified sound effect file. Each sound effect file has a unique ID. The ID must be a positive integer. Valid values: 1 to 10000.

    Returns Promise<unknown>

    Error codes that may be returned: -"BROWSER_NOT_SUPPORT": The browser does not support the file format. -"SOUND_NOT_EXISTS": The sound effect file specified by soundId does not exist. -"INVALID_OPERATION": Invalid operation you can view the log records in the console. In most cases, a status error occurs. If the file is in the play or pause status, the operation is invalid. -"No MediaHelper": localStream is not initialized by init(). Therefore, the sound effect feature cannot be used. -"Stream.unloadEffect:soundId": The parameter format is invalid.

unmuteAudio

  • unmuteAudio(): Promise<void>
  • Enables the audio stream.

    Returns Promise<void>

unmuteScreen

  • unmuteScreen(): Promise<void>
  • Enables the screen sharing stream.

    If you have called muteScreen to disable screen sharing, you can call this method to enable the screen sharing stream. The remote client will trigger the Client.on("ummute-screen") callback.

    Returns Promise<void>

unmuteVideo

  • unmuteVideo(): Promise<void>
  • Enables the audio stream.

    By default, the video stream is enabled. If you have called muteVideo to disable the video stream, you can call this method to enable the video stream.

    After you enable the video stream on the local client, the remote client will trigger the Client.on("unmute-video") callback.

    note

    For local streams, this method can only be used when the video parameter is set to true when you call the createStream method.

    Returns Promise<void>