Adjust someone's audio locally, this operation doesn't affect other participants' audio
userId
number
Gets the active device ID of the microphone.
Device ID.
Gets the active device of the speaker.
Device ID.
Gets the audio statistic data.
Gets the available microphones.
Microphone list.
Gets the share audio status.
Share audio status.
Gets the available speakers.
Speaker list.
Get the user's volume.
User ID.
Number.
Determines whether the user is muted.
Default undefined
boolean
Determines whether share audio is muted locally. Refers to the audio shared by other participants.
User ID.
Boolean.
Determines whether someone's audio is muted locally.
User ID.
Boolean.
Mutes audio.
userId
is not specified, this will mute self.Default undefined
.
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.
Optional empty value will mute self share audio.
Executed promise.
Mutes someone's audio locally. This operation doesn't affect other participants' audio.
User ID.
''
: Success.Error
: Failure. Details in ErrorTypes.Joins audio by microphone and speaker.
await client.init();
await client.join(topic, signature, username, password);
const stream = client.getMediaStream();
await stream.startAudio();
Safari browser is different:
let audioDecode, audioEncode;
// wait until the encoding and decoding process is ready for the audio
client.on("media-sdk-change", (payload) => {
const { action, type, result } = payload;
if (type === "audio" && result === "success") {
if (action === "encode") {
audioEncode = true;
} else if (action === "decode") {
audioDecode = true;
}
if (audioDecode && audioEncode) {
try {
// start audio automatically in Safari
stream.startAudio({ autoStartAudioInSafari: true });
} catch (err) {
console.warn(err);
}
}
}
});
// Start audio in 'click' callback in Safari
joinAudioButton.addEventListener("click", () => {
if (audioDecode && audioDecode) {
try {
stream.startAudio();
} catch (err) {
console.warn(err);
}
}
});
Executed promise. Following are the possible error reasons:
USER_FORBIDDEN_MICROPHONE
: The user has blocked accesses to the microphone from the SDK. Try to grant the privilege and rejoin the session.Leaves computer audio.
Executed promise.
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.
Example
try{
await stream.subscribeAudioStatisticData();
} catch (error) {
console.log(error);
}
Optional. Object { encode: Boolean, decode: Boolean }
can specify which type of audio to subscribe to.
''
: Success.Error
: Failure. Details in ErrorTypes.Switches the microphone.
const microphones = stream.getMicList();
const microphone = // choose another microphone
await switchMicrophone(microphone.deviceId);
Device ID of the microphone.
Executed promise.
Switches the speaker.
Device ID of the speaker.
Executed promise.
Unmute audio.
userId
is not specified, this will unmute self.// 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');
})
Default undefined
.
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.
Optional empty value will unmute self share audio.
Executed promise.
Unmutes someone's audio locally. This operation doesn't affect other participants' audio.
User ID.
''
: Success.Error
: Failure. Details in ErrorTypes.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);
}
Optional. Object { encode: Boolean, decode: Boolean }
can specify which type of audio to unsubscribe to.
''
: Success.Error
: Failure. Details in ErrorTypes.Approve the control request.
the requesting user ID.
''
: SuccessError
: Failure. Details in ErrorTypes.Control the local camera.
The cmd option.
''
: SuccessError
: Failure. Details in ErrorTypes.Control the far-end camera.
The cmd option.
''
: SuccessError
: Failure. Details in ErrorTypes.Decline the control request.
The requesting user ID.
''
: SuccessError
: Failure. Details in ErrorTypes.Get the capability of the camera on current device
default is active camera id
Get the capability of the far-end camera.
Give up control of far end camera.
The controlling user ID.
''
: SuccessError
: Failure. Details in ErrorTypes.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,
});
}
});
the controlling user ID.
''
: SuccessError
: Failure. Details in ErrorTypes.Determined whether current browser support PTZ function
Cancels the dial out request before it is complete.
Country code.
Phone number.
Executed promise.
Gets phone call status.
Phone call status.
Get supported countries.
Supported phone call countries.
Hangs up the phone. Only used when the current audio was joined by phone.
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:
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.
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);
});
Country code.
Phone number.
Name.
Executed promise.
Determines whether the phone call feature is supported.
Boolean.
Gets the user ID of the received shared content.
Active shared user ID.
Get the share privilege.
Share privilege.
Gets the status of share.
Share status.
Get the list of users who are screen sharing.
shared user list
Determines whether the host locked the share.
Whether screen share is locked.
Whether to use video element to start screen sharing.
boolean
Locks the privilege of screen share. Only the host or manager can share.
// 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')
}
})
Set to true
to lock share, or false
to unlock.
Executed promise.
Pauses screen share.
Executed promise.
Resumes screen share.
Executed promise.
Set the privilege of screen share.
The privilege
Executed promise.
When screen sharing is started, host or manager can determine whether the shared content is broadcast to subsessions.
Executed promise.
Starts screen share.
Required. The canvas which renders the screen share content.
Optional options for screen share.
Executed promise.
Renders the received screen share content.
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();
}
})
Required. The canvas to render the share content.
Required. Active share user ID.
Executed promise.
Stops screen share.
Executed promise.
Stop broadcasting the shared content to subsessions.
Executed promise.
Stops rendering received screen share content.
Executed promise.
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);
}
})
Required. Active share user ID.
Executed promise.
Switch camera for sharing.
Camera ID.
Executed promise.
Sets the dimension of the canvas rendering the received share content.
Canvas width.
Canvas height.
Executed promise.
Adjusts the coordinates and dimension of the rendered video.
Required. The canvas to render the video.
Required. The user ID which to render the video.
Required. Video width.
Required. Video height.
Required. Coordinate x of video.
Required. Coordinate y of video.
Optional. Must be paired with renderVideo
.
''
: Success.Error
: Failure. Details in ErrorTypes.Clears the canvas.
Required. The canvas to render the video.
Optional. Underlying color when video is stopped. Default is transparent.
''
: Success.Error
: Failure. Details in ErrorTypes.Tries to enable hardware acceleration.
boolean or specific encode or decode.
Promise<boolean> true: success, false: fail.
Gets the recently active camera devices ID.
''
: 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.Gets the recently active video ID.
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
navigator.mediaDevices
object and maintained by the stream object.CameraDevice
object with all properties set to empty strings.[]
: 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.Get network quality,only the network quality of users who start video is meaningful.
optional, default is current user
Gets the dimension of received video.
Received video dimension.
Gets the maximum quality of video.
Highest video quality. See the definition VideoQuality
Gets the video statistic data.
Video statistic date. VideoQosData
Gets the status of the virtual backgrounds.
Status of the virtual background. VirtualBackgroundStatus
Gets the isCameraTaken
flag status.
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.Gets the isCaptureForbidden
flag status.
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.Gets the isCapturingVideo
flag status.
true
: The stream object is capturing video.false
: The stream object is not capturing video or the video flag is false
in media constraints.Whether to use video element to render self-view.
Boolean.
Determines whether HD video is supported.
Whether the current account supports sending 720p video.
Determines whether the browser can support multiple videos.
Whether the current platform supports multiple videos.
Determines whether the current platform supports virtual backgrounds.
Whether the current platform supports virtual backgrounds.
Mirrors current video.
''
: Success.Error
: Failure. Details in ErrorTypes.Previews the virtual background. If the video is on, preview virtual background applies to the current video.
Virtual background image.
Cropped to 16/9 aspect ratio. Default is false.
''
: Success.Error
: Failure. Details in ErrorTypes.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);
}
Required. The canvas to render the video.
Required. The user ID which to render the video.
Required. Video width.
Required. Video height.
** Note **
The origin of the coordinates is in the lower left corner of the canvas.
Required. Coordinate x of video.
Required. Coordinate y of video.
Required. Video quality: 90p, 180p, 360p, 720p. Currently supports up to 720p.
Optional. Used to render the same video on different coordinates of the canvas.
''
: SuccessError
: Failure. Details in ErrorTypes.Starts capturing video from a specified camera.
Note
Example
try {
await stream.startVideo();
} catch (error) {
console.log(error);
}
''
: SuccessError
: 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.Stops previewing the virtual background.
''
: Success.Error
: Failure. Details in ErrorTypes.Stops rendering the video.
Example
try{
await stream.stopRenderVideo();
} catch (error) {
console.log(error);
}
Required. The canvas to render the video.
Required. The user ID which to render the video.
Optional. Must be paired with renderVideo
.
Optional. Underlying color when video is stopped. Default is transparent.
Optional. Determines whether to keep the last frame when stopping the video.
''
: Success.Error
: Failure. Details in ErrorTypes.Stops current video capturing.
Example
try{
await stream.stopVideo();
} catch (error) {
console.log(error);
}
''
: SuccessError
: 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.
Example
try{
await stream.subscribeVideoStatisticData();
} catch (error) {
console.log(error);
}
Optional. Object { encode: Boolean, decode: Boolean }
can specify which type of audio should be subscribed to.
''
: Success.Error
: Failure. Details in ErrorTypes.Changes camera device for capturing video.
Note
Example
try{
const cameras = stream.getCameraList();
const camera = // choose your camera
await stream.switchCamera(camera.deviceId);
} catch (error) {
console.log(error);
}
Camera device ID.
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);
}
Optional. Object { encode: Boolean, decode: Boolean }
can specify which type of audio should be unsubscribed to.
''
: Success.Error
: Failure. Details in ErrorTypes.Updates the dimension of the canvas. Used to update the width or height when the styled width or height changed.
Required. The canvas to render the video.
Required. Canvas's new width.
Updates the virtual background image.
Virtual background image.
Cropped to 16/9 aspect ratio. Default is false.
''
: Success.Error
: Failure. Details in ErrorTypes.
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.