Audio Output Routing

Audio Routing can be helpful in the case when user wants to switch output to device other than the default focussed one by SDK.

Switch audio focus to another device

fun switchAudioOutput(audioDevice: AudioDevice)
  • Types of audio routing supported.
  • SPEAKER - route audio to device speaker
  • EARPIECE - route audio to device earpiece
  • WIRED - route audio to connected wired device
  • BLUETOOTH - route audio to connected bluetooth device
  • AUTOMATIC - automatic routing

invoke this method with appropriate option , to switch the output to that device

audioDevice is the [AudioDevice] type through which audio should be routed.

hmsSDK.switchAudioOutput(AudioDevice.SPEAKER_PHONE)

Adding a listener

fun setAudioDeviceChangeListener(audioManagerDeviceChangeListener: AudioManagerDeviceChangeListener)

add a listener to get updates whenever a device is removed or attached to the device. audioManagerDeviceChangeListener - listener to be passed to be able to listen to device updates.

callback methods :

  1. onAudioDeviceChanged - this method is invoked when output device has changed.
  2. onError - this method is invoked when there is an error with switching to output device.
hmsSDK.setAudioDeviceChangeListener(object : HMSAudioManager.AudioManagerDeviceChangeListener { override fun onAudioDeviceChanged( device: HMSAudioManager.AudioDevice?, listOfDevices: MutableSet<HMSAudioManager.AudioDevice>? ) { } override fun onError(error: HMSException?) { HMSLogger.d(TAG, "error : ${error?.description}") } })

Get current focussed device

fun getAudioOutputRouteType() : AudioDevice

invoke this method get current device type through which audio output is being routed.

hmsSDK.getAudioOutputRouteType()

Have a suggestion? Recommend changes ->

Was this helpful?

1234