Options
All
  • Public
  • Public/Protected
  • All
Menu

The stream interface provides methods that define the behaviors of a stream object, such as mute audio or capture video.

The stream object is created by the getMediaStream method.

Index

Functions Audio

Functions CRC

Functions Camera

Functions Phone

Functions Processor

Functions Screen Share

Functions Video

Audio Functions

  • adjustUserAudioVolumeLocally(userId: number, volume: number): ExecutedResult
  • Adjusts someone's audio locally. This operation doesn't affect other participants' audio.

    Parameters

    • userId: number

      User ID.

    • volume: number

      The volume, an integer between 0-100.

    Returns ExecutedResult

  • The host can set to allow users to unmute themselves.

    • Only the host or manager can do this.

    Parameters

    • enable: boolean

    Returns ExecutedResult

    executed promise.

  • Enables or disables background suppression.

    Note: Enabling this option may increase CPU utilization.

    Parameters

    • enabled: boolean

      enabled

    Returns ExecutedResult

  • enableOriginalSound(enable: boolean | { hifi?: boolean; stereo?: boolean }): ExecutedResult
  • Enable or disable original sound.

    Parameters

    • enable: boolean | { hifi?: boolean; stereo?: boolean }

      enabled

    Returns ExecutedResult

  • Enables or disables sync mute or unmute state on headset.

    Only supported on Chromium-like browsers.

    Parameters

    • enabled: boolean

      enabled

    Returns ExecutedResult

  • getActiveMicrophone(): string
  • Gets the active device ID of the microphone.

    Returns string

    Device ID.

  • getActiveSpeaker(): string
  • Gets the active device of the audio speaker.

    Returns string

    Device ID.

  • getAudioMediaPlaybackController(): (Pick<HTMLAudioElement, "play" | "pause" | "paused" | "muted" | "currentTime" | "loop"> & { playback: boolean }) | null
  • Get the audio media file playback controller. Only available when using the media file as an audio source, otherwise, it returns null.

    Returns (Pick<HTMLAudioElement, "play" | "pause" | "paused" | "muted" | "currentTime" | "loop"> & { playback: boolean }) | null

  • Gets the available microphones.

    Returns MediaDevice[]

    Microphone list.

  • Gets the available audio speakers.

    Returns MediaDevice[]

    Speaker list.

  • getUserVolumeLocally(userId: number): number
  • Get the user's volume.

    Parameters

    • userId: number

      User ID.

    Returns number

    Number.

  • isAllowAudioUnmutedBySelf(): boolean
  • Determines whether users are allowed to unmute their audio themselves.

    Returns boolean

    Boolean.

  • isAudioMuted(userId?: number): boolean
  • Determines whether the user is muted.

    • If the user ID is not specified, gets the muted status of the current user.

    Parameters

    • Optional userId: number

      Default undefined

    Returns boolean

    boolean

  • isOthersShareAudioMutedLocally(userId: number): boolean
  • Determines whether share audio is muted locally. Refers to the audio shared by other participants.

    Parameters

    • userId: number

      User ID.

    Returns boolean

    Boolean.

  • isSupportMicrophoneAndShareAudioSimultaneously(): boolean
  • Determines whether the platform support microphone audio and share tab audio work at the same time.

    Returns boolean

    boolean.

  • isUserAudioMutedLocally(userId: number): boolean
  • Determines whether someone's audio is muted locally.

    Parameters

    • userId: number

      User ID.

    Returns boolean

    Boolean.

  • Mute all users' audio

    • Only the host or manager can do this.
    // host side
    await stream.muteAllAudio();
    // other user side
    client.on('current-audio-change',payload=>{
    if(payload.action==='muted' && payload.source==='passive(mute all)'){
    console.log('host muted all');
    }
    })

    Returns ExecutedResult

    executed promise.

  • Mute all users' audio locally, this operation doesn't affect other users' audio

    Returns ExecutedResult

  • Mutes audio.

    • If userId is not specified, this will mute self.
    • Only the host or manager can mute others.
    • If a participant is allowed to talk, the host can also mute them.

    Parameters

    • Optional userId: number

      Default undefined.

    Returns ExecutedResult

    Executed promise.

  • The host can set to mute users when they start audio.

    • Only the host or manager can do this.

    Parameters

    • Optional enable: boolean

      boolean default true

    Returns ExecutedResult

    executed promise.

  • Mutes self share audio or other's share audio locally. If userId is empty, will mute share audio. Other participants will not be able to hear the share audio. If userId is set, will mute share audio locally, other participants are not affected.

    Parameters

    • Optional userId: number

      Optional empty value will mute self share audio.

    Returns ExecutedResult

    Executed promise.

  • Mutes someone's audio locally. This operation doesn't affect other participants' audio.

    Parameters

    • userId: number

      User ID.

    Returns ExecutedResult

      • '': Success.
  • Joins audio by microphone and speaker.

    • If the participant has joined audio by phone, they cannot join using computer audio.
    await client.init();
    await client.join(topic, signature, username, password);
    const stream = client.getMediaStream();
    await stream.startAudio();

    Parameters

    Returns ExecutedResult

    Executed promise. Possible error reasons:

    • type = INSUFFICIENT_PRIVILEGES,reason = AUDIO_CAPTURE_FAILED: The user has blocked accesses to the microphone from the SDK. Try to grant the privilege and rejoin the session.
  • startSecondaryAudio(deviceId: string, constraints?: Pick<MediaTrackConstraints, "autoGainControl" | "noiseSuppression" | "sampleRate" | "echoCancellation">): ExecutedResult
  • Start audio with the secondary microphone. This is typically used when a user needs to share additional audio input after joining the audio. Please note that simultaneous screen sharing is not supported in this scenario.

    Parameters

    • deviceId: string
    • Optional constraints: Pick<MediaTrackConstraints, "autoGainControl" | "noiseSuppression" | "sampleRate" | "echoCancellation">

      audio track contraints

    Returns ExecutedResult

  • Subscribes to audio statistic data based on the type parameter. Client will receive audio quality data every second.

    Note If type is not specified, this will subscribe to both encode and decode audio statistics.

    • Client only handles the encode (send) audio statistic data when:
      1. Current user's audio is connected.
      2. Current user is not muted.
      3. There is another participant who is listening to the current user's audio.
    • Client only handles the decode (receive) audio statistic data when:
      1. Current user's audio is connected.
      2. There is another participant who is sending audio.

    Example

    try{
    await stream.subscribeAudioStatisticData();
    } catch (error) {
    console.log(error);
    }

    Parameters

    • Optional type: StatisticOption

      Optional. Object { encode: Boolean, decode: Boolean } can specify which type of audio to subscribe to.

    Returns ExecutedResult

    • '': Success.
    • Error: Failure. Details in ErrorTypes.
  • Switches the microphone.

     const microphones = stream.getMicList();
    const microphone = // choose another microphone
    await switchMicrophone(microphone.deviceId);

    Parameters

    • microphoneId: string | MediaPlaybackFile

      Device ID of the microphone or an audio playback file.

    Returns ExecutedResult

    Executed promise.

  • Switches the audio speaker.

    Parameters

    • speakerId: string

      Device ID of the speaker.

    Returns ExecutedResult

    Executed promise.

  • Unmute all users' audio

    • Only the host or manager can do this.
    • For privacy and security concerns, the host can not unmute the participant's audio directly, instead, the participant will receive an unmute audio consent message.

    Returns ExecutedResult

    executed promise.

  • Unute all users' audio locally, this operation doesn't affect other users' audio

    Returns ExecutedResult

  • Unmutes audio.

    • If userId is not specified, this will unmute self.
    • For privacy and security concerns, the host can not unmute the participant's audio directly, instead, the participant will receive an unmute audio consent message.
    // unmute myself
    await stream.unmuteAudio();

    // host unmute others
    await stream.unmuteAudio(userId);
    // participant side
    client.on('host-ask-unmute-audio',(payload)=>{
    console.log('Host ask me to unmute');
    })

    Parameters

    • Optional userId: number

      Default undefined.

    Returns ExecutedResult

    Executed promise.

  • Unmutes self share audio or other's share audio locally. If userId is empty, will unmute share audio, other participants will be able to hear the share audio. If userId is set, will unmute share audio locally, other participants are not affected.

    Parameters

    • Optional userId: number

      Optional empty value will unmute self share audio.

    Returns ExecutedResult

    Executed promise.

  • Unmutes someone's audio locally. This operation doesn't affect other participants' audio.

    Parameters

    • userId: number

      User ID.

    Returns ExecutedResult

      • '': Success.
  • Unsubscribes to audio statistic data based on the type parameter.

    Note If type is not specified, this will unsubscribe to both encode and decode audio statistics. Example

    try{
    await stream.unsubscribeAudioStatisticData();
    } catch (error) {
    console.log(error);
    }

    Parameters

    • Optional type: StatisticOption

      Optional. Object { encode: Boolean, decode: Boolean } can specify which type of audio to unsubscribe to.

    Returns ExecutedResult

      • '': Success.

CRC Functions

  • Call out CRC (Cloud Room Connector) device

    client.on('crc-call-out-state-change',(payload)=>{
    console.log('crc device call out status:',payload.code)
    })

    Parameters

    • ipAddress: string

      IP Address

    • protocol: CRCProtocol

      Protocol H323|SIP

    Returns ExecutedResult | Promise<string>

  • Cancel the CRC (Cloud Room Connector) call out request before it is complete.

    Parameters

    • ipAddress: string

      IP Address

    • protocol: CRCProtocol

      Protocol H323|SIP

    Returns ExecutedResult

Camera Functions

  • Approves the control request.

    Parameters

    • userId: number

      the requesting user ID.

    Returns ExecutedResult

    • '': Success
    • Error: Failure. Details in ErrorTypes.
  • Declines the control request.

    Parameters

    • userId: number

      The requesting user ID.

    Returns ExecutedResult

    • '': Success
    • Error: Failure. Details in ErrorTypes.
  • Gets the capability of the camera on current device.

    Parameters

    • Optional cameraId: string

      Default is active camera ID.

    Returns PTZCameraCapability

  • Gets the capability of the far-end camera.

    Parameters

    • userId: number

    Returns PTZCameraCapability

  • Gives up control of far end camera.

    Parameters

    • userId: number

      The controlling user ID.

    Returns ExecutedResult

    • '': Success
    • Error: Failure. Details in ErrorTypes.
  • isBrowserSupportPTZ(): boolean
  • Determines whether the current browser supports Pan-Tilt-Zoom (PTZ).

    Returns boolean

  • Request control on far-end PTZ camera

    // UserA
    // request control of UserB's camera
    stream.requestFarEndCameraControl(userBId);

    // UserB
    client.on("far-end-camera-request-control", (payload) => {
    const { userId, displayName } = payload;
    // popup a confirm window, approve or decline the request
    stream.approveFarEndCameraControl(userId);
    });

    // UserA
    let isFarEndCameraApproved = false;
    let capability = undefined;
    client.on("far-end-camera-response-control", (payload) => {
    const { isApproved, userId, displayName } = payload;
    isFarEndCameraApproved = isApproved;
    });

    client.on("far-end-camera-capability-change", (payload) => {
    const { userId, ptz } = payload;
    capability = ptz;
    if (capability.pan) {
    // pan the camera left
    stream.controlFarEndCamera({
    userId,
    cmd: CameraControlCmd.Left,
    range: 10,
    });
    }
    });

    Parameters

    • userId: number

      the controlling user ID.

    Returns ExecutedResult

    • '': Success
    • Error: Failure. Details in ErrorTypes.

Phone Functions

  • cancelInviteByPhone(countryCode: string, phoneNumber: string, options?: { callMe?: boolean }): ExecutedResult
  • Cancels the dial out request before it is complete.

    Parameters

    • countryCode: string

      Country code.

    • phoneNumber: string

      Phone number.

    • Optional options: { callMe?: boolean }
      • Optional callMe?: boolean

    Returns ExecutedResult

    Executed promise.

  • Gets phone call status.

    Returns DialoutState

    Phone call status.

  • Get supported countries.

    Returns PhoneCallCountry[]

    Supported phone call countries.

  • Hangs up the phone. Only used when the current audio was joined by phone.

    Returns ExecutedResult

    Executed promise.

  • Invites a user to join by phone.

    You can join a Zoom session by means of teleconferencing or audio conferencing (using a traditional phone). This is useful when:

    • You do not have a microphone or speaker on your PC or macOS machine.
    • You do not have a smartphone (iOS or Android) while on the road.
    • You cannot connect to a network for video and VoIP (computer audio).

    If a number is not listed or has asterisks (***) in place of some of the numbers, it means that number is not available on the account that you're currently logged into. Check the stream.getSupportCountryInfo() method to get available countries.

    • This method will trigger the dialout-state-change event, add a listener to get the latest value.
    const countryCode = '+1'
    const phoneNumber ='8801'
    if(stream.getSupportCountryInfo().findIndex(country=>country.code===countryCode)>-1){
    await stream.inviteByPhone(countryCode,phoneNumber,name);
    }
    client.on('dialout-state-change',({code})=>{
    console.log('dial out stats:',code);
    });

    Parameters

    • countryCode: string

      Country code.

    • phoneNumber: string

      Phone number.

    • name: string

      Name.

    • Optional options: DialOutOption

    Returns ExecutedResult

    Executed promise.

  • isSupportPhoneFeature(): boolean
  • Determines whether the phone call feature is supported.

    Returns boolean

    Boolean.

Processor Functions

  • addProcessor(processor: Processor): Promise<"">
  • Add the processor to the current media stream.

    Parameters

    • processor: Processor

      required. The processor instance you want to add.

    Returns Promise<"">

    • '': Success
  • Create a processor.

    Parameters

    Returns Promise<Processor>

    • Processor: Processor instance.
  • isSupportVideoProcessor(): boolean
  • Determines whether the current platform supports the video processor.

    Returns boolean

    Whether the current platform supports the video processor.

  • removeProcessor(processor: Processor): Promise<"">
  • Remove the current media stream processor.

    Parameters

    • processor: Processor

      required. The processor instance you want to remove.

    Returns Promise<"">

    • '': Success

Screen Share Functions

  • Enables or disables video share optimization.

    Parameters

    • enable: boolean

      boolean

    Returns ExecutedResult

    Executed promise.

  • getActiveShareUserId(): number
  • Gets the user ID of the received shared content.

    Returns number

    Active shared user ID.

  • Gets the status of share.

    Returns ShareStatus

    Share status.

  • getShareStreamSettings(): { deviceId?: string; displaySurface?: string; height?: number; width?: number }
  • Get the active share stream settings

    Returns { deviceId?: string; displaySurface?: string; height?: number; width?: number }

    • Optional deviceId?: string
    • Optional displaySurface?: string
    • Optional height?: number
    • Optional width?: number
  • Gets the list of users who are screen sharing.

    Returns Participant[]

    shared user list

  • isOptimizeForSharedVideoEnabled(): boolean
    • Determines whether video sharing is enabled.

    Returns boolean

  • isShareLocked(): boolean
  • Determines whether the host locked the share.

    Returns boolean

    Whether screen share is locked.

  • isStartShareScreenWithVideoElement(): boolean
  • Determines whether to use video element to start screen sharing.

    Returns boolean

    boolean

  • isSupportOptimizedForSharedVideo(): boolean
  • Determines whether the current platform supports video share.

    Returns boolean

  • Locks the privilege of screen share. Only the host or manager can share.

    • Only the host or manager has the permission.
    • If a participant (non-host or manager) is sharing the screen, once the host locks screen share, their share will be forcibly stopped.
    // host
    stream.lockShare(true);
    // sharing user
    client.on('passively-stop-share',payload=>{
    if(payload.reason==='PrivilegeChange'){
    console.log('passively stop share because of privilege change')
    }
    })

    Parameters

    • isLocked: boolean

      Set to true to lock share, or false to unlock.

    Returns ExecutedResult

    Executed promise.

  • Determines whether the shared content is broadcast to subsessions, when screen sharing is started. Available to host or manager.

    Returns ExecutedResult

    Executed promise.

  • Starts screen share.

    • Check the share privilege before starting screen share.
    • If you start screen share, you will stop receiving others' shared content.
    • Users with legacy Chrome browsers need to install a chrome extension before starting screen share. Check the promise return value.

    Parameters

    • canvas: HTMLVideoElement | HTMLCanvasElement

      Required. The canvas which renders the screen share content.

    • Optional options: ScreenShareOption

      Optional options for screen share.

    Returns ExecutedResult

    Executed promise.

    • {type:'INVALID_OPERATION', reason:'required extension', extensionUrl:'url'} : Install the extension before starting share.
  • startShareView(canvas: HTMLCanvasElement, activeUserId: number): ExecutedResult
  • Renders the received screen share content.

    • It is usually called in the active-share-change callback.
    client.on('active-share-change',payload=>{
    if(payload.state==='Active'){
    stream.startShareView(canvas,payload.activeUserId);
    }else if(payload.state==='Inactive'){
    stream.stopShareView();
    }
    })

    Parameters

    • canvas: HTMLCanvasElement

      Required. The canvas to render the share content.

    • activeUserId: number

      Required. Active share user ID.

    Returns ExecutedResult

    Executed promise.

  • Stops broadcasting the shared content to subsessions.

    Returns ExecutedResult

    Executed promise.

  • Stops rendering received screen share content.

    Returns ExecutedResult

    Executed promise.

  • Subscribes to share statistic data base on the type parameter. Client will receive video quality data every second.

    Parameters

    • Optional type: StatisticOption

      optional. Object { encode: Boolean, decode: Boolean }, Can specify which type of share to subscribe to.

    Returns ExecutedResult

    • '': Success.
    • Error: Failure. Details in ErrorTypes.
  • Switch to another share content.

    When there are multiple users sharing the screen in the session,you can have a chance to switch to another one's screen.

    const sharingUserList = stream.getShareUserList();
    // click handler of sharing user list menu
    switchButton.addEventListener('click',(event)=>{
    if(event.dataId!==stream.getActiveShareUserId()){
    stream.switchShareView(event.dataId);
    }
    })

    Parameters

    • activeNodeId: number

      Required. Active share user ID.

    Returns ExecutedResult

    Executed promise.

  • Switches camera for sharing.

    Parameters

    • cameraId: string

      Camera ID.

    Returns ExecutedResult

    Executed promise.

  • Unsubscribes to share statistic data bases on the parameter type.

    • @param type optional. Object { encode: Boolean, decode: Boolean }, Can specify which type of share to subscribe to.

    Parameters

    Returns ExecutedResult

    • '': Success.
    • Error: Failure. Details in ErrorTypes.
  • Updates the share quality when video share enabled. Note: High resolution will lead to low FPS.

    Parameters

    Returns ExecutedResult

    Executed promise.

  • updateSharingCanvasDimension(width: number, height: number): ExecutedResult
  • Sets the dimension of the canvas rendering the received share content.

    Parameters

    • width: number

      Canvas width.

    • height: number

      Canvas height.

    Returns ExecutedResult

    Executed promise.

Video Functions

  • adjustRenderedVideoPosition(canvas: HTMLVideoElement | HTMLCanvasElement, userId: number, width?: number, height?: number, x?: number, y?: number, additionalUserKey?: string): ExecutedResult
  • Adjusts the coordinates and dimension of the rendered video.

    Parameters

    • canvas: HTMLVideoElement | HTMLCanvasElement

      Required. The canvas to render the video.

    • userId: number

      Required. The user ID which to render the video.

    • Optional width: number

      Optional. Video width. undefined if the canvas parameter is a video tag

    • Optional height: number

      Optional. Video height. undefined if the canvas parameter is a video tag

    • Optional x: number

      Optional. Coordinate x of video. undefined if the canvas parameter is a video tag

    • Optional y: number

      Optional. Coordinate y of video. undefined if the canvas parameter is a video tag

    • Optional additionalUserKey: string

      Optional. Must be paired with renderVideo.

    Returns ExecutedResult

    • '': Success.
    • Error: Failure. Details in ErrorTypes.
  • Create a VideoPlayer or reuse the existing VideoPlayer and attach the video stream to it.

    Note the returned video-playerVideoPlayer element must be a child node of the video-player-container VideoPlayerContainer.

    <video-player-container>
    <div class="video-tile"></div>
    </video-player-container>
    const element = await stream.attachVideo(userId,VideoQuality.Video_720P);
    document.querySelector('.video-tile').appendChild(element);

    Parameters

    • userId: number

      Required. The user ID which to render the video.

    • videoQuality: VideoQuality

      Required. Quality of the video. One of the following: 90P/180P/360P/720P/1080P.

    • Optional element: string | VideoPlayer

      Optional. Empty value: create a new element; String value: VideoPlayer element selector specified by document.querySelector; VideoPlayer Element value: Specified element

    Returns Promise<VideoPlayer | ExecutedFailure>

  • Clears the canvas.

    Parameters

    • canvas: HTMLCanvasElement

      Required. The canvas to render the video.

    • Optional underlyingColor: string | UnderlyingColor

      Optional. Underlying color when video is stopped. Default is transparent.

      • @returns
      • '': Success.
      • Error: Failure. Details in ErrorTypes.

    Returns ExecutedResult

  • Detach the video stream from all previously attached VideoPlayer elements or specific elements.

    const elements = await stream.detachVideo(userId);
    if (Array.isArray(elements)) {
    elements.forEach((e) => e.remove());
    } else {
    elements.remove();
    }`

    Parameters

    • userId: number

      Required. The user ID which to render the video.

    • Optional element: string | VideoPlayer

      Optional. Empty value: detach all video streams. String value:VideoPlayer element selector specified by document.querySelector; VideoPlayer Element value: Specified element

    Returns Promise<VideoPlayer | VideoPlayer[]>

  • enableHardwareAcceleration(enable: boolean | { decode?: boolean; encode?: boolean }): Promise<boolean>
  • Tries to enable hardware acceleration.

    Parameters

    • enable: boolean | { decode?: boolean; encode?: boolean }

      boolean or specific encode or decode.

    Returns Promise<boolean>

    Promise<boolean> true: success, false: fail.

  • getActiveCamera(): string
  • Gets the recently active camera devices ID.

    Returns string

    • '': The video flag is false in media constraints.
    • 'default': No camera device ID is passed to startCaptureVideo and it will use system default camera.
    • string: Recently active camera devices ID.
  • getActiveVideoId(): number
  • Gets the recently active video ID.

    Returns number

    • 0: No video is active or the video flag is false in media constraints.
    • number: ID of current active video.
  • Gets the current camera devices list.

    Note

    • This camera device list is collected from the browser's navigator.mediaDevices object and maintained by the stream object.
    • If the user does not allow permission to access the camera, this list will have a default CameraDevice object with all properties set to empty strings.

    Returns MediaDevice[]

    • []: The video flag is false in media constraints.
    • Array<CameraDevice>: A CameraDevice interface has following property:
      • label: string: The label of camera device.
      • deviceId: string: The string of camera device.
  • getCapturedVideoResolution(): { height: number; width: number }
  • Gets captured video resolution.

    Returns { height: number; width: number }

    • height: number
    • width: number
  • getMaxRenderableVideos(): number
  • Get maximum concurrent video renders supported by current device.

    Returns number

    The number of simultaneous video renders, typically affected by GPU/CPU/ShareArrayBuffer capabilities.

  • Gets network quality. Only the network quality of users who start video is meaningful.

    Parameters

    • Optional userId: number

      optional, default is current user

    Returns NetworkQuality

  • getReceivedVideoDimension(): { height: number; width: number }
  • Gets the dimension of received video. Note this is only available when multi-video rendering is not supported. For the case of multi-video rendering, get each video's resolution from the video-detailed-data-change event

    Returns { height: number; width: number }

    Received video dimension.

    • height: number
    • width: number
  • Get a list of spotlighted users.

    Returns Participant[]

  • getVideoMaxQuality(): number
  • Gets the maximum quality of video.

    Returns number

    Highest video quality. See the definition VideoQuality

  • getVideoMediaPlaybackController(): Pick<HTMLAudioElement, "play" | "pause" | "paused" | "muted" | "currentTime" | "loop"> | null
  • Get the video media file playback controller. Only available when using a media file as a video source, otherwise, it returns null.

    Returns Pick<HTMLAudioElement, "play" | "pause" | "paused" | "muted" | "currentTime" | "loop"> | null

  • isCameraTaken(): boolean
  • Gets the isCameraTaken flag status.

    Returns boolean

    • true: The camera is taken by another program.
    • false: The camera is taken by another program or the video flag is false in media constraints.
  • isCaptureForbidden(): boolean
  • Gets the isCaptureForbidden flag status.

    Returns boolean

    • true: The capture is forbidden by the user.
    • false: The capture is not forbidden by user or the video flag is false in media constraints.
  • isCapturingVideo(): boolean
  • Gets the isCapturingVideo flag status.

    Returns boolean

    • true: The stream object is capturing video.
    • false: The stream object is not capturing video or the video flag is false in media constraints.
  • isRenderSelfViewWithVideoElement(): boolean
  • Determines whether to use video element to render self-view.

    Returns boolean

    Boolean.

  • isSupportHDVideo(): boolean
  • Determines whether HD video is supported.

    Returns boolean

    Whether the current account supports sending 720p video.

  • isSupportMultipleVideos(): boolean
  • Determines whether the browser can support multiple videos. If this returns false, we recommend that you render self-view in a separate video-player-container.

    Returns boolean

    Whether the current platform supports multiple videos.

  • isSupportVirtualBackground(): boolean
  • Determines whether the current platform supports virtual backgrounds.

    Returns boolean

    Whether the current platform supports virtual backgrounds.

  • isVideoMirrored(): boolean
  • Whether the self video is mirrored

    Returns boolean

  • Mirrors current video.

    Parameters

    • mirrored: boolean

    Returns ExecutedResult

    • '': Success.
    • Error: Failure. Details in ErrorTypes.
  • Preview the video mask, if the video is on, preview mask will apply to current video.

    Parameters

    • canvas: HTMLCanvasElement
    • option: MaskOption

      Mask option.

    Returns ExecutedResult

    • '': Success.
    • Error: Failure. Details in ErrorTypes.
  • previewVirtualBackground(previewDOMElement: VideoPlayer | HTMLCanvasElement, imageUrl: undefined | string, cropped?: boolean, cameraId?: string): ExecutedResult
  • Previews the virtual background. If the video is on, preview virtual background applies to the current video.

    Parameters

    • previewDOMElement: VideoPlayer | HTMLCanvasElement
    • imageUrl: undefined | string

      Virtual background image.

    • Optional cropped: boolean

      Cropped to 16/9 aspect ratio. Default is false.

    • Optional cameraId: string

      cameraId, default is active camera

    Returns ExecutedResult

    • '': Success.
    • Error: Failure. Details in ErrorTypes.
  • Remove all spotlighted videos. Available to host.

    Returns ExecutedResult

    • '': Success.
    • Error: Failure. Details in ErrorTypes.
  • Remove a user's video from being spotlighted.

    Parameters

    • Optional userId: number

      Optional.

      • If it is empty, remove the spotlighted tag from the current user's video.
      • Otherwise, remove the spotlighted tag from the specific user's video. Available to host or manager.

    Returns ExecutedResult

    • '': Success.
    • Error: Failure. Details in ErrorTypes.
  • renderVideo(canvas: HTMLVideoElement | HTMLCanvasElement, userId: number, width: undefined | number, height: undefined | number, x: undefined | number, y: undefined | number, videoQuality: VideoQuality, additionalUserKey?: string): Promise<"" | Error>
  • deprecated

    Use the attachVideo method instead.

    Starts rendering video.

    Example

    try{
    const canvas = document.querySelector('#canvas-id');
    await stream.renderVideo(canvas,userId,300,200,0,0,1);
    } catch (error) {
    console.log(error);
    }

    Parameters

    • canvas: HTMLVideoElement | HTMLCanvasElement

      Required. The canvas or video to render the video. If userId is the current user and stream.isRenderSelfViewWithVideoElement() returns true, you need to use a video tag for rendering.

    • userId: number

      Required. The user ID which to render the video.

    • width: undefined | number

      Required. Video width. undefined if the canvas parameter is a video tag

    • height: undefined | number

      Required. Video height. undefined if the canvas parameter is a video tag

      ** Note **

      The origin of the coordinates is in the lower left corner of the canvas.

    • x: undefined | number

      Required. Coordinate x of video. undefined if the canvas parameter is a video tag

    • y: undefined | number

      Required. Coordinate y of video. undefined if the canvas parameter is a video tag

    • videoQuality: VideoQuality

      Required. Video quality: 90p, 180p, 360p, 720p. Currently supports up to 720p.

    • Optional additionalUserKey: string

      Optional. Used to render the same video on different coordinates of the canvas.

    Returns Promise<"" | Error>

    • '': Success
    • Error: Failure. Details in ErrorTypes.
  • Take a screenshot of the specified user's video stream.

    Parameters

    • userId: number

      Required. The user ID which to screenshot the video.

    Returns Promise<Blob | ExecutedFailure>

  • Spotlight specific user's video. Available to host or manager.

    Note:Spotlighting a video affects the behavior of the video-active-change event. The spotlighted user remains the active user, regardless of whether they are speaking. This also impacts the behavior in the recording file; when the 'Record active speaker' option is selected, the recording will always show the spotlighted user's video.

    Parameters

    • userId: number

      Required. Id of user to spotlight.

    • Optional isReplaced: boolean

      Optional. Host can spotlight multiple users, if true, replace all spotlighted users, otherwise, add as a new spotlighted user.

    Returns ExecutedResult

    • '': Success.
    • Error: Failure. Details in ErrorTypes.
  • Starts capturing video from a specified camera.

    Note

    • It may take the user some time to allow browser access to the camera device. Therefore there is no default timeout.

    Example

    try {
    await stream.startVideo();
    } catch (error) {
    console.log(error);
    }

    Parameters

    Returns ExecutedResult

    • '': Success
    • Error: Failure. Errors besides ErrorTypes that may be returned include the following:
      • CAN_NOT_DETECT_CAMERA: Cannot detect camera device.
      • CAN_NOT_FIND_CAMERA: The provided camera device ID is not included in the camera device list.
      • VIDEO_USER_FORBIDDEN_CAPTURE: The user has forbidden the use of the camera. They can allow camera and rejoin the session.
      • VIDEO_ESTABLISH_STREAM_ERROR: Video WebSocket is broken.
      • VIDEO_CAMERA_IS_TAKEN: User's camera is taken by other programs.
  • stopRenderVideo(canvas: HTMLVideoElement | HTMLCanvasElement, userId: number, additionalUserKey?: string, underlyingColor?: string | UnderlyingColor, isKeepLastFrame?: boolean, replacedUserId?: number): ExecutedResult
  • deprecated

    Use the detachVideo method instead.

    Stops rendering the video.

    Example

    try{
    await stream.stopRenderVideo();
    } catch (error) {
    console.log(error);
    }

    Parameters

    • canvas: HTMLVideoElement | HTMLCanvasElement

      Required. The canvas or video to render the video. If userId is the current user and stream.isRenderSelfViewWithVideoElement() returns true, you need to use a video tag for stopping rendering.

    • userId: number

      Required. The user ID which to render the video.

    • Optional additionalUserKey: string

      Optional. Must be paired with renderVideo.

    • Optional underlyingColor: string | UnderlyingColor

      Optional. Underlying color when video is stopped. Default is transparent.

    • Optional isKeepLastFrame: boolean

      Optional. Determines whether to keep the last frame when stopping the video.

    • Optional replacedUserId: number

      Optional. Whether to replace the rendered user at the same coordinate position. The benefit of specifying the next user can reduce the gap time between switching two users' videos. Only one user's video can be preloaded at the same time.

    Returns ExecutedResult

    • '': Success.
    • Error: Failure. Details in ErrorTypes.
  • Stops current video capturing.

    Example

    try{
    await stream.stopVideo();
    } catch (error) {
    console.log(error);
    }

    Returns ExecutedResult

    • '': Success
    • Error: Failure. Details in ErrorTypes.
  • Subscribes to video statistic data based on the type parameter. Client will receive video quality data every second.

    Note If type is not specified, this subscribes to both encode and decode video statistics.

    • Client only handles the encode (send) video statistic data when:
        1. Current user turns on video.
        1. There is other participant watching the current user's video.
    • Client only handles the decode (receive) video statistic data when:
        1. There is other participant sending video.

    Example

    try{
    await stream.subscribeVideoStatisticData();
    } catch (error) {
    console.log(error);
    }

    Parameters

    • Optional type: VideoStatisticOption

      Optional. Object { encode: Boolean, decode: Boolean } can specify which type of audio should be subscribed to.

    Returns ExecutedResult

    • '': Success.
    • Error: Failure. Details in ErrorTypes.
  • Changes camera device for capturing video.

    Note

    • The camera device ID is accessible only after the user allows the browser to access camera devices.
    • If the using on the mobile devices, using the MobileVideoFacingMode as the camera ID.

    Example

    try{
    const cameras = stream.getCameraList();
    const camera = // choose your camera
    await stream.switchCamera(camera.deviceId);
    } catch (error) {
    console.log(error);
    }

    Parameters

    Returns ExecutedResult

  • Unsubscribes to video statistic data based on the type parameter.

    Note If type is not specified, this will unsubscribe to both encode and decode audio statistics. Example

    try{
    await stream.unsubscribeVideoStatisticData();
    } catch (error) {
    console.log(error);
    }

    Parameters

    • Optional type: VideoStatisticOption

      Optional. Object { encode: Boolean, decode: Boolean } can specify which type of audio should be unsubscribed to.

    Returns ExecutedResult

    • '': Success.
    • Error: Failure. Details in ErrorTypes.
  • updateVideoCanvasDimension(canvas: HTMLCanvasElement, width: number, height: number): ExecutedResult
  • Updates the dimension of the canvas. Used to update the width or height when the styled width or height changed.

    Parameters

    • canvas: HTMLCanvasElement

      Required. The canvas to render the video.

    • width: number

      Required. Canvas's new width.

    • height: number

      Required. Canvas's new height.

      • @returns
      • '': Success.
      • Error: Failure. Details in ErrorTypes.

    Returns ExecutedResult

  • Update the option of video mask. You can update each option individually.

    Parameters

    Returns ExecutedResult

    • '': Success.
    • Error: Failure. Details in ErrorTypes.
  • updateVirtualBackgroundImage(imageUrl: undefined | string, cropped?: boolean): ExecutedResult
  • Updates the virtual background image.

    Parameters

    • imageUrl: undefined | string

      Virtual background image.

    • Optional cropped: boolean

      Cropped to 16/9 aspect ratio. Default is false.

    Returns ExecutedResult

    • '': Success.
    • Error: Failure. Details in ErrorTypes.