AudioDeviceManager
This API is in beta and subject to change.
Interface that manages audio devices, i.e. sees current active device, selects another active device and gets the list of available devices.
Voximplant Android SDK supports the following devices:
- Earpiece
- Speaker
- Wired headset
- USB headset
- Bluetooth headset
Default audio device
The earpiece is the default audio device for devices that supports telephony feature (android phones). The speaker is the default audio device for android tablets.
Default audio device type can be changed via AudioDeviceManager.setDefaultAudioDeviceType.
Before a call
If the audio device is not selected via AudioDeviceManager.selectedAudioDevice and default audio device type is not set via AudioDeviceManager.setDefaultAudioDeviceType, it is selected according to the following priority order:
- Bluetooth (if connected)
- USB or wired headset (if connected)
- earpiece (if available)
- speaker
If audio device is selected via AudioDeviceManager.selectedAudioDevice and then a higher priority device is connected, the new device is used for a call. For example, speaker has been selected and then a Bluetooth headset is connected, in this case bluetooth device is used for a call.
During a call
If a new audio device (wired headset, USB headset, or Bluetooth headset) is connected, the active audio device is switched to the new connected audio device.
If the active audio device is disconnected (wired, USB, or Bluetooth headset), the active audio device is selected according to the priority order.
If the active audio device is selected via AudioDeviceManager.selectedAudioDevice, active audio device is switched to the selected device.
Permissions
Voximplant Android SDK does not require any additional permissions to manage audio devices.
Limitations
- On Android 11 and below it is not possible to select earpiece while a wired or USB headset is connected.
- Voximplant Android SDK does not currently support multiple Bluetooth audio devices.
Methods
selectAudioDevice
fun selectAudioDevice(audioDevice: ): Unit
This API is in beta and subject to change.
Changes the currently selected audio device. There are two cases:
- Before a call. The method does not activate an audio device, it just selects (i.e. points to) the active audio device.
- During a call. If the selected audio device is available, the method activates this audio device. When the call is ended, selected audio device is reset to the default one.
Please note that active audio device can be changed later if new device is connected. In this case AudioDeviceEventsListener.onAudioDeviceChanged is triggered to notify about new active device.
Parameters
audioDevice:
to be selected
Returns
type:
Unit
getAudioDeviceOfType
fun getAudioDeviceOfType(audioDeviceType: ):
This API is in beta and subject to change.
Returns the available audio device by its type.
Parameters
audioDeviceType:
Requested audio device type
Returns
type:
setDefaultAudioDeviceType
fun setDefaultAudioDeviceType(audioDeviceType: ): Unit
This API is in beta and subject to change.
Sets the default audio device type.
Parameters
audioDeviceType:
Audio device type to be default
Returns
type:
Unit
setAudioFocusChangeListener
fun setAudioFocusChangeListener(listener: ): Unit
This API is in beta and subject to change.
Sets a listener to handle audio focus change events.
Parameters
listener:
OptionalThe listener to be notified of changes in the audio focus, or null to remove a listener
Returns
type:
Unit
addAudioDeviceEventsListener
fun addAudioDeviceEventsListener(listener: ): Unit
This API is in beta and subject to change.
Adds a listener to handle events related to the audio devices.
Parameters
listener:
The listener to be notified of changes in audio devices
Returns
type:
Unit
removeAudioDeviceEventsListener
fun removeAudioDeviceEventsListener(listener: ): Unit
This API is in beta and subject to change.
Removes the listener used to handle events related to audio devices.
Parameters
listener:
The listener used to be notified of changes in audio devices
Returns
type:
Unit
getInstance
@JvmStatic@Synchronizedfun getInstance(context: Context
):
This API is in beta and subject to change.
Gets the AudioDeviceManage instance.
Parameters
context:
Context
Returns
type:
Props
selectedAudioDevice
val selectedAudioDevice:
This API is in beta and subject to change.
The selected audio device during the call or audio device that is used for a call if there is no calls at this moment.
Please note that active audio device can be later changed if new device is connected. In this case AudioDeviceEventsListener.onAudioDeviceChanged is triggered to notify about new active device.
Returns
type:
audioDevices
val audioDevices: List<AudioDevice>
This API is in beta and subject to change.
Available audio devices.
Returns
type:
List<AudioDevice>