Rate this page:

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:

  1. Earpiece
  2. Speaker
  3. Wired headset
  4. USB headset
  5. 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:

  1. Bluetooth (if connected)
  2. USB or wired headset (if connected)
  3. earpiece (if available)
  4. 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

  1. On Android 11 and below it is not possible to select earpiece while a wired or USB headset is connected.
  2. Voximplant Android SDK does not currently support multiple Bluetooth audio devices.

Methods

selectAudioDevice

Copy URL
fun selectAudioDevice(audioDevice: 

AudioDevice

):

Unit

This API is in beta and subject to change.

Changes the currently selected audio device. There are two cases:

  1. Before a call. The method does not activate an audio device, it just selects (i.e. points to) the active audio device.
  2. 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

Returns

  • type:

    Unit

getAudioDeviceOfType

Copy URL
fun getAudioDeviceOfType(audioDeviceType: 

AudioDeviceType

):

AudioDevice?

This API is in beta and subject to change.

Returns the available audio device by its type.

Parameters

Returns

setDefaultAudioDeviceType

Copy URL
fun setDefaultAudioDeviceType(audioDeviceType: 

AudioDeviceType

):

Unit

This API is in beta and subject to change.

Sets the default audio device type.

Parameters

Returns

  • type:

    Unit

setAudioFocusChangeListener

Copy URL
fun setAudioFocusChangeListener(listener: 

AudioFocusChangeListener?

):

Unit

This API is in beta and subject to change.

Sets a listener to handle audio focus change events.

Parameters

  • Optional

    The listener to be notified of changes in the audio focus, or null to remove a listener

Returns

  • type:

    Unit

addAudioDeviceEventsListener

Copy URL
fun addAudioDeviceEventsListener(listener: 

AudioDeviceEventsListener

):

Unit

This API is in beta and subject to change.

Adds a listener to handle events related to the audio devices.

Parameters

Returns

  • type:

    Unit

removeAudioDeviceEventsListener

Copy URL
fun removeAudioDeviceEventsListener(listener: 

AudioDeviceEventsListener

):

Unit

This API is in beta and subject to change.

Removes the listener used to handle events related to audio devices.

Parameters

Returns

  • type:

    Unit

getInstance

Copy URL
@JvmStatic
@Synchronized
fun getInstance(context:

Context

):

AudioDeviceManager

This API is in beta and subject to change.

Gets the AudioDeviceManage instance.

Parameters

  • context:

    Context

Returns

Props

selectedAudioDevice

Copy URL
val selectedAudioDevice: 

AudioDevice?

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

audioDevices

Copy URL
val audioDevices: 

List<AudioDevice>

This API is in beta and subject to change.

Available audio devices.

Returns