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.
- 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:
- speaker - in-built speaker device
- 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.