Change Input Device - Javascript
During the meeting, at any point, a participant wishing to switch their input audio or video device, can do so using the below-mentioned methods.
This page uses the following asynchronous methods. Refer to their API reference for the errors each Promise may reject with, and handle these rejections appropriately based on your use case.
Changing Audio Input Device
getMics()
-
This method of the Meeting class will provide you with a list of all the available mics, which can be displayed in a dropdown list.
-
It will return an array of objects, which will contain the
deviceIdand thelabelof the audio input device.
changeMic()
- Once you know which device you want to switch the audio input to, you can pass the
deviceIdto this method to change the audio input device.
Example
let meeting;
// Initialize Meeting
meeting = VideoSDK.initMeeting({
// ...
});
let mics;
try {
mics = await meeting?.getMics();
} catch (err) {
console.error("getMics failed:", err);
}
const { deviceId, label } = mics[0];
try {
await meeting?.changeMic(deviceId);
} catch (err) {
console.error("changeMic failed:", err);
}
Getting the Audio Input Device currently in use.
- You can get the audio device that is currently in use in the meeting,using the
selectedMicrophoneDeviceproperty of theMeetingclass.
Example
let meeting;
// Initialize Meeting
meeting = VideoSDK.initMeeting({
// ...
});
// ...
console.log("Currently used Audio Input Device : ", meeting?.selectedMicrophoneDevice);
Changing Camera Input Device
getWebcams()
-
This method of the Meeting class will provide you with a list of all the available cameras, which can be displayed in a dropdown list.
-
This method will return an array of objects which will contain the
deviceIdandlabelof the camera input device.
changeWebcam()
- Once you know which device you want to switch the camera input to, you can pass the
deviceIdto this method to change the camera input device.
Example
let meeting;
// Initialize Meeting
meeting = VideoSDK.initMeeting({
// ...
});
let webcams;
try {
webcams = await meeting?.getWebcams();
} catch (err) {
console.error("getWebcams failed:", err);
}
const { deviceId, label } = webcams[0];
try {
await meeting?.changeWebcam(deviceId);
} catch (err) {
console.error("changeWebcam failed:", err);
}
Getting the Camera Device currently in use.
- You can get the camera device that is currently in use in the meeting, using the
selectedCameraDeviceproperty of theMeetingclass.
Example
let meeting;
// Initialize Meeting
meeting = VideoSDK.initMeeting({
// ...
});
// ...
console.log("Currently used Webcam : ", meeting?.selectedCameraDevice);
API Reference
The API references for all the methods and events utilized in this guide are provided below.
Got a Question? Ask us on discord

