Toggle Participant Media
Control other participant's webcam and mic. For better idea, let's understand this with a real case scenario
Scenario 1 (Online Class) - In this scenario, the lecturer(Local Participant) will control the student's(Other Participant) webcam and mic as per his/her needs.
Scenario 2 (Online Events) - In this scenario, the event hosts will control the audience webcam and mic when someone wants to speak.
This guide will provide an overview of how to control other participant webcam and mic in a meeting.
-
Enable Webcam of Participant - By using
enableWebcam()
function, awebcam-requested
event will trigger on requested participant side.Example : Meeting is running with User A and User B. Now User A wants to Enable Webcam of User B, so User A will use
enableWebcam()
function to request User B, after that User B recieve thewebcam-requested
event, from there user can either accept or reject the incoming request. -
Disable Webcam of Participant - By using
disableWebcam()
function, webcam of that participant will be turned off.Example : User A wants to Disable Webcam of User B, so User A will use
disableWebcam()
function to Disable it without any request. -
Enable Mic of Participant - By using
enableMic()
function, amic-requested
event will trigger on requested participant side.Example : Meeting is running with User A and User B. Now User A wants to Enable Mic of User B, so User A will use
enableMic()
function to request User B, after that User B will receive theMic-requested
event, from there user can either accept or reject the incoming request. -
Disable Mic of Participant - By using
disableMic()
function, Mic of that participant will disable.Example : User A wants to Disable Mic of User B, so User A will use
disableMic()
function to Disable it without any request.
To achieve this feature, you need to pass allow_join
persmission while genearting token for meeting initialization. After that you will be able to access participant media methods.
Request Media Methods
- JavaScript
- React
- ReactNative
- Android
- IOS
- Flutter
const participants = meeting.participants;
const participant = participants.get("<participant-id>");
// This will emit an event called "webcam-requested" to that particular participant
participant.enableWebcam();
// This will directly disable webcam of particular participant
participant.disableWebcam();
// This will emit an event called "mic-requested" to that particular participant
participant.enableMic();
// This will directly disable mic of particular participant
participant.disableMic();
import { useParticipant } from "@videosdk.live/react-sdk";
const { enableWebcam, disableWebcam, enableMic, disableMic } =
useParticipant("<participant-id>");
const onPress = () => {
// This will emit an event called "webcam-requested" to that particular participant
enableWebcam();
// This will directly disable webcam of particular participant
disableWebcam();
// This will emit an event called "mic-requested" to that particular participant
enableMic();
// This will directly disable mic of particular participant
disableMic();
};
import { useParticipant } from "@videosdk.live/react-native-sdk";
const { enableWebcam, disableWebcam, enableMic, disableMic } =
useParticipant("<participant-id>");
const onPress = () => {
// This will emit an event called "webcam-requested" to that particular participant
enableWebcam();
// This will directly disable webcam of particular participant
disableWebcam();
// This will emit an event called "mic-requested" to that particular participant
enableMic();
// This will directly disable mic of particular participant
disableMic();
};
Participant participant = meeting.getParticipants().get("<participant-id>");
// This will emit an event called "onWebcamRequested" to that particular participant
participant.enableWebcam();
// This will directly disable webcam of particular participant
participant.disableWebcam();
// This will emit an event called "onMicRequested" to that particular participant
participant.enableMic();
// This will directly disable mic of particular participant
participant.disableMic();
let participant = meeting?.participants.first(where: { $0.id == <participantId> })
/// Enable/Unmute mic for this participant
participant?.enableMic()
/// Disable/Mute mic for this participant
participant?.disableMic()
/// Enable/Turn on camera for this participant
participant?.enableWebcam()
/// Disable/Turn off camera for this participant
participant?.disableWebcam()
const participants = meeting.participants;
const participant = participants.get("<participant-id>");
// This will emit an event called "webcam-requested" to that particular participant
participant.enableWebcam();
// This will directly disable webcam of particular participant
participant.disableWebcam();
// This will emit an event called "mic-requested" to that particular participant
participant.enableMic();
// This will directly disable mic of particular participant
participant.disableMic();
Manage Requested Media Events
-
webcam-requested - This event will be emitted to the participant
B
when any other participantA
requests to enable webcam of that participantB
. This event handler will receieve following three arguments:accept()
- Callback function to accept the request.reject()
- Callback function to reject the request.
-
mic-requested - This event will be emitted to the participant
B
when any other participantA
requests to enable mic of that participantB
. This event handler will receieve following three arguments:accept()
- Callback function to accept the request.reject()
- Callback function to reject the request.
- JavaScript
- React
- ReactNative
- Android
- IOS
- Flutter
// Handle Webcam Requested
meeting.on("webcam-requested", ({ accept, reject }) {
// callback function to accept the request
accept();
// callback function to reject the request
reject();
}, );
// Handle Mic Requested
meeting.on("mic-requested", ({ accept, reject }) {
// callback function to accept the request
accept();
// callback function to reject the request
reject();
}, );
import { useMeeting } from "@videosdk.live/react-sdk";
const {
/** Methods */
} = useMeeting({
onWebcamRequested: ({ accept, reject }) => {
// callback function to accept the request
accept();
// callback function to reject the request
reject();
},
onMicRequested: ({ accept, reject }) => {
// callback function to accept the request
accept();
// callback function to reject the request
reject();
},
});
import { useMeeting } from "@videosdk.live/react-native-sdk";
const {
/** Methods */
} = useMeeting({
onWebcamRequested: ({ accept, reject }) => {
// callback function to accept the request
accept();
// callback function to reject the request
reject();
},
onMicRequested: ({ accept, reject }) => {
// callback function to accept the request
accept();
// callback function to reject the request
reject();
},
});
new MeetingEventListener() {
@Override
public void onMicRequested(String participantId, MicRequestListener listener) {
// TODO: show dialog before accepting request
listener.accept();
}
@Override
public void onWebcamRequested(String participantId, WebcamRequestListener listener) {
// TODO: show dialog before accepting request
listener.accept();
}
}
/// Called when host requests to turn on the mic/audio
func onMicRequested(participantId: String?, accept: @escaping () -> Void, reject: @escaping () -> Void) {
// callback to accept the request
accept()
// callback to reject the request
reject()
}
/// Called when host requests to turn on the camera/video
func onWebcamRequested(participantId: String?, accept: @escaping () -> Void, reject: @escaping () -> Void) {
// callback to accept the request
accept()
// callback to reject the request
reject()
}
// Handle Webcam Requested
widget.meeting.on("webcam-requested", ({ accept, reject }) {
// callback function to accept the request
accept();
// callback function to reject the request
reject();
}, );
// Handle Mic Requested
widget.meeting.on("mic-requested", ({ accept, reject }) {
// callback function to accept the request
accept();
// callback function to reject the request
reject();
}, );
Got a Question? Ask us on discord