Skip to main content
Version: 2.0.x

Change Input/Output Audio Device - iOS

During the meeting at any point a participant wishes to switch his/her audio device, it can be done using the below mentioned methods.

Changing Input/Output Audio Device​

getMics()​

  • The getMics() method will return an array of tuples, where each tuple consists of two elements deviceName and deviceType.

  • returns [deviceName: String, deviceType: String]

Example​

let devices = meeting.getMics()
for device in devices {
print(device.deviceName) //sample output [("Speaker","Speaker"), ("iPhone Microphone", "Receiver")]
}

changeMic()​

  • Participant can change the audio device using changeMic(selectedDevice: String) method of Meeting classs

Example​

func changeAudioDevice(device: String) {
changeMic(selectedDevice: "Speaker") //output will be changed to speaker
}
caution

selectedDevice string should only be from the deviceName that you get from the returned array of getMics().

Events​

onMicChanged - Changing Mic will trigger onMicChanged event.

extension MeetingViewController: MeetingEventListener {

/// Mic is Changed
/// - Parameter selectedDevice: String
func onMicChanged(selectedDevice: String) {

print("Mic Changed to: \(selectedDevice)") //example: Mic changed to Speaker

print("Available Devices:")

let devices = self.meeting?.getMics() ?? []
for device in devices {
print(device.deviceName)
}
}
}

Sample output

Mic changed to Speaker
Available Devices:
Speaker
iPhone Microphone
Headphones

Changing Camera Input Device​

switchWebcam()​

  • By using switchWebcam() function, a participant can stream from front / rear camera during the meeting.

Example​

/// keep track of camera position
private var cameraPosition = CameraPosition.front

@IBAction func cameraButtonTapped(_ sender: Any) {
cameraPosition.toggle()

// switch camera to front/back
// Values: .front, .back
self.meeting?.switchWebcam(position: cameraPosition)
}

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