Skip to main content
Version: 2.0.x

Mute / Unmute Mic - iOS

This feature allows hosts to communicate with each other during the livestream by enabling or disabling their microphones. While only hosts (participants in SEND_AND_RECV mode) can speak, audience members (in RECV_ONLY mode) can listen to the conversation in real time.

unmuteMic()​

  • By using unmuteMic() function of Meeting class, the host can publish their audio to other hosts and audience members.

  • 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 of ParticipantEventListener.

muteMic()​

  • By using muteMic() function of Meeting class, the host can stop publishing their audio to other hosts and audience members.

Example​

Example​

@IBAction func micButtonTapped(_ sender: Any) {
if !micEnabled {
// enable/unmute mic
self.meeting?.unmuteMic()
} else {
// disable/mute mic
self.meeting?.muteMic()
}
}

Events associated with unmuteMic​

Events associated with muteMic​

Audio Permissions​

  • Step 1: Begin by ensuring that your application has audio permission to access user's microphone device. Utilize the getAudioPermissionStatus() method of the VideoSDK class to verify if permissions are granted. If the permissions are not granted, the method will request the required permissions.
note

In case permissions are blocked by the user, the app's permission request dialogue cannot be re-rendered programmatically. In such cases, consider providing guidance to users on manually adjusting their application settings.

let audioPermission = VideoSDK.getAudioPermissionStatus(); // audio permission status

Request Permissions​

  • If permission status is notDetermined, use the getAudioPermission() methods of the VideoSDK class to prompt users to grant access to their devices.

  • Calling the above functions will automatically handle the notDetermined state and prompt the user to grant permission.

class LiveStreamViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()

// UI Setup
setupUI()

// prompt user to grant permission when the app starts
VideoSDK.getAudioPermission()
}

func setupUI() {
// your UI code
}
}

API Reference​

The API references for all the methods and events utilized in this guide are provided below.

Got a Question? Ask us on discord