AudioSwitch

class AudioSwitch

This class enables developers to enumerate available audio devices and select which device audio should be routed to. It is strongly recommended that instances of this class are created and accessed from a single application thread. Accessing an instance from multiple threads may cause synchronization problems.

Constructors

AudioSwitch
Link copied to clipboard
fun AudioSwitch(context: Context, bluetoothHeadsetConnectionListener: BluetoothHeadsetConnectionListener? = null, loggingEnabled: Boolean = false, audioFocusChangeListener: AudioManager.OnAudioFocusChangeListener = OnAudioFocusChangeListener {}, preferredDeviceList: List<Class<out AudioDevice>> = defaultPreferredDeviceList)
Constructs a new AudioSwitch instance.

Types

Companion
Link copied to clipboard
object Companion

Functions

activate
Link copied to clipboard
fun activate()
Performs audio routing and unmuting on the selected device from AudioSwitch.selectDevice.
deactivate
Link copied to clipboard
fun deactivate()
Restores the audio state prior to calling AudioSwitch.activate and removes audio focus from the client application.
selectDevice
Link copied to clipboard
fun selectDevice(audioDevice: AudioDevice?)
Selects the desired audioDevice.
start
Link copied to clipboard
fun start(listener: AudioDeviceChangeListener)
Starts listening for audio device changes and calls the listener upon each change.
stop
Link copied to clipboard
fun stop()
Stops listening for audio device changes if AudioSwitch.start has already been invoked.

Properties

availableAudioDevices
Link copied to clipboard
val availableAudioDevices: List<AudioDevice>
Retrieves the current list of available AudioDevices.
loggingEnabled
Link copied to clipboard
var loggingEnabled: Boolean
A property to configure AudioSwitch logging behavior.
selectedAudioDevice
Link copied to clipboard
val selectedAudioDevice: AudioDevice?
Retrieves the selected AudioDevice from AudioSwitch.selectDevice.