caution
Camera Controls
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
- JavaScript
- React
- ReactNative
- Android
- IOS
- Flutter
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);
};
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);
};
const onPress = () => {
// Enable Webcam in Meeting
meeting?.enableWebcam();
// Disable Webcam in Meeting
meeting?.disableWebcam();
// Change Webcam in Meeting
meeting?.changeWebcam();
};
btnWebcam.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Toggle participant webcam in meeting
if (webcamEnabled) {
meeting.disableWebcam();
} else {
meeting.enableWebcam();
}
}
});
@IBAction func videoButtonTapped(_ sender: Any) {
if !videoEnabled {
// enable webcam/camera
self.meeting?.enableWebcam()
} else {
// disable webcam/camera
self.meeting?.disableWebcam()
}
}
/// keep track of camera position
private var cameraPosition = CameraPosition.front
@IBAction func cameraButtonTapped(_ sender: Any) {
cameraPosition.toggle()
// switch camera to front/back
// Values: .front, .back
self.meeting?.switchWebcam(position: cameraPosition)
}
ElevatedButton(
onPressed: meeting.disableWebcam,
child: Text("disableWebcam"),
),
ElevatedButton(
onPressed: meeting.enableWebcam,
child: Text("enableWebcam"),
),
ElevatedButton(
onPressed: () {
meeting?.changeWebcam("<device-id>")
},
child: Text("changeWebcam"),
),
// changeWebcam() method is coming soon in flutter.
Got a Question? Ask us on discord