public static class MediaRouter.RouteInfo extends Object
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.
Modifier and Type | Field and Description |
---|---|
static int |
CONNECTION_STATE_CONNECTED
A connection state indicating the route is connected.
|
static int |
CONNECTION_STATE_CONNECTING
A connection state indicating the route is in the process of connecting and is not yet
ready for use.
|
static int |
CONNECTION_STATE_DISCONNECTED
The default connection state indicating the route is disconnected.
|
static int |
DEVICE_TYPE_BLUETOOTH
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 int |
DEVICE_TYPE_SPEAKER
A receiver device type of the route indicating the presentation of the media is happening
on a speaker.
|
static int |
DEVICE_TYPE_TV
A receiver device type of the route indicating the presentation of the media is happening
on a TV.
|
static int |
DEVICE_TYPE_UNKNOWN
The default receiver device type of the route indicating the type is unknown.
|
static int |
PLAYBACK_TYPE_LOCAL
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 int |
PLAYBACK_TYPE_REMOTE
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 int |
PLAYBACK_VOLUME_FIXED
Playback information indicating the playback volume is fixed, i.e. it cannot be
controlled from this object.
|
static int |
PLAYBACK_VOLUME_VARIABLE
Playback information indicating the playback volume is variable and can be controlled
from this object.
|
static int |
PRESENTATION_DISPLAY_ID_NONE
The default presentation display id indicating no presentation display is associated
with the route.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canDisconnect()
Gets whether this route supports disconnecting without interrupting
playback.
|
int |
getConnectionState()
Gets the connection state of the route.
|
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. |
String |
getDescription()
Gets the user-visible description of the route.
|
int |
getDeviceType()
Gets the type of the receiver device associated with this route.
|
Bundle |
getExtras()
Gets a collection of extra properties about this route that were supplied
by its media route provider, or null if none.
|
Uri |
getIconUri()
Gets the URI of the icon representing this route.
|
String |
getId()
Gets the unique id of the route.
|
String |
getName()
Gets the user-visible name of the route.
|
int |
getPlaybackStream()
Gets the audio stream over which the playback associated with this route is performed.
|
int |
getPlaybackType()
Gets the type of playback associated with this route.
|
Display |
getPresentationDisplay()
Gets the
Display that should be used by the application to show
a Presentation on an external display when this route is selected. |
int |
getPresentationDisplayId()
Gets the route's presentation display id, or -1 if none.
|
MediaRouter.ProviderInfo |
getProvider()
Gets information about the provider of this media route.
|
MediaRouteProvider |
getProviderInstance() |
IntentSender |
getSettingsIntent()
Gets an intent sender for launching a settings activity for this
route.
|
int |
getVolume()
Gets the current volume for this route.
|
int |
getVolumeHandling()
Gets information about how volume is handled on the route.
|
int |
getVolumeMax()
Gets the maximum volume at which the playback associated with this route is performed.
|
boolean |
isConnecting()
Returns true if the route is in the process of connecting and is not
yet ready for use.
|
boolean |
isDefault()
Returns true if this route is the default route.
|
boolean |
isDefaultOrBluetooth() |
boolean |
isEnabled()
Returns true if this route is enabled and may be selected.
|
boolean |
isSelected()
Returns true if this route is currently selected.
|
boolean |
matchesSelector(MediaRouteSelector selector)
Returns true if the route supports at least one of the capabilities
described by a media route selector.
|
void |
requestSetVolume(int volume)
Requests a volume change for this route asynchronously.
|
void |
requestUpdateVolume(int delta)
Requests an incremental volume update for this route asynchronously.
|
void |
select()
Selects this media route.
|
void |
sendControlRequest(Intent intent,
MediaRouter.ControlRequestCallback callback)
Sends a
media control request to be performed
asynchronously by the route's destination. |
boolean |
supportsControlAction(String category,
String action)
Returns true if the route supports the specified
media control category and action. |
boolean |
supportsControlCategory(String category)
Returns true if the route supports the specified
media control category. |
boolean |
supportsControlRequest(Intent intent)
Returns true if the route supports the specified
media control request. |
String |
toString()
Returns a string representation of the object.
|
public static final int CONNECTION_STATE_DISCONNECTED
getConnectionState()
,
Constant Field Valuespublic static final int CONNECTION_STATE_CONNECTING
getConnectionState()
,
Constant Field Valuespublic static final int CONNECTION_STATE_CONNECTED
getConnectionState()
,
Constant Field Valuespublic static final int PLAYBACK_TYPE_LOCAL
getPlaybackType()
,
Constant Field Valuespublic static final int PLAYBACK_TYPE_REMOTE
getPlaybackType()
,
Constant Field Valuespublic static final int DEVICE_TYPE_UNKNOWN
getDeviceType()
,
Constant Field Valuespublic static final int DEVICE_TYPE_TV
getDeviceType()
,
Constant Field Valuespublic static final int DEVICE_TYPE_SPEAKER
getDeviceType()
,
Constant Field Valuespublic static final int DEVICE_TYPE_BLUETOOTH
getDeviceType()
,
Constant Field Valuespublic static final int PLAYBACK_VOLUME_FIXED
getVolumeHandling()
,
Constant Field Valuespublic static final int PLAYBACK_VOLUME_VARIABLE
getVolumeHandling()
,
Constant Field Valuespublic static final int PRESENTATION_DISPLAY_ID_NONE
public MediaRouter.ProviderInfo getProvider()
@NonNull public String getId()
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.
public String getName()
The route name identifies the destination represented by the route. It may be a user-supplied name, an alias, or device serial number.
@Nullable public String getDescription()
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.
public Uri getIconUri()
This icon will be used in picker UIs if available.
public boolean isEnabled()
public boolean isConnecting()
public int getConnectionState()
CONNECTION_STATE_DISCONNECTED
,
CONNECTION_STATE_CONNECTING
, or CONNECTION_STATE_CONNECTED
.public boolean isSelected()
MediaRouter.getSelectedRoute()
public boolean isDefault()
MediaRouter.getDefaultRoute()
public List<IntentFilter> getControlFilters()
media control intent
filters that
describe the capabilities of this route and the media control actions that
it supports.MediaControlIntent
,
supportsControlCategory(java.lang.String)
,
supportsControlRequest(android.content.Intent)
public boolean matchesSelector(@NonNull MediaRouteSelector selector)
selector
- The selector that specifies the capabilities to check.public boolean supportsControlCategory(@NonNull String category)
media control
category.
Media control categories describe the capabilities of this route such as whether it supports live audio streaming or remote playback.
category
- A media control
category
such as MediaControlIntent.CATEGORY_LIVE_AUDIO
,
MediaControlIntent.CATEGORY_LIVE_VIDEO
,
MediaControlIntent.CATEGORY_REMOTE_PLAYBACK
, or a provider-defined
media control category.MediaControlIntent
,
getControlFilters()
public boolean supportsControlAction(@NonNull String category, @NonNull String action)
media control
category and action.
Media control actions describe specific requests that an application can ask a route to perform.
category
- A media control
category
such as MediaControlIntent.CATEGORY_LIVE_AUDIO
,
MediaControlIntent.CATEGORY_LIVE_VIDEO
,
MediaControlIntent.CATEGORY_REMOTE_PLAYBACK
, or a provider-defined
media control category.action
- A media control
action
such as MediaControlIntent.ACTION_PLAY
.MediaControlIntent
,
getControlFilters()
public boolean supportsControlRequest(@NonNull Intent intent)
media control
request.
Media control requests are used to request the route to perform actions such as starting remote playback of a media item.
intent
- A media control intent
.MediaControlIntent
,
getControlFilters()
public void sendControlRequest(@NonNull Intent intent, @Nullable MediaRouter.ControlRequestCallback callback)
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.
intent
- A media control intent
.callback
- A MediaRouter.ControlRequestCallback
to invoke with the result
of the request, or null if no result is required.MediaControlIntent
public int getPlaybackType()
PLAYBACK_TYPE_LOCAL
or PLAYBACK_TYPE_REMOTE
.public int getPlaybackStream()
public int getDeviceType()
DEVICE_TYPE_TV
or DEVICE_TYPE_SPEAKER
.public boolean isDefaultOrBluetooth()
public int getVolumeHandling()
PLAYBACK_VOLUME_FIXED
or PLAYBACK_VOLUME_VARIABLE
.public int getVolume()
public int getVolumeMax()
public boolean canDisconnect()
public void requestSetVolume(int volume)
This function may only be called on a selected route. It will have no effect if the route is currently unselected.
volume
- The new volume value between 0 and getVolumeMax()
.public void requestUpdateVolume(int delta)
This function may only be called on a selected route. It will have no effect if the route is currently unselected.
delta
- The delta to add to the current volume.@Nullable public Display getPresentationDisplay()
Display
that should be used by the application to show
a 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 MediaRouter.Callback.onRoutePresentationDisplayChanged(android.support.v7.media.MediaRouter, android.support.v7.media.MediaRouter.RouteInfo)
callback and
show or dismiss its Presentation
accordingly when the display
becomes available or is removed.
This method only makes sense for
live video
routes.
MediaControlIntent.CATEGORY_LIVE_VIDEO
,
Presentation
public int getPresentationDisplayId()
@Nullable public Bundle getExtras()
@Nullable public IntentSender getSettingsIntent()
public void select()
public String toString()
Object
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
public MediaRouteProvider getProviderInstance()