Skip to main content
Version: 2.0.x

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.

note

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.

img1

Methods

enableMic()

  • If you wish to turn on the microphone of a participant, you will be calling the enableMic() from the Participant class.

  • When this method is called, the participant whose microphone is requested will receive the onMicRequested event with the participantId of the participant who requested it and two callback functions accept and reject 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 the onMicRequested 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 the Participant class.

  • When this method is called, the participant whose camera is requested will receive the onWebcamRequested event with the participantId of the participant who requested it and two callback functions accept and reject 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 the onWebcamRequested 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 the Participant 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 the Participant class.
  • This will disable the camera of the participant.

Example

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 participant
  • listener: 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 participant
  • listener: MicRequestListener { accept: Method; reject: Method }
Usage
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