Camera Controls - Javascript
Whenever any participant wants to start/stop broadcasting their video to other participant in a meeting, they can simply do it with VideoSDK Meeting.
This guide will provide an overview of how to implement enable, disable and switch webcam features in a meeting.
- Enable Camera - By using
enableWebcam()
function, a participant can publish camera stream to other participants. - Disable Camera - By using
disableWebcam()
function, a participant can stop publishing camera stream to other participants. - Switch Camera - By using
changeWebcam()
function, a participant can stream from front / rear camera during the meeting.This function is only applicable for Mobile devices.
Enable, Disable And Switch Webcam
const onPress = async () => {
// Enable Webcam in Meeting
meeting?.enableWebcam();
// Disable Webcam in Meeting
meeting?.disableWebcam();
// Change Webcam in Meeting
const webcams = await meeting?.getWebcams(); // returns all webcams
const { deviceId, label } = webcams[0];
meeting?.changeWebcam(deviceId);
};
Events
Events associated with enableWebcam()
:
stream-enabled
event will be emitted withstream
object from the event callback, inside that participant object.
Events associated with disableWebcam()
:
stream-disabled
event will be emitted withstream
object from the event callback, inside that participant object.
participant.on("stream-enabled", (stream) => {
if (stream.kind === "video") {
//particiapnt turned on video
//Render Participant video logic here
}
});
participant.on("stream-disabled", (stream) => {
if (stream.kind === "video") {
//particiapnt turned off video
//remove Participant video logic here
}
});
Got a Question? Ask us on discord