selectAudioDevice method
Changes selection of the current active audio device.
Before a call. This API does not activate audioDevice
, it just selects
the audio device that will be activated.
During a call. If the audioDevice
is available, the API activates
audioDevice
.
Active audio device can be later changed if a new device is connected. In this case VIAudioDeviceManager.onAudioDeviceChanged will be triggered.
For iOS. If the application uses CallKit, you should take into consideration:
- In case if Bluetooth headset is connected, audio routing depends on where a call is answered (from the Bluetooth headset or from the phone screen). Bluetooth hedset will be activated only in case if a call is answered via Bluetooth hedset controls. In other cases the audio will be played via Earpiece.
- Audio is always routed to Bluetooth headset only if the user selects "Bluetooth headset" as Call Audio Routing in the phone preferences.
- If audio device is selected before CallKit activates the audio session, it is required to reselect this audio device after CXProviderDelegate.didActivateAudioSession is called. Otherwise audio routing may be reset to default.
audioDevice
- Audio device to be set active
Implementation
Future<void> selectAudioDevice(VIAudioDevice audioDevice) async {
await _channel
.invokeMethod<void>('AudioDevice.selectAudioDevice', <String, dynamic>{
'audioDevice': audioDevice.index,
});
}