Class AudioSwitch
-
- All Implemented Interfaces:
public final class AudioSwitch
-
-
Field Summary
Fields Modifier and Type Field Description public final static StringVERSIONprivate final AudioDeviceselectedAudioDeviceprivate final List<AudioDevice>availableAudioDevices
-
Method Summary
Modifier and Type Method Description final AudioDevicegetSelectedAudioDevice()final List<AudioDevice>getAvailableAudioDevices()final Unitstart(Function2<List<AudioDevice>, AudioDevice, Unit> listener)Starts listening for audio device changes and calls the listener upon each change. final Unitstop()Stops listening for audio device changes if AudioSwitch.start has already been invoked. final Unitactivate()Performs audio routing and unmuting on the selected device from AudioSwitch.selectDevice. final Unitdeactivate()Restores the audio state prior to calling AudioSwitch.activate and removes audio focus from the client application. final UnitselectDevice(AudioDevice audioDevice)Selects the desired audioDevice. -
-
Method Detail
-
getSelectedAudioDevice
final AudioDevice getSelectedAudioDevice()
-
getAvailableAudioDevices
final List<AudioDevice> getAvailableAudioDevices()
-
start
final Unit start(Function2<List<AudioDevice>, AudioDevice, Unit> listener)
Starts listening for audio device changes and calls the listener upon each change. Note: When audio device listening is no longer needed, AudioSwitch.stop should be called in order to prevent a memory leak.
-
stop
final Unit stop()
Stops listening for audio device changes if AudioSwitch.start has already been invoked. AudioSwitch.deactivate will also get called if a device has been activated with AudioSwitch.activate.
-
activate
final Unit activate()
Performs audio routing and unmuting on the selected device from AudioSwitch.selectDevice. Audio focus is also acquired for the client application. Note: AudioSwitch.deactivate should be invoked to restore the prior audio state.
-
deactivate
final Unit deactivate()
Restores the audio state prior to calling AudioSwitch.activate and removes audio focus from the client application.
-
selectDevice
final Unit selectDevice(AudioDevice audioDevice)
Selects the desired audioDevice. If the provided AudioDevice is not available, no changes are made. If the provided device is null, one is chosen based on the specified preferred device list or the following default list: BluetoothHeadset, WiredHeadset, Earpiece, Speakerphone.
-
-
-
-