Manage in-meeting audio settings

View as Markdown

Through the SDK, let individual users manage their own various audio settings and control their in-meeting audio state. Additionally, meeting hosts can manage settings for other users and for the meeting as a whole.

Most of the functionality is done through MobileRTCMeetingService, which can be accessed after the participant joins the meeting.

guard let meetingService = MobileRTC.shared().getMeetingService() else { return }

Connect to meeting audio

After joining a meeting, the SDK instance may not be automatically connected to the meeting audio. To send or receive audio in the meeting, the SDK must connect to the audio channel.

if meetingService.myAudioType() == .none && meetingService.isSupportedVOIP() {
    meetingService.connectMyAudio(true)
}

Once connected, the SDK can also disconnect from the audio channel. After disconnecting from audio, the SDK will no longer be able to send or receive audio until it reconnects.

if meetingService.myAudioType() != .none {
    meetingService.connectMyAudio(false)
}

You can also check whether a specific user is connected to the audio channel by checking their audio type against MobileRTCAudioType constants. MobileRTCAudioType_VoIP means that they're connected to the meeting audio channel, MobileRTCAudioType_Telephony means that they're using audio from their phone, and MobileRTCAudioType_None means that they are not connected.

// To get the local user's audioType
guard let meetingService = MobileRTC.shared().getMeetingService() else { return }
meetingService.myAudioType()

// To get other user's (MobileRTCMeetingUserInfo) audioType
userInfo.audioStatus?.audioType

Switch the audio output

To switch between the earpiece and speaker, call switchMyAudioSource.

meetingService.switchMyAudioSource()

Mute or unmute audio

Mute the local user's audio with muteMyAudio. Additionally, if the meeting supports participants unmuting their own audio, do that by using the muteMyAudio method.

meetingService.muteMyAudio(true)

if meetingService.canUnmuteMyAudio() {
    meetingService.muteMyAudio(false)
}

If the current user is the meeting's host, they can mute the other meeting participants' audio. For privacy reasons, the host cannot force another participant to unmute their audio. If the user is currently muted, this code asks them to unmute their microphone.

meetingService.muteUserAudio(true, withUID: userID)

The host can also mute all attendees' audio simultaneously.

// Host/co-host to mute all
meetingService.muteAllUserAudio(false)

/*
 Host/co-host to ask to unmute all - This will trigger the MobileRTCMeetingServiceDelegate's onSinkMeetingAudioRequestUnmuteByHost callback
*/
meetingService.muteAllUserAudio(true)

The meeting settings of the current meeting can also be updated to mute by default upon joining the meeting. Note that unless the meeting explicitly prevents participants from unmuting themselves, this behavior can be overridden by any client instances.

guard let meetingSettings = MobileRTC.shared().getMeetingSettings() else { return }
meetingSettings.setMuteAudioWhenJoinMeeting(true)

Stop incoming audio

The SDK supports stopping your device from receiving audio while staying connected to the audio channel. This allows your microphone to continue capturing audio and sending it to other meeting participants and will prevent your device from playing any audio produced by others.

meetingService.stopIncomingAudio(!meetingService.isIncomingAudioStopped())