Mute / Unmute Mic - iOS
Muting and Unmuting your microphone refers to turning your microphone off and on, respectively.
When you mute your microphone, you prevent any sound from your microphone from being transmitted to other meeting participants, while unmuting it allows others to hear you.
unmuteMic()
-
By using
unmuteMic()
function ofMeeting
class, local participant can publish audio to other participants.- You can call this method when the local participant is not broadcasting any audio to others.
-
Audio stream of the participant can be accessed from the
onStreamEnabled
event ofParticipantEventListener
.
muteMic()
-
By using
muteMic()
function ofMeeting
class, local participant can stop publish audio to other participants. -
You can call this method when the local participant is broadcasting any audio to others.
Example
- Swift
@IBAction func micButtonTapped(_ sender: Any) {
if !micEnabled {
// enable/unmute mic
self.meeting?.unmuteMic()
} else {
// disable/mute mic
self.meeting?.muteMic()
}
}
Events associated with unmuteMic
- Every Participant will receive a callback on
onStreamEnabled()
of theParticipant
withStream
object.
Events associated with muteMic
- Every Participant will receive a callback on
onStreamDisabled()
of theParticipant
withStream
object.
- Swift
extension MeetingViewController: ParticipantEventListener {
//Callback for when the participant starts a stream
func onStreamEnabled(_ stream: MediaStream, forParticipant participant: Participant) {
if stream.kind = .state(value: .audio) {
print("new audio stream enabled")
}
}
//Callback for when the participant stops a stream
func onStreamDisabled(_ stream: MediaStream, forParticipant participant: Participant) {
if stream.kind = .state(value: .audio) {
print("new audio stream disabled")
}
}
}
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