Camera Controls - Android
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​
- Kotlin
- Java
btnWebcam!!.setOnClickListener {
// Toggle participant webcam in meeting
if (webcamEnabled) {
meeting!!.disableWebcam()
} else {
meeting!!.enableWebcam()
}
// 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();
}
// Change Webcam in Meeting
meeting.changeWebcam();
}
});
Events​
Event associated with enableWebcam()
:
- Every Participant will receive a callback on
onStreamEnabled()
of theParticipant
withStream
object.
Event associated with disableWebcam()
:
- Every Participant will receive a callback on
onStreamDisabled()
of theParticipant
withStream
object.
- Kotlin
- Java
meeting!!.localParticipant.addEventListener(object : ParticipantEventListener() {
override fun onStreamEnabled(stream: Stream) {
//
if(stream.getKind().equals("video")){
//participant turned on video
//Render participant video
}
}
override fun onStreamDisabled(stream: Stream) {
//
if(stream.getKind().equals("video")){
//participant turned off video
//remove participant video
}
}
});
participant.addEventListener(new ParticipantEventListener() {
@Override
public void onStreamEnabled(Stream stream) {
//
if(stream.getKind().equals("video")){
//participant turned on video
//Render participant video
}
}
@Override
public void onStreamDisabled(Stream stream) {
//
if(stream.getKind().equals("video")){
//participant turned off video
//remove participant video
}
}
});
Got a Question? Ask us on discord