Most visited

Recently visited

Added in API level 24

AudioRouting

public interface AudioRouting

android.media.AudioRouting
Known Indirect Subclasses


AudioRouting定义了一个接口,用于控制AudioTrack和AudioRecord对象中的路由和路由通知。

Summary

Nested classes

interface AudioRouting.OnRoutingChangedListener

定义应用程序可以接收关联AudioRouting的路由更改通知的AudioRouting

Public methods

abstract void addOnRoutingChangedListener(AudioRouting.OnRoutingChangedListener listener, Handler handler)

添加一个 AudioRouting.OnRoutingChangedListener以接收此AudioTrack / AudioRecord上路由更改的通知。

abstract AudioDeviceInfo getPreferredDevice()

返回由 setPreferredDevice(AudioDeviceInfo)指定的所选输出/输入。

abstract AudioDeviceInfo getRoutedDevice()

返回 AudioDeviceInfo标识此AudioTrack / AudioRecord的当前路由。

abstract void removeOnRoutingChangedListener(AudioRouting.OnRoutingChangedListener listener)

删除以前添加的 AudioRouting.OnRoutingChangedListener以接收重新路由通知。

abstract boolean setPreferredDevice(AudioDeviceInfo deviceInfo)

指定一个音频设备(通过 AudioDeviceInfo对象)来路由输出/输入。

Public methods

addOnRoutingChangedListener

Added in API level 24
void addOnRoutingChangedListener (AudioRouting.OnRoutingChangedListener listener, 
                Handler handler)

添加 AudioRouting.OnRoutingChangedListener以接收此AudioTrack / AudioRecord上路由更改的通知。

Parameters
listener AudioRouting.OnRoutingChangedListener: The AudioRouting.OnRoutingChangedListener interface to receive notifications of rerouting events.
handler Handler: Specifies the Handler object for the thread on which to execute the callback. If null, the Handler associated with the main Looper will be used.

getPreferredDevice

Added in API level 24
AudioDeviceInfo getPreferredDevice ()

返回由setPreferredDevice(AudioDeviceInfo)指定的所选输出/输入。 请注意,这不能保证与用于播放/录制的实际设备相对应。

Returns
AudioDeviceInfo

getRoutedDevice

Added in API level 24
AudioDeviceInfo getRoutedDevice ()

返回AudioDeviceInfo标识此AudioTrack / AudioRecord的当前路由。 注意:只有当AudioTrack / AudioRecord当前正在播放时,该查询才有效。 如果不是, getRoutedDevice()将返回null。

Returns
AudioDeviceInfo

removeOnRoutingChangedListener

Added in API level 24
void removeOnRoutingChangedListener (AudioRouting.OnRoutingChangedListener listener)

删除以前添加的 AudioRouting.OnRoutingChangedListener以接收重新路由通知。

Parameters
listener AudioRouting.OnRoutingChangedListener: The previously added AudioRouting.OnRoutingChangedListener interface to remove.

setPreferredDevice

Added in API level 24
boolean setPreferredDevice (AudioDeviceInfo deviceInfo)

指定一个音频设备(通过 AudioDeviceInfo对象)将输出/输入路由到/从。

Parameters
deviceInfo AudioDeviceInfo: The AudioDeviceInfo specifying the audio sink or source. If deviceInfo is null, default routing is restored.
Returns
boolean true if succesful, false if the specified AudioDeviceInfo is non-null and does not correspond to a valid audio device.

Hooray!