AudioRouting
interface AudioRouting
| android.media.AudioRouting | 
AudioRouting defines an interface for controlling routing and routing notifications in AudioTrack and AudioRecord objects.
Summary
| Nested classes | |
|---|---|
| abstract | Defines the interface by which applications can receive notifications of routing changes for the associated  | 
| Public methods | |
|---|---|
| abstract Unit | addOnRoutingChangedListener(listener: AudioRouting.OnRoutingChangedListener!, handler: Handler!)Adds an  | 
| abstract AudioDeviceInfo! | Returns the selected output/input specified by  | 
| abstract AudioDeviceInfo! | Returns an  | 
| open MutableList<AudioDeviceInfo!> | Returns a List of  | 
| abstract Unit | Removes an  | 
| abstract Boolean | setPreferredDevice(deviceInfo: AudioDeviceInfo!)Specifies an audio device (via an  | 
Public methods
addOnRoutingChangedListener
abstract fun addOnRoutingChangedListener(
listener: AudioRouting.OnRoutingChangedListener!,
handler: Handler!
): Unit
Adds an AudioRouting.OnRoutingChangedListener to receive notifications of routing changes on this AudioTrack/AudioRecord.
| Parameters | |
|---|---|
| listener | AudioRouting.OnRoutingChangedListener!: The AudioRouting.OnRoutingChangedListenerinterface to receive notifications of rerouting events. | 
| handler | Handler!: Specifies the Handlerobject for the thread on which to execute the callback. Ifnull, theHandlerassociated with the mainLooperwill be used. | 
getPreferredDevice
abstract fun getPreferredDevice(): AudioDeviceInfo!
Returns the selected output/input specified by setPreferredDevice. Note that this is not guaranteed to correspond to the actual device being used for playback/recording.
getRoutedDevice
abstract fun getRoutedDevice(): AudioDeviceInfo!
Returns an AudioDeviceInfo identifying the current routing of this AudioTrack/AudioRecord. Note: The query is only valid if the AudioTrack/AudioRecord is currently playing. If it is not, getRoutedDevice() will return null.
getRoutedDevices
open fun getRoutedDevices(): MutableList<AudioDeviceInfo!>
Returns a List of AudioDeviceInfo identifying the current routing of this AudioTrack/AudioRecord. Note: The query is only valid if the AudioTrack/AudioRecord is currently playing. If it is not, getRoutedDevices() will return an empty List.
| Return | |
|---|---|
| MutableList<AudioDeviceInfo!> | This value cannot be null. | 
removeOnRoutingChangedListener
abstract fun removeOnRoutingChangedListener(listener: AudioRouting.OnRoutingChangedListener!): Unit
Removes an AudioRouting.OnRoutingChangedListener which has been previously added to receive rerouting notifications.
| Parameters | |
|---|---|
| listener | AudioRouting.OnRoutingChangedListener!: The previously added AudioRouting.OnRoutingChangedListenerinterface to remove. | 
setPreferredDevice
abstract fun setPreferredDevice(deviceInfo: AudioDeviceInfo!): Boolean
Specifies an audio device (via an AudioDeviceInfo object) to route the output/input to/from.
| Parameters | |
|---|---|
| deviceInfo | AudioDeviceInfo!: The AudioDeviceInfospecifying the audio sink or source. If deviceInfo is null, default routing is restored. | 
| Return | |
|---|---|
| Boolean | true if succesful, false if the specified AudioDeviceInfois non-null and does not correspond to a valid audio device. | 
