This topic describes the AliRtcEngine interface of the Web SDK.

Contents

Define a constructor
var aliWebrtc = new AliRtcEngine(option);
Parameter description
Parameter Type Description
option autoPublish Boolean Whether to automatically push the stream. Value:
  • true: Yes.
  • False (default): No.
autoSubscribe Boolean Whether to subscribe automatically. Value:
  • true: Yes.
  • False (default): No.

Basic methods

API Description Supported earliest version
isSupport Checks whether the browser supports Web SDK. 1.12
getDevices Obtain device information. 1.2
getAvailableResolutions Gets the supported resolution. 1.2
isSupportScreenShare Supports screen sharing. 1.12
setChannelProfile Set the channel mode. 1.12
setClientRole Set the role. 1.12
setAudioOnlyMode Specifies whether to set this parameter to audio-only mode. 1.12.2
dispose Releases an instance. 1.16.5

Channel-related interfaces

API Description Supported earliest version
joinChannel Join the channel. 1.2
leaveChannel Off the channel. 1.2

Publish related interfaces

API Description Supported earliest version
configLocalAudioPublish Specify whether to allow the audio stream to be published. 1.9
configLocalCameraPublish Specify whether to allow the camera stream to be published. 1.9
configLocalScreenPublish Specify whether to allow publishing screen sharing streams. 1.9
publish Releases a local video stream. 1.2
unPublish End publishing the local stream. 1.2

Subscription-related interfaces

API Description Supported earliest version
configRemoteAudio Specifies whether to subscribe to remote audio streams. 1.9
configRemoteCameraTrack Specifies whether to subscribe to the remote camera stream. 1.9
configRemoteScreenTrack Specifies whether to subscribe to a remote screen stream. 1.9
subscribe Subscribe to a remote release stream. 1.2
unSubscribe Unsubscribe from all streams of this user. 1.2

Video-related methods

API Description Supported earliest version
currentCamera Specifies the camera device. 1.9
videoProfile Set video stream parameters. 1.9
muteLocalCamera Specifies whether to stop local video collection. 1.2
setDisplayRemoteVideo Set the rendering window and drawing parameters for the remote video. 1.14
setVideoProfile Set video stream or shared stream parameters. 1.11
enableCamera Specify whether to use the camera. 1.13.0

Audio-related methods

API Description Supported earliest version
currentAudioCapture Specifies the microphone device. 1.9
muteLocalMic Specifies whether to stop local audio collection. 1.2
muteRemoteAudioPlaying Specifies whether to stop playing remote audio streams. 1.12.2
muteAllRemoteAudioPlaying Specifies whether to stop playback of all audio streams at the remote end. 1.12.2
setAudioVolume Set the volume of the subscription user. 1.13.0
getAudioVolume Gets the volume of the subscribed user. 1.13.0
enableAudioVolumeIndicator Sets the receive volume value callback. 1.13.0
startAudioMixing Start playing music files. 1.16.0
stopAudioMixing Stop playing music files. 1.16.0
pauseAudioMixing Pause playing the music file. 1.16.0
resumeAudioMixing Resume playback of music files. 1.16.0
adjustAudioMixingVolume Adjust the volume of the accompaniment. 1.16.0
setAudioMixingPosition Sets the playback location of the music file. 1.16.0
getAudioMixingDuration Gets the duration of the music file. 1.16.0
getAudioMixingCurrentPosition Gets the music file playback progress. 1.16.0
setAudioOutput Set the audio playback device. 1.16.0

Preview Port

API Description Supported earliest version
startPreview Preview the local camera. 1.2
stopPreview End preview of the local camera. 1.2
enableHighDefinitionPreview Specify whether to enable HD preview. 1.12.1

Remote user query interface

API Description Supported earliest version
getUserList Get the current room online user. 1.9
getUserInfo Queries the details about a user. 1.9

Other operations

API Description Supported earliest version
on Subscribe to events. 1.2
off Unsubscribe from an event. 1.2
setExternalMediaTrack Set external input audio and video stream replacement. 1.12.1

Details

  • isSupport: checks whether the browser supports the Web SDK.
    aliWebrtc.isSupport(option).then(re =>{
        console.log(re)
    }).catch(error => {
        console.log(error)
    })
    Parameter description
    Parameter Type Description
    option isReceiveOnly Boolean Indicates whether the subscription mode is pure. Valid values:
    • true: The weekly report subscription feature is enabled.
    • false: The Enterprise Edition transit router does not automatically advertise routes to the VBR.
    isDebug Boolean Indicates whether this is in local debugging mode. Valid values:
    • true: The weekly report subscription feature is enabled.
    • false: The Enterprise Edition transit router does not automatically advertise routes to the VBR.
    customPlay Boolean Indicates whether the playback mode is custom. Valid values:
    • true: The weekly report subscription feature is enabled.
    • false: The Enterprise Edition transit router does not automatically advertise routes to the VBR.
    Note After customPlay is set, when the subscription changes, the setDisplayRemoteVideo, muteRemoteAudioPlaying, muteAllRemoteAudioPlaying, setAudioVolume, and getAudioVolume interfaces become invalid in response to onMediaStreamUpdate messages.

    The online environment must use the HTTPS protocol. You can add {isDebug: true} parameters for localhost (local host) debugging to skip HTTPS detection.

    Notice
    1.11 version:
    • Added the parameter {channelProfile: 2} to check whether the browser supports the low-latency interactive live mode. The default parameter {channelProfile: 0} to check whether the browser supports the communication mode.
    • Before instantiation, call this interface.
    1.12 and later versions:
    • You do not need to set relevant channel information.
    • It is no longer a static method.
    • Call this interface before adding a channel after instantiation.
    • Cancel parameter {channelProfile: 0} and {channelProfile: 2}.

    Response parameters

    Parameter Type Description
    audioDevice Boolean Specifies whether the audio device is available. Valid values:
    • true: The weekly report subscription feature is enabled.
    • false: The weekly report subscription feature is disabled.
    browser String The name of the browser.
    browser_version String The version of the browser.
    isSupported Boolean Supports webRTC. Valid values:
    • true: The weekly report subscription feature is enabled.
    • false: The weekly report subscription feature is disabled.
    message String The error message returned.
    supportH264 Boolean Supports H264. Valid values:
    • true: The weekly report subscription feature is enabled.
    • false: The weekly report subscription feature is disabled.
    supportScreenShare Boolean Supports screen sharing. Valid values:
    • true: The weekly report subscription feature is enabled.
    • false: The weekly report subscription feature is disabled.
    supportMixBackgroundAudio Boolean Supports screen sound sharing. Valid values:
    • true: The weekly report subscription feature is enabled.
    • false: The weekly report subscription feature is disabled.
    videoDevice Boolean Whether the camera is available. Valid values:
    • true: The weekly report subscription feature is enabled.
    • false: The weekly report subscription feature is disabled.
  • getDevices: obtains device information and returns the camera and audio device. If the external device cannot obtain the device information after plugging and unplugging, please try restarting the computer.
    aliWebrtc.getDevices().then((re)=>{
    }).catch((error)=>{ 
      console.log(error.message)
    });
  • getAvailableResolutions: obtains the array information of supported resolutions.
    aliWebrtc.getAvailableResolutions(deviceId).then((re)=>{
    }).catch((error)=>{ 
      console.log(error.message)
    });
    Parameter description
    Parameter Type Description
    deviceId String The ID of the camera.
  • isSupportScreenShare: Supports screen sharing.
    aliWebrtc.isSupportScreenShare();
  • setChannelProfile: Set the channel mode.
    aliWebrtc.setChannelProfile(channelProfile);
    Parameter description
    Parameter Type Description
    channelProfile Number Channel mode. Valid values:
    • 0 (default): Normal mode.
    • 1: interaction mode.
    • 2: low-latency interactive live streaming mode.
  • setClientRole: specifies a role.
    aliWebrtc.setClientRole(role);
    Parameter description
    Parameter Type Description
    role Number The type of the role. Valid values:
    • 0 (default): interactive identity.
    • 1: Audience.
  • setAudioOnlyMode: specifies whether to set the audio-only mode.
    aliWebrtc.setAudioOnlyMode(audioOnly);
    Parameter description
    Parameter Type Description
    audioOnly Boolean Specifies whether to enable the audio-only mode. Valid values:
    • true: The weekly report subscription feature is enabled.
    • false: The Enterprise Edition transit router does not automatically advertise routes to the VBR.
    Notice You need to call the isSupport operation before you call it. After the audio-only mode is set, the camera can no longer be detected when isSupport is called. Local preview cannot be performed after joining a channel. Push-pull streams can only be audio streams.
  • dispose: releases the instance.
    aliWebrtc.dispose();
    Note When you execute this function to release an instance, the leaveChannel is called internally by the function. Therefore, you do not need to execute additional leaveChannel to exit the channel.
  • joinChannel: joins a channel.
    aliWebrtc.joinChannel({
        userid, // User ID
        channel, // Channel
        appid, // Application ID
        nonce, // Random code
        timestamp, // The timestamp.
        gslb, // The gslb service address.
        token, // The token.
    },displayName).then(()=>{
        // The membership is successful.
    } ,(error)=>{
        // If the membership fails, the error content is printed. You can see the cause of the failure.
        console.log(error.message);
    });
    Parameter description
    Parameter Type Description
    authInfo userid String The ID of the user.
    channel String Channel.
    appid String The ID of the application.
    nonce String Random code.
    timestamp String Timestamp.
    token String The token.
    gslb Array gslb(Global Server Load Balancing) service address.
    displayName String The username.
  • leaveChannel: leaves the channel.
    aliWebrtc.leaveChannel().then(()=>{
    } ,(error)=>{
        console.log(error.message);
    });
  • configLocalAudioPublish: specifies whether to allow audio streams to be published.
    aliWebrtc.configLocalAudioPublish=enable;
    Parameter description
    Parameter Type Description
    enable Boolean Specifies whether to allow audio streams to be published. Valid values:
    • true (default): Yes.
    • false: The weekly report subscription feature is disabled.
    Notice You need to call the publish to take effect.
  • configLocalCameraPublish: specifies whether to allow the camera stream to be published.
    aliWebrtc.configLocalCameraPublish=enable;
    Parameter description
    Parameter Type Description
    enable Boolean Specifies whether to allow the camera stream to be published. Valid values:
    • true (default): Yes.
    • false: The weekly report subscription feature is disabled.
    Notice You need to call the publish for stream ingest before the setting takes effect.
  • configLocalScreenPublish: specifies whether to allow publishing screen sharing streams.
    aliWebrtc.configLocalScreenPublish=enable;
    Parameter description
    Parameter Type Description
    enable Boolean Specifies whether to allow publishing screen sharing streams. Valid values:
    • true: The weekly report subscription feature is enabled.
    • false: The Enterprise Edition transit router does not automatically advertise routes to the VBR.
    Notice You need to call the publish for stream ingest before the setting takes effect.
  • publish: publishes a local video stream.
    aliWebrtc.publish().then(()=>{
    } ,(error)=>{
        console.log(error.message);
    });

    Web SDKs can only push big streams.

    Notice You need to call this operation after the channel is successfully added. If you want to subscribe to a local stream, call the publish operation to publish the local stream. The onPublisher event is received.
  • unPublish: ends publishing the local stream. When you unpublish the local stream, the remote receives the onUnPublisher event.
    aliWebrtc.unPublish().then(()=>{
    } ,(error)=>{
        console.log(error.message);
    });
    Notice The 1.14 version starts to cancel this interface. We recommend that you call the publish interface after you set config.
  • configRemoteAudio: specifies whether to subscribe to remote audio streams.
    aliWebrtc.configRemoteAudio(userId,enable);
    Parameter description
    Parameter Type Description
    userId String The ID of the user.
    enable Boolean Specifies whether to subscribe to remote audio streams. Valid values:
    • true (default): Yes.
    • false: The weekly report subscription feature is disabled.
    Notice You must call subscribe before the settings take effect.
  • configRemoteCameraTrack: specifies whether to subscribe to remote camera streams.
    
    aliWebrtc.configRemoteCameraTrack(userId,preferMaster,enable);
    Parameter description
    Parameter Type Description
    userId String The ID of the user.
    preferMaster Boolean Subscribe to a major stream or a minor stream first. Valid values:
    • true (default): subscribes to a large stream.
    • false: Subscribe to small streams.
    enable Boolean Specifies whether to subscribe to the remote camera stream. Valid values:
    • true: The weekly report subscription feature is enabled.
    • false: The Enterprise Edition transit router does not automatically advertise routes to the VBR.

    Camera streams contain large streams and small streams, with higher resolution for large streams and lower resolution for small streams.

    Notice You must call subscribe before the settings take effect.
  • configRemoteScreenTrack: specifies whether to subscribe to the remote screen stream.
    aliWebrtc.configRemoteScreenTrack(userId,enable);
    Parameter description
    Parameter Type Description
    userId String The ID of the user.
    enable Boolean Specifies whether to subscribe to the remote screen stream. Valid values:
    • true: The weekly report subscription feature is enabled.
    • false: The Enterprise Edition transit router does not automatically advertise routes to the VBR.
    Notice You must call subscribe before the settings take effect.
  • subscribe: subscribes to a remote release stream.
    aliWebrtc.subscribe(userId).then((userId)=>{
    },(error)=>{
        console.log(error.message);
    });
    Parameter description
    Parameter Type Description
    userId String The ID of the user.

    You can use the subscirbe method to subscribe to remote streams. By default, you can subscribe to camera streams and audio streams. You can set up subscription content by calling configRemoteAudio, configRemoteCameraTrack, and configRemoteScreenTrack.

  • unSubscribe: unsubscribes all streams of the user.
    aliWebrtc.unSubscribe(userId).then(() => {
    },(error)=>{
        console.log(error.message);
    });
    Parameter description
    Parameter Type Description
    userId String The ID of the user.
    Notice The 1.14 version starts to cancel this interface. We recommend that you call the subscribe interface after you set config.
  • currentCamera: specifies the camera device.
    // The pc side.
    aliWebrtc.currentCamera = {
      deviceId: deviceId
    };
    // The front camera is enabled when the user is specified and the rear camera is enabled when the environment is specified.
    aliWebrtc.currentCamera = {
      facingMode:"user"
    };
    Parameter description
    Parameter Type Description
    deviceId String The ID of the camera.
    Notice Hot switchover is not supported. You need to set this parameter before preview and stream ingest.
  • videoProfile: sets video stream parameters.
    aliWebrtc.videoProfile = { 
      frameRate:20,
      width: 640,
      height: 480
    };
    Parameter description
    Parameter Type Description
    frameRate int The frame rate. Valid values: 5 to 30. The default value is 15.
    width int The width of the video. The default value is 640.
    height int The height of the device. The default value is 480.

    The specified resolution needs to be returned by the call getAvailableResolutions before the call publish takes effect. If the set resolution is not appropriate, the system will automatically adjust.

    Notice The SDK of version 1.14 cancels this operation. Use setVideoProfile.
  • muteLocalCamera: whether to stop local video collection.
    aliWebrtc.muteLocalCamera(true);
    Parameter description
    Parameter Type Description
    mute Boolean Specifies whether to stop local video collection. Valid values:
    • true (default): stops local video collection.
    • false: does not stop local video collection.

    Return result

    A value of true indicates that the call was successful. A value of false indicates that the call failed.

    Notice 1.10 or later. This operation adds a return value. This interface needs to be valid in the stream ingest state.
  • setDisplayRemoteVideo: Set the rendering window and drawing parameters for the remote video.
    aliWebrtc.setDisplayRemoteVideo(
        userId, // User ID
        video, // The video element used to display the stream object in html
        1 // 1 indicates the camera stream (large stream and small stream), and 2 indicates the screen sharing stream.
    )
    Notice
    • Audio streams from 1.10.0 to versions earlier than 1.14.0 do not need to set the view, and can be automatically played after subscription.
    • An audio stream of version 1.14.0 or later must have a video that plays a video. The specific policies are as follows.
      • Only the view of the camera is set while subscribing to the audio stream. Audio can be played, and the audio stream plays following the view of the camera.
      • Only the view of the screen sharing stream is set while subscribing to the audio stream. Audio can be played, and the audio stream plays following the view of the screen sharing.
      • Set the view of the camera and screen sharing stream while subscribing to the audio stream. The audio can be played, and the audio stream plays following the view of the camera.
      • The audio cannot be played without setting the view while subscribing to the audio stream.
    • The safari browser audio is played by default in the background after it is subscribed.
  • setVideoProfile: Set camera or screen sharing parameters.
    aliWebrtc.setVideoProfile({ 
          width,
          height,
          frameRate,
        },type);
    Parameter description
    Parameter Type Description
    config width Number The width of the remote videos. Valid values:
    • Camera: 640 (default).
    • Screen sharing: 960 (default).
    height Number The height of the remote videos. Valid values:
    • Camera: 480 (default).
    • Screen sharing: 540 (default).
    frameRate Number The frame rate of the transcoded stream. Valid values: 5 to 30. Valid values:
    • Camera: 15 (default).
    • Screen sharing: 10 (default).
    maxBitrate Number The maximum bitrate. Valid values:
    • Camera: 500000 (default).
    • Screen sharing: 1500000 (default).
    Notice Version 1.13.2 has deleted this parameter. The SDK automatically sets the maximum bitrate based on the specified resolution and frame rate. If you call setVideoProfile in a version earlier than 1.13.2, you must configure this parameter.
    type Number Specifies the type. Valid values:
    • 1: Camera.
    • 2: Screen sharing.
    Notice Screen sharing definition is related to network quality and device performance, rather than the higher the resolution set, the clearer the display. This interface needs to be republished after it is set.
  • enableCamera: specifies whether to use the camera.
    aliWebrtc.enableCamera = enable;
    Parameter description
    Parameter Type Description
    enable Boolean Specify whether the camera is allowed. Valid values:
    • true: RAM users can change their passwords. This is the default value.
    • false: Log Service is not allowed to send text messages to the phone number.
    Notice This operation needs to be called before isSupport. After this operation is set, isSupport will no longer detect cameras.
  • currentAudioCapture: specifies a microphone device.
    aliWebrtc.currentAudioCapture = {
      deviceId: deviceId
    };
    Parameter description
    Parameter Type Description
    deviceId String The ID of the microphone.
  • muteLocalMic: specifies whether to stop local audio collection.
    aliWebrtc.muteLocalMic(true, true);
    Parameter description
    Parameter Type Description
    mute Boolean Specifies whether to stop local audio collection. Valid values:
    • true (default): stops local audio collection.
    • false: does not stop local audio collection.
    isRemember Boolean Whether to remember the status (stop streaming and then re-ingest using the previous audio collection configuration). Valid values:
    • true: Remember.
    • false (default): Do not remember.

    Return result

    A value of true indicates that the call was successful. A value of false indicates that the call failed.

    Note 1.10 or later. This operation adds a return value. This interface needs to be valid in the stream ingest state.
  • muteRemoteAudioPlaying: specifies whether to stop playing the remote audio stream.
    aliWebrtc.muteRemoteAudioPlaying(userId, muted);
    Parameter description
    Parameter Type Description
    userId String The ID of the user.
    muted Boolean Specifies whether to enable mute. Valid values:
    • true: enables TDE.
    • false: Dynamic indexing is disabled. This is the default value.
  • muteAllRemoteAudioPlaying: specifies whether to stop playback of all audio streams at the remote end.
    aliWebrtc.muteAllRemoteAudioPlaying(muted);
    Parameter description
    Parameter Type Description
    muted Boolean Specifies whether to enable full mute. Valid values:
    • true: enables TDE.
    • false: Dynamic indexing is disabled. This is the default value.
  • setAudioVolume: specifies the volume of the subscription user.
    aliWebrtc.setAudioVolume (userId, volume);
    Parameter description
    Parameter Type Description
    userId String The ID of the user.
    volume Number The volume value. Valid values:[0,1].

    Return result

    A value of true indicates that the call was successful. A value of false indicates that the call failed.

    Notice
    • This interface does not conflict with the silent interface.
    • This port is not supported on ios devices.
  • getAudioVolume: obtains the volume of subscribed users.
    aliWebrtc.getAudioVolume(userId);
    Parameter description
    Parameter Type Description
    userId String The ID of the user.

    Response parameters

    Parameter Type Description
    volume Number The volume value. Valid values:[0,1].
  • enableAudioVolumeIndicator: sets the callback for receiving the audio volume value.
    aliWebrtc.enableAudioVolumeIndicator = enable;
    Parameter description
    Parameter Type Description
    enable Boolean Specifies whether to receive audio volume value callbacks. Valid values:
    • true: receives
    • false: does not receive data. This is the default value.
  • startPreview: previews the local camera.
    aliWebrtc.startPreview(
        video // The video element in html
    ).then(()=>{
    }).catch((error) => {
        // The preview failed.
    });

    Play by using the video tag.

  • stopPreview: ends the preview of the local camera.
    aliWebrtc.stopPreview().then(()=>{
    }).catch((error) => {
        // Failed to end the preview.
    });
  • enableHighDefinitionPreview: Set the HD preview interface.
    aliWebrtc.enableHighDefinitionPreview(enable);
    Parameter description
    Parameter Type Description
    enable Boolean Specifies whether to enable high-definition preview. Valid values:
    • true
    • false: BFD is disabled.
  • getUserList: obtains the online user of the current room.
    aliWebrtc.getUserList();
    Parameter description
    Parameter Type Description
    displayName String The name of the user.
    userId String The ID of the user.
    muteAudioPlaying Boolean Specifies whether to set mute. Valid values:
    • true: The weekly report subscription feature is enabled.
    • false: The weekly report subscription feature is disabled.
    streamConfigs - Array An array of audio and video streams.
    label String The stream label.
    state String The status of the stream. Valid values:
    • active: The stream is available.
    • inactive: The stream is unavailable.
    subscribed Boolean Specifies whether to subscribe to remote users. Valid values:
    • true: The weekly report subscription feature is enabled.
    • false: The weekly report subscription feature is disabled.
    type String The type of the audio or video. Valid values:
    • audio: audio only
    • video: video
    Return result

    Returns the online user list information of all ingest streams in the current room.

  • getUserInfo: obtains user information.
    aliWebrtc.getUserInfo(userId);
    Parameter description
    Parameter Type Description
    displayName String The name of the user.
    userId String The ID of the user.
    muteAudioPlaying Boolean Specifies whether to set mute. Valid values:
    • true: The weekly report subscription feature is enabled.
    • false: The weekly report subscription feature is disabled.
    streamConfigs - Array An array of audio and video streams.
    label String The stream label.
    state String The status of the stream. Valid values:
    • active: The stream is available.
    • inactive: The stream is unavailable.
    subscribed Boolean Specifies whether to subscribe to remote users. Valid values:
    • true: The weekly report subscription feature is enabled.
    • false: The weekly report subscription feature is disabled.
    type String The type of the audio or video. Valid values:
    • audio: audio only
    • video: video
  • on: subscribes to events.
    on(name, handler)
    Parameter description
    Parameter Type Description
    name String The name of the event.
    handler String The method used to handle the event.
  • off: unsubscribes from the event.
    off(name, handler)
    Parameter description
    Parameter Type Description
    name String The name of the event.
    handler String The method used to handle the event.
  • setExternalMediaTrack: Set external input.
    aliWebrtc.setExternalMediaTrack(track, type);
    Parameter description
    Parameter Type Description
    track MediaStreamTrack The type of the media stream. Valid values:
    • audiotrack: the type of the incoming audio stream.
    • videotrack: the type of the incoming video stream.
    type Number The type of the stream to replace. Valid values:
    • 0: audio stream.
    • 1: video stream.
    • 2: Screen sharing stream.
    Note
    • The external input video resolution is the resolution of the incoming media stream, which is not affected by the setVideoProfile port settings.
    • Replace the microphone with audiotrack, and replace the camera or screen share with videotrack.
    • You can set an external audio or video stream setExternalMediaTrack the port is not in the stream ingest state.
    • If the setExternalMediaTrack interface wants to cancel the setting of external audio and video streams, you can track null, which needs to be set when the stream is not ingested.
    • You need to reset the setExternalMediaTrack port after it cancels stream ingest.
  • startAudioMixing: starts playing music files.
    aliWebrtc.startAudioMixing({filePath: filePath}, (err)=> {
        if(err) {
          // Failed to open the playback music file.
      }else {
          // The playback of the music file is enabled.
      }
    })
    Parameter description
    Parameter Type Description
    options - Object option.
    filePath String The file address. This parameter is required.
    cacheResource Boolean Specifies whether to cache. Default value: true.
    playTime Number The start playback position (in milliseconds). Default value: 0.
    callback Function The callback function.
  • stopAudioMixing: Stop playing music files.
    aliWebrtc.stopAudioMixing((err)=> {
        if(err) {
          // Failed to stop playing the music file.
      }else {
          // The music file is stopped.
      }
    })
    Parameter description
    Parameter Type Description
    callback Function The callback function.
  • pauseAudioMixing: Pause the music file.
    aliWebrtc.pauseAudioMixing((err)=> {
        if(err) {
          // Failed to pause playing the music file.
      }else {
          // The music file is paused.
      }
    })
    Parameter description
    Parameter Type Description
    callback Function Callback function
  • resumeAudioMixing: Resume playback of music files.
    aliWebrtc.resumeAudioMixing((err)=> {
        if(err) {
          // Failed to resume playing the music file.
      }else {
          // The music file is resumed.
      }
    })
    Parameter description
    Parameter Type Description
    callback Function The callback function.
  • adjustAudioMixingVolume: Adjust the accompaniment volume.
    aliWebrtc.adjustAudioMixingVolume(volume)
    Parameter description
    Parameter Type Description
    volume Number Accompaniment volume:[0,100].
  • setAudioMixingPosition: Sets the playback location of the music file.
    aliWebrtc.setAudioMixingPosition(positioin, (err)=> {
        if(err) {
          // Failed to set the playback position of the audio file of the music file.
      }else {
          // Set the playback position of the audio file of the music file.
      }
    })
    Parameter description
    Parameter Type Description
    position Number The location of the accompaniment. Unit: milliseconds.
    callback Function The callback function.
  • getAudioMixingDuration: Obtains the duration of the music file.
    aliWebrtc.getAudioMixingDuration()
    Parameter description
    Response parameters Type Description
    duration Number The total duration. Unit: milliseconds.
  • getAudioMixingCurrentPosition: Obtains the music file playback progress.
    aliWebrtc.getAudioMixingCurrentPosition()
    Parameter description
    Response parameters Type Description
    position Number The current playback progress. Unit: milliseconds.
  • setAudioOutput: specifies an audio playback device.
    aliWebrtc.setAudioOutput(deviceId).then(()=>{
        // The setting is successful.
    }).catch(()=> {
        // The setting failed.
    })
    Parameter description
    Parameter Type Description
    deviceId String The ID of the speaker device, which can be obtained by getDevices.