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, similar to the phone calls.
Switch audio focus to another device
void switchAudioOutput(HMSAudioDevice audioDevice)
Types of audio routing supported:
- SPEAKER_PHONE - route audio to device speaker
- EARPIECE - route audio to device earpiece
- WIRED_HEADSET - 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.
void switchAudioOutput(HMSAudioDevice audioDevice) { hmsSDK.switchAudioOutput(audioDevice:audioDevice); }
Adding a listener
Listener is attached to get the updates if a new audio device gets connected to the device such as bluetooth,wired_headset etc.
This method needs to be overriden in the class wherever HMSUpdateListener
is implemented
void onAudioDeviceChanged( {HMSAudioDevice? currentAudioDevice, List<HMSAudioDevice>? availableAudioDevice}) { //currentAudioDevice : audio device to which audio is routed to //availableAudioDevice : other available audio devices }
Get current focussed device
This method will help in getting the device where the current audio output is routed to.
Future<HMSAudioDevice> getCurrentAudioDevice()
Invoke this method get current device type through which audio output is being routed.
Future<HMSAudioDevice> getCurrentAudioDevice() async { return await hmsSDK.getCurrentAudioDevice(); }