MediaRouter.RouteInfo
public class MediaRouter.RouteInfo
MediaRouter.GroupRouteInfo |
Provides information about a media route that represents a dynamic group. |
Provides information about a media route.
Each media route has a list of media control intent filters that describe the capabilities of the route and the manner in which it is used and controlled.
Summary
Constants |
|
|---|---|
static final int |
A connection state indicating the route is connected. |
static final int |
A connection state indicating the route is in the process of connecting and is not yet ready for use. |
static final int |
The default connection state indicating the route is disconnected. |
static final int |
A receiver device type indicating that the presentation of the media is happening on an Audio/Video receiver (AVR). |
static final int |
A receiver device type indicating the presentation of the media is happening on a Bluetooth Low Energy (BLE) HEADSET. |
static final int |
A receiver device type of the route indicating the presentation of the media is happening on a bluetooth device such as a bluetooth speaker. |
static final int |
A receiver device type indicating the presentation of the media is happening on a speaker system (i.e. a mono speaker or stereo speakers) built into the device. |
static final int |
DEVICE_TYPE_CAR = 9A receiver device type indicating that the presentation of the media is happening on a car. |
static final int |
A receiver device type indicating that the presentation of the media is happening on a computer. |
static final int |
DEVICE_TYPE_DOCK = 19A receiver device type indicating the presentation of the media is happening on an audio device associated on a dock. |
static final int |
A receiver device type indicating that the presentation of the media is happening on a gaming console. |
static final int |
DEVICE_TYPE_GROUP = 1000A receiver device type indicating that the presentation of the media is happening on a group of devices. |
static final int |
DEVICE_TYPE_HDMI = 16A receiver device type indicating the presentation of the media is happening on an HDMI connection. |
static final int |
DEVICE_TYPE_HDMI_ARC = 23A receiver device type indicating the presentation of the media is happening on an Audio Return Channel of an HDMI connection |
static final int |
A receiver device type indicating the presentation of the media is happening on an Enhanced Audio Return Channel of an HDMI connection |
static final int |
A receiver device type indicating the presentation of the media is happening on a hearing aid device. |
static final int |
A receiver device type of the route indicating the presentation of the media is happening on a remote speaker. |
static final int |
A receiver device type indicating that the presentation of the media is happening on a smartphone. |
static final int |
A receiver device type indicating that the presentation of the media is happening on a smartwatch. |
static final int |
This field is deprecated. use |
static final int |
A receiver device type indicating that the presentation of the media is happening on a tablet. |
static final int |
A receiver device type indicating that the presentation of the media is happening on a docked tablet. |
static final int |
DEVICE_TYPE_TV = 1A receiver device type of the route indicating the presentation of the media is happening on a TV. |
static final int |
A receiver device type indicating the presentation of the media is happening on a USB audio device in accessory mode. |
static final int |
A receiver device type indicating the presentation of the media is happening on a USB audio device. |
static final int |
A receiver device type indicating the presentation of the media is happening on a USB audio headset. |
static final int |
A receiver device type indicating the presentation of the media is happening on a pair of wired headphones. |
static final int |
A receiver device type indicating the presentation of the media is happening on a headset, which is the combination of a headphones and a microphone. |
static final int |
The default playback type, "local", indicating the presentation of the media is happening on the same device (e.g. a phone, a tablet) as where it is controlled from. |
static final int |
A playback type indicating the presentation of the media is happening on a different device (i.e. the remote device) than where it is controlled from. |
static final int |
Playback information indicating the playback volume is fixed, i.e. it cannot be controlled from this object. |
static final int |
Playback information indicating the playback volume is variable and can be controlled from this object. |
Public methods |
|
|---|---|
boolean |
Gets whether this route supports disconnecting without interrupting playback. |
void |
Connects this route without selecting it. |
void |
Disconnects this route. |
int |
Gets the connection state of the route. |
@NonNull List<IntentFilter> |
Gets a list of |
@Nullable String |
Gets the user-visible description of the route. |
int |
Gets the type of the receiver device associated with this route. |
@Nullable Bundle |
Gets a collection of extra properties about this route that were supplied by its media route provider, or null if none. |
@Nullable Uri |
Gets the URI of the icon representing this route. |
@NonNull String |
getId()Gets the unique id of the route. |
@Nullable MediaRouteDescriptor |
Returns the |
@NonNull String |
getName()Gets the user-visible name of the route. |
int |
Gets the audio stream over which the playback associated with this route is performed. |
int |
Gets the type of playback associated with this route. |
@Nullable Display |
Gets the |
@NonNull MediaRouter.ProviderInfo |
Gets information about the provider of this media route. |
@Nullable IntentSender |
Gets an intent sender for launching a settings activity for this route. |
int |
Gets the current volume for this route. |
int |
Gets information about how volume is handled on the route. |
int |
Gets the maximum volume at which the playback associated with this route is performed. |
boolean |
Returns true if this route is a bluetooth route. |
boolean |
This method is deprecated. use |
boolean |
Returns true if this route is the default route. |
boolean |
Returns true if this route is the default route and the device speaker. |
boolean |
Returns true if this route is enabled and may be selected. |
boolean |
Returns true if this route is currently selected. |
boolean |
Returns |
boolean |
@MainThreadReturns true if the route supports at least one of the capabilities described by a media route selector. |
void |
@MainThreadRequests a volume change for this route asynchronously. |
void |
@MainThreadRequests an incremental volume update for this route asynchronously. |
void |
Selects this media route. |
void |
@MainThreadSends a |
boolean |
@MainThreadReturns true if the route supports the specified |
boolean |
@MainThreadReturns true if the route supports the specified |
boolean |
@MainThreadReturns true if the route supports the specified |
@NonNull String |
toString() |
Constants
CONNECTION_STATE_CONNECTED
public static final int CONNECTION_STATE_CONNECTED = 2
A connection state indicating the route is connected.
| See also | |
|---|---|
getConnectionState |
CONNECTION_STATE_CONNECTING
public static final int CONNECTION_STATE_CONNECTING = 1
A connection state indicating the route is in the process of connecting and is not yet ready for use.
| See also | |
|---|---|
getConnectionState |
CONNECTION_STATE_DISCONNECTED
public static final int CONNECTION_STATE_DISCONNECTED = 0
The default connection state indicating the route is disconnected.
| See also | |
|---|---|
getConnectionState |
DEVICE_TYPE_AUDIO_VIDEO_RECEIVER
public static final int DEVICE_TYPE_AUDIO_VIDEO_RECEIVER = 4
A receiver device type indicating that the presentation of the media is happening on an Audio/Video receiver (AVR).
| See also | |
|---|---|
getDeviceType |
DEVICE_TYPE_BLE_HEADSET
public static final int DEVICE_TYPE_BLE_HEADSET = 22
A receiver device type indicating the presentation of the media is happening on a Bluetooth Low Energy (BLE) HEADSET.
| See also | |
|---|---|
getDeviceType |
DEVICE_TYPE_BLUETOOTH_A2DP
public static final int DEVICE_TYPE_BLUETOOTH_A2DP = 3
A receiver device type of the route indicating the presentation of the media is happening on a bluetooth device such as a bluetooth speaker.
| See also | |
|---|---|
getDeviceType |
DEVICE_TYPE_BUILTIN_SPEAKER
public static final int DEVICE_TYPE_BUILTIN_SPEAKER = 12
A receiver device type indicating the presentation of the media is happening on a speaker system (i.e. a mono speaker or stereo speakers) built into the device.
| See also | |
|---|---|
getDeviceType |
DEVICE_TYPE_CAR
public static final int DEVICE_TYPE_CAR = 9
A receiver device type indicating that the presentation of the media is happening on a car.
| See also | |
|---|---|
getDeviceType |
DEVICE_TYPE_COMPUTER
public static final int DEVICE_TYPE_COMPUTER = 7
A receiver device type indicating that the presentation of the media is happening on a computer.
| See also | |
|---|---|
getDeviceType |
DEVICE_TYPE_DOCK
public static final int DEVICE_TYPE_DOCK = 19
A receiver device type indicating the presentation of the media is happening on an audio device associated on a dock.
| See also | |
|---|---|
getDeviceType |
DEVICE_TYPE_GAME_CONSOLE
public static final int DEVICE_TYPE_GAME_CONSOLE = 8
A receiver device type indicating that the presentation of the media is happening on a gaming console.
| See also | |
|---|---|
getDeviceType |
DEVICE_TYPE_GROUP
public static final int DEVICE_TYPE_GROUP = 1000
A receiver device type indicating that the presentation of the media is happening on a group of devices.
| See also | |
|---|---|
getDeviceType |
DEVICE_TYPE_HDMI
public static final int DEVICE_TYPE_HDMI = 16
A receiver device type indicating the presentation of the media is happening on an HDMI connection.
| See also | |
|---|---|
getDeviceType |
DEVICE_TYPE_HDMI_ARC
public static final int DEVICE_TYPE_HDMI_ARC = 23
A receiver device type indicating the presentation of the media is happening on an Audio Return Channel of an HDMI connection
| See also | |
|---|---|
getDeviceType |
DEVICE_TYPE_HDMI_EARC
public static final int DEVICE_TYPE_HDMI_EARC = 24
A receiver device type indicating the presentation of the media is happening on an Enhanced Audio Return Channel of an HDMI connection
| See also | |
|---|---|
getDeviceType |
DEVICE_TYPE_HEARING_AID
public static final int DEVICE_TYPE_HEARING_AID = 21
A receiver device type indicating the presentation of the media is happening on a hearing aid device.
| See also | |
|---|---|
getDeviceType |
DEVICE_TYPE_REMOTE_SPEAKER
public static final int DEVICE_TYPE_REMOTE_SPEAKER = 2
A receiver device type of the route indicating the presentation of the media is happening on a remote speaker.
| See also | |
|---|---|
getDeviceType |
DEVICE_TYPE_SMARTPHONE
public static final int DEVICE_TYPE_SMARTPHONE = 11
A receiver device type indicating that the presentation of the media is happening on a smartphone.
| See also | |
|---|---|
getDeviceType |
DEVICE_TYPE_SMARTWATCH
public static final int DEVICE_TYPE_SMARTWATCH = 10
A receiver device type indicating that the presentation of the media is happening on a smartwatch.
| See also | |
|---|---|
getDeviceType |
public static final int DEVICE_TYPE_SPEAKER = 2
A receiver device type of the route indicating the presentation of the media is happening on a speaker.
| See also | |
|---|---|
getDeviceType |
DEVICE_TYPE_TABLET
public static final int DEVICE_TYPE_TABLET = 5
A receiver device type indicating that the presentation of the media is happening on a tablet.
| See also | |
|---|---|
getDeviceType |
DEVICE_TYPE_TABLET_DOCKED
public static final int DEVICE_TYPE_TABLET_DOCKED = 6
A receiver device type indicating that the presentation of the media is happening on a docked tablet.
| See also | |
|---|---|
getDeviceType |
DEVICE_TYPE_TV
public static final int DEVICE_TYPE_TV = 1
A receiver device type of the route indicating the presentation of the media is happening on a TV.
| See also | |
|---|---|
getDeviceType |
DEVICE_TYPE_USB_ACCESSORY
public static final int DEVICE_TYPE_USB_ACCESSORY = 18
A receiver device type indicating the presentation of the media is happening on a USB audio device in accessory mode.
| See also | |
|---|---|
getDeviceType |
DEVICE_TYPE_USB_DEVICE
public static final int DEVICE_TYPE_USB_DEVICE = 17
A receiver device type indicating the presentation of the media is happening on a USB audio device.
| See also | |
|---|---|
getDeviceType |
DEVICE_TYPE_USB_HEADSET
public static final int DEVICE_TYPE_USB_HEADSET = 20
A receiver device type indicating the presentation of the media is happening on a USB audio headset.
| See also | |
|---|---|
getDeviceType |
DEVICE_TYPE_WIRED_HEADPHONES
public static final int DEVICE_TYPE_WIRED_HEADPHONES = 14
A receiver device type indicating the presentation of the media is happening on a pair of wired headphones.
| See also | |
|---|---|
getDeviceType |
DEVICE_TYPE_WIRED_HEADSET
public static final int DEVICE_TYPE_WIRED_HEADSET = 13
A receiver device type indicating the presentation of the media is happening on a headset, which is the combination of a headphones and a microphone.
| See also | |
|---|---|
getDeviceType |
PLAYBACK_TYPE_LOCAL
public static final int PLAYBACK_TYPE_LOCAL = 0
The default playback type, "local", indicating the presentation of the media is happening on the same device (e.g. a phone, a tablet) as where it is controlled from.
| See also | |
|---|---|
getPlaybackType |
PLAYBACK_TYPE_REMOTE
public static final int PLAYBACK_TYPE_REMOTE = 1
A playback type indicating the presentation of the media is happening on a different device (i.e. the remote device) than where it is controlled from.
| See also | |
|---|---|
getPlaybackType |
PLAYBACK_VOLUME_FIXED
public static final int PLAYBACK_VOLUME_FIXED = 0
Playback information indicating the playback volume is fixed, i.e. it cannot be controlled from this object. An example of fixed playback volume is a remote player, playing over HDMI where the user prefers to control the volume on the HDMI sink, rather than attenuate at the source.
| See also | |
|---|---|
getVolumeHandling |
PLAYBACK_VOLUME_VARIABLE
public static final int PLAYBACK_VOLUME_VARIABLE = 1
Playback information indicating the playback volume is variable and can be controlled from this object.
| See also | |
|---|---|
getVolumeHandling |
Public methods
canDisconnect
public boolean canDisconnect()
Gets whether this route supports disconnecting without interrupting playback.
| Returns | |
|---|---|
boolean |
True if this route can disconnect without stopping playback, false otherwise. |
connect
@MainThread
public void connect()
Connects this route without selecting it.
A route may be selected or connected. Route selection is performed using the select method. The media router library supports a single selected route which is typically the active playback device chosen by the user. This method enables connection to additional routes while maintaining the current route selection. If the specified route is already selected, this method has no effect.
The route controller dialog should display only the selected route, as this is the one users directly interact with. Connected routes are typically managed by the application in the background and are not generally relevant to the user.
After calling this method to connect a route, the application will receive the onRouteConnected callback when the connection is established. The connected RouteInfo can then be used to send control commands to the route. If the connection fails, the application receives the onRouteDisconnected callback with error details.
Must be called on the main thread.
disconnect
@MainThread
public void disconnect()
Disconnects this route.
If it is a connected route, then it will disconnect this route. If it is a selected route, disconnecting this route will do nothing.
After calling this method to disconnect a route, the application receives the onRouteDisconnected callback.
Must be called on the main thread.
getConnectionState
public int getConnectionState()
Gets the connection state of the route.
| Returns | |
|---|---|
int |
The connection state of this route: |
getControlFilters
public @NonNull List<IntentFilter> getControlFilters()
Gets a list of media control intent filters that describe the capabilities of this route and the media control actions that it supports.
| Returns | |
|---|---|
@NonNull List<IntentFilter> |
A list of intent filters that specifies the media control intents that this route supports. |
getDescription
public @Nullable String getDescription()
Gets the user-visible description of the route.
The route description describes the kind of destination represented by the route. It may be a user-supplied string, a model number or brand of device.
getDeviceType
public int getDeviceType()
Gets the type of the receiver device associated with this route.
| Returns | |
|---|---|
int |
The type of the receiver device associated with this route. |
getExtras
public @Nullable Bundle getExtras()
Gets a collection of extra properties about this route that were supplied by its media route provider, or null if none.
getIconUri
public @Nullable Uri getIconUri()
Gets the URI of the icon representing this route.
This icon will be used in picker UIs if available.
getId
public @NonNull String getId()
Gets the unique id of the route.
The route unique id functions as a stable identifier by which the route is known. For example, an application can use this id as a token to remember the selected route across restarts or to communicate its identity to a service.
getMediaRouteDescriptor
public @Nullable MediaRouteDescriptor getMediaRouteDescriptor()
Returns the MediaRouteDescriptor of this media route info or null if it is not updated by its provider yet.
getName
public @NonNull String getName()
Gets the user-visible name of the route.
The route name identifies the destination represented by the route. It may be a user-supplied name, an alias, or device serial number.
getPlaybackStream
public int getPlaybackStream()
Gets the audio stream over which the playback associated with this route is performed.
| Returns | |
|---|---|
int |
The stream over which the playback associated with this route is performed. |
getPlaybackType
public int getPlaybackType()
Gets the type of playback associated with this route.
| Returns | |
|---|---|
int |
The type of playback associated with this route: |
getPresentationDisplay
@MainThread
public @Nullable Display getPresentationDisplay()
Gets the Display that should be used by the application to show a android.app.Presentation on an external display when this route is selected. Depending on the route, this may only be valid if the route is currently selected.
The preferred presentation display may change independently of the route being selected or unselected. For example, the presentation display of the default system route may change when an external HDMI display is connected or disconnected even though the route itself has not changed.
This method may return null if there is no external display associated with the route or if the display is not ready to show UI yet.
The application should listen for changes to the presentation display using the onRoutePresentationDisplayChanged callback and show or dismiss its android.app.Presentation accordingly when the display becomes available or is removed.
This method only makes sense for live video routes.
Must be called on the main thread.
| Returns | |
|---|---|
@Nullable Display |
The preferred presentation display to use when this route is selected or null if none. |
| See also | |
|---|---|
CATEGORY_LIVE_VIDEO |
|
Presentation |
getProvider
public @NonNull MediaRouter.ProviderInfo getProvider()
Gets information about the provider of this media route.
getSettingsIntent
public @Nullable IntentSender getSettingsIntent()
Gets an intent sender for launching a settings activity for this route.
getVolume
public int getVolume()
Gets the current volume for this route. Depending on the route, this may only be valid if the route is currently selected.
| Returns | |
|---|---|
int |
The volume at which the playback associated with this route is performed. |
getVolumeHandling
public int getVolumeHandling()
Gets information about how volume is handled on the route.
| Returns | |
|---|---|
int |
How volume is handled on the route: |
getVolumeMax
public int getVolumeMax()
Gets the maximum volume at which the playback associated with this route is performed.
| Returns | |
|---|---|
int |
The maximum volume at which the playback associated with this route is performed. |
isBluetooth
@MainThread
public boolean isBluetooth()
Returns true if this route is a bluetooth route.
Must be called on the main thread.
| Returns | |
|---|---|
boolean |
True if this route is a bluetooth route. |
| See also | |
|---|---|
getBluetoothRoute |
public boolean isConnecting()Returns true if the route is in the process of connecting and is not yet ready for use.
| Returns | |
|---|---|
boolean |
True if this route is in the process of connecting. |
isDefault
@MainThread
public boolean isDefault()
Returns true if this route is the default route.
Must be called on the main thread.
| Returns | |
|---|---|
boolean |
True if this route is the default route. |
| See also | |
|---|---|
getDefaultRoute |
isDeviceSpeaker
public boolean isDeviceSpeaker()
Returns true if this route is the default route and the device speaker.
| Returns | |
|---|---|
boolean |
True if this route is the default route and the device speaker. |
isEnabled
public boolean isEnabled()
Returns true if this route is enabled and may be selected.
| Returns | |
|---|---|
boolean |
True if this route is enabled. |
isSelected
@MainThread
public boolean isSelected()
Returns true if this route is currently selected.
Only one representative route can return true. For instance:
- If this route is a selected (non-group) route, it returns true.
- If this route is a selected group route, it returns true.
- If this route is a selected member route of a group, it returns false.
Must be called on the main thread.
| Returns | |
|---|---|
boolean |
True if this route is currently selected. |
| See also | |
|---|---|
getSelectedRoute |
isSystemRoute
public boolean isSystemRoute()
Returns true if this route is a system route.
System routes are routes controlled by the system, like the device's built-in speakers, wired headsets, and bluetooth devices.
To use system routes, your application should write media sample data to a media framework API, typically via ExoPlayer.
matchesSelector
@MainThread
public boolean matchesSelector(@NonNull MediaRouteSelector selector)
Returns true if the route supports at least one of the capabilities described by a media route selector.
Must be called on the main thread.
| Parameters | |
|---|---|
@NonNull MediaRouteSelector selector |
The selector that specifies the capabilities to check. |
| Returns | |
|---|---|
boolean |
True if the route supports at least one of the capabilities described in the media route selector. |
requestSetVolume
@MainThread
public void requestSetVolume(int volume)
Requests a volume change for this route asynchronously.
This function may only be called on a selected route. It will have no effect if the route is currently unselected.
Must be called on the main thread.
| Parameters | |
|---|---|
int volume |
The new volume value between 0 and |
requestUpdateVolume
@MainThread
public void requestUpdateVolume(int delta)
Requests an incremental volume update for this route asynchronously.
This function may only be called on a selected route. It will have no effect if the route is currently unselected.
Must be called on the main thread.
| Parameters | |
|---|---|
int delta |
The delta to add to the current volume. |
select
@MainThread
public void select()
Selects this media route.
Must be called on the main thread.
sendControlRequest
@MainThread
public void sendControlRequest(
@NonNull Intent intent,
@Nullable MediaRouter.ControlRequestCallback callback
)
Sends a media control request to be performed asynchronously by the route's destination.
Media control requests are used to request the route to perform actions such as starting remote playback of a media item.
This function may only be called on a selected route. Control requests sent to unselected routes will fail.
Must be called on the main thread.
| Parameters | |
|---|---|
@NonNull Intent intent |
|
@Nullable MediaRouter.ControlRequestCallback callback |
A |
| See also | |
|---|---|
MediaControlIntent |
supportsControlAction
@MainThread
public boolean supportsControlAction(@NonNull String category, @NonNull String action)
Returns true if the route supports the specified media control category and action.
Media control actions describe specific requests that an application can ask a route to perform.
Must be called on the main thread.
| Parameters | |
|---|---|
@NonNull String category |
A |
@NonNull String action |
A |
| Returns | |
|---|---|
boolean |
True if the route supports the specified intent action. |
| See also | |
|---|---|
MediaControlIntent |
|
getControlFilters |
supportsControlCategory
@MainThread
public boolean supportsControlCategory(@NonNull String category)
Returns true if the route supports the specified media control category.
Media control categories describe the capabilities of this route such as whether it supports live audio streaming or remote playback.
Must be called on the main thread.
| Parameters | |
|---|---|
@NonNull String category |
A |
| Returns | |
|---|---|
boolean |
True if the route supports the specified intent category. |
| See also | |
|---|---|
MediaControlIntent |
|
getControlFilters |
supportsControlRequest
@MainThread
public boolean supportsControlRequest(@NonNull Intent intent)
Returns true if the route supports the specified media control request.
Media control requests are used to request the route to perform actions such as starting remote playback of a media item.
Must be called on the main thread.
| Returns | |
|---|---|
boolean |
True if the route can handle the specified intent. |
| See also | |
|---|---|
MediaControlIntent |
|
getControlFilters |