Toggle Remote Participant Media - iOS
When hosting a meeting, it's important that the host of the meeting should be able to request someone's Mic or Camera to be turned on or should be able to turn them off.
Participant who will be controlling other participant's mic and camera should have permission allow_mod
passed in the token. To know more about permissions visit here.
Before we discuss the methods and events associated with this functionality, here is how the flow would look like.
Methods
enableMic()
-
If you wish to turn on the microphone of a participant, you will be calling the
enableMic()
from theParticipant
class. -
When this method is called, the participant whose microphone is requested will receive the
onMicRequested
event with theparticipantId
of the participant who requested it and two callback functionsaccept
andreject
which should be called based on decision made by the user. -
Example: Meeting is running with Participant A and Participant B. Now Participant A wants to Enable Mic of Participant B, so Participant A will use
enableMic()
function to request Participant B, after that Participant B recieve theonMicRequested
event, from there user can either accept or reject the incoming request.
enableWebcam()
-
If you wish to turn on the camera of a participant, you will be calling the
enableWebcam()
from theParticipant
class. -
When this method is called, the participant whose camera is requested will receive the
onWebcamRequested
event with theparticipantId
of the participant who requested it and two callback functionsaccept
andreject
which should be called based on decision made by the user. -
Example: Meeting is running with Participant A and Participant B. Now Participant A wants to Enable Webcam of Participant B, so Participant A will use
enableWebcam()
function to request Participant B, after that Participant B recieve theonWebcamRequested
event, from there user can either accept or reject the incoming request.
disableMic()
- If you wish to turn off the microphone of a participant, you will be calling the
disableMic()
from theParticipant
class. - This will disable the microphone of the participant.
disableWebcam()
- If you wish to turn off the camera of a participant, you will be calling the
disableWebcam()
from theParticipant
class. - This will disable the camera of the participant.
Example
- Swift
class MeetingViewController {
//Button when tapped will toggle participant's mic
@IBAction func micButtonTapped(_ sender: Any) {
let participant = meeting?.participants.first(where: { $0.id == <participantId> })
//micenabled is a user defined status for participant's mic
if !micenabled {
participant?.enableMic()
} else {
participant?.disableMic()
}
}
//Button when tapped will toggle participant's video
@IBAction func micButtonTapped(_ sender: Any) {
let participant = meeting?.participants.first(where: { $0.id == <participantId> })
//videoenabled is a user defined status for participant's video
if !videoenabled {
participant?.enableWebcam()
} else {
participant?.disableWebcam()
}
}
}
Events
onWebcamRequested
This event will be emitted to the Participant B
when any other Participant A
requests to enable webcam of that participant (Participant B
). This event handler will receieve following two arguments:
participantId
- ParticipantId of the requesting participantlistener
: MicRequestListener { accept: Method; reject: Method }
onMicRequested
This event will be emitted to the Participant B
when any other Participant A
requests to enable mic of that participant (Participant B
). This event handler will receieve following two arguments:
participantId
- ParticipantId of the requesting participantlistener
: MicRequestListener { accept: Method; reject: Method }
Usage
- Swift
extension MeetingViewController: MeetingEventListener {
/// 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()
}
}
API Reference
The API references for all the methods and events utilised in this guide are provided below.
Got a Question? Ask us on discord