Audio Output Routing

If you want to give your users option to switch audio between speaker and earpiece, you use Audio Output Routing API. For example, you can implement an in-call speaker button that toggles between speaker and earpiece audio.

Minimum Requirements

  • SDK version 0.5.1

How to switch audio to a particular output device

You call switchAudioOutput method on HMSSDK instance passing in the HMSAudioOutputDevice that you would like to switch audio to. Like below:

// Switch audio to earpiece hmsSDK.switchAudioOutput(to: .earpiece) // Switch audio to speaker hmsSDK.switchAudioOutput(to: .speaker)

Currently, there are only 2 HMSAudioOutputDevices available:

  1. speaker - in-built speaker device
  2. earpiece - in-built earpiece device

Can I switch audio to audio output devices other than speaker and earpiece?

No. Currently in-built speaker and in-built earpiece are the only two supported devices. Although there is getAudioOutputDeviceList method on HMSSDK that you call to get all available audio output devices, but currently it will return just these 2 in-built audio output devices.

let availableAudioOutputDevices = hmsSDK.getAudioOutputDeviceList()

Note: In future getAudioOutputDeviceList may return other available audio devices.

👀 To see an example iOS audio routing implementation using 100ms SDK, checkout our example project.

Have a suggestion? Recommend changes ->

Was this helpful?