MediaRouteDescriptor


public final class MediaRouteDescriptor


Describes the properties of a route.

Each route is uniquely identified by an opaque id string. This token may take any form as long as it is unique within the media route provider.

This object is immutable once created using a Builder instance.

Summary

Nested types

public final class MediaRouteDescriptor.Builder

Builder for media route descriptors.

Public methods

@NonNull Bundle

Converts this object to a bundle for serialization.

boolean

Gets whether the route can be disconnected without stopping playback.

static @Nullable MediaRouteDescriptor

Creates an instance from a bundle.

@NonNull Set<String>

Gets the set of allowed packages which are able to see the route or an empty set if only the route provider's package is allowed to see this route.

int

Gets the connection state of the route.

@NonNull List<IntentFilter>

Gets the route's media control intent filters.

@NonNull Set<String>

Gets the route's deduplication ids.

@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 bundle of extras for this route descriptor.

@Nullable Uri

Gets the URI of the icon representing this route.

@NonNull String

Gets the unique id of the route.

@NonNull String

Gets the user-visible name of the route.

int

Gets the route's playback stream.

int

Gets the type of playback associated with this route.

int

Gets the route's presentation display id, or -1 if none.

@Nullable IntentSender

Gets an IntentSender for starting a settings activity for this route.

int

Gets the route's current volume, or 0 if unknown.

int

Gets information about how volume is handled on the route.

int

Gets the route's maximum volume, or 0 if unknown.

boolean

This method is deprecated.

Use getConnectionState instead

boolean

Returns if this route is a dynamic group route.

boolean

Gets whether the route is enabled.

boolean

Returns true if this route is a system route.

boolean

Returns true if the route descriptor has all of the required fields.

boolean

Gets whether the route visibility is public or not.

@NonNull String

Public methods

asBundle

Added in 1.1.0
public @NonNull Bundle asBundle()

Converts this object to a bundle for serialization.

Returns
@NonNull Bundle

The contents of the object represented as a bundle.

canDisconnectAndKeepPlaying

Added in 1.1.0
public boolean canDisconnectAndKeepPlaying()

Gets whether the route can be disconnected without stopping playback.

The route can normally be disconnected without stopping playback when the destination device on the route is connected to two or more source devices. The route provider should update the route immediately when the number of connected devices changes.

To specify that the route should disconnect without stopping use unselect with UNSELECT_REASON_DISCONNECTED.

fromBundle

Added in 1.1.0
public static @Nullable MediaRouteDescriptor fromBundle(@Nullable Bundle bundle)

Creates an instance from a bundle.

Parameters
@Nullable Bundle bundle

The bundle, or null if none.

Returns
@Nullable MediaRouteDescriptor

The new instance, or null if the bundle was null.

getAllowedPackages

Added in 1.6.0
public @NonNull Set<StringgetAllowedPackages()

Gets the set of allowed packages which are able to see the route or an empty set if only the route provider's package is allowed to see this route. This applies only when isVisibilityPublic returns false.

getConnectionState

Added in 1.1.0
public int getConnectionState()

Gets the connection state of the route.

Returns
int

The connection state of this route: CONNECTION_STATE_DISCONNECTED, CONNECTION_STATE_CONNECTING, or CONNECTION_STATE_CONNECTED.

getControlFilters

Added in 1.1.0
public @NonNull List<IntentFiltergetControlFilters()

Gets the route's media control intent filters.

getDeduplicationIds

Added in 1.6.0
public @NonNull Set<StringgetDeduplicationIds()

Gets the route's deduplication ids.

Two routes are considered to come from the same receiver device if any of their respective deduplication ids match.

getDescription

Added in 1.1.0
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

Added in 1.1.0
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

Added in 1.1.0
public @Nullable Bundle getExtras()

Gets a bundle of extras for this route descriptor. The extras will be ignored by the media router but they may be used by applications.

getIconUri

Added in 1.1.0
public @Nullable Uri getIconUri()

Gets the URI of the icon representing this route.

This icon will be used in picker UIs if available.

getId

Added in 1.1.0
public @NonNull String getId()

Gets the unique id of the route.

The route id associated with a route descriptor functions as a stable identifier for the route and must be unique among all routes offered by the provider.

getName

Added in 1.1.0
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

Added in 1.1.0
public int getPlaybackStream()

Gets the route's playback stream.

getPlaybackType

Added in 1.1.0
public int getPlaybackType()

Gets the type of playback associated with this route.

Returns
int

The type of playback associated with this route: PLAYBACK_TYPE_LOCAL or PLAYBACK_TYPE_REMOTE.

getPresentationDisplayId

Added in 1.1.0
public int getPresentationDisplayId()

Gets the route's presentation display id, or -1 if none.

getSettingsActivity

Added in 1.1.0
public @Nullable IntentSender getSettingsActivity()

Gets an IntentSender for starting a settings activity for this route. The activity may have specific route settings or general settings for the connected device or route provider.

Returns
@Nullable IntentSender

An IntentSender to start a settings activity.

getVolume

Added in 1.1.0
public int getVolume()

Gets the route's current volume, or 0 if unknown.

getVolumeHandling

Added in 1.1.0
public int getVolumeHandling()

Gets information about how volume is handled on the route.

Returns
int

How volume is handled on the route: PLAYBACK_VOLUME_FIXED or PLAYBACK_VOLUME_VARIABLE.

getVolumeMax

Added in 1.1.0
public int getVolumeMax()

Gets the route's maximum volume, or 0 if unknown.

isConnecting

Added in 1.1.0
Deprecated in 1.1.0
public boolean isConnecting()

Gets whether the route is connecting.

isDynamicGroupRoute

Added in 1.1.0
public boolean isDynamicGroupRoute()

Returns if this route is a dynamic group route.

MediaRouteProvider creates a dynamic group route when onCreateDynamicGroupRouteController is called. It happens when a single route or a single static group is selected.

If a single device or a static group is selected, the associated dynamic group route should not be seen by any client app because there is already one for the device. After user added more devices into the session, it should be seen by the client app. The provider can treat this by not setting the media intent for the dynamic group route if it contains only one member.

Returns
boolean

true if this route is a dynamic group route.

isEnabled

Added in 1.1.0
public boolean isEnabled()

Gets whether the route is enabled.

isSystemRoute

Added in 1.7.0
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.

isValid

Added in 1.1.0
public boolean isValid()

Returns true if the route descriptor has all of the required fields.

isVisibilityPublic

Added in 1.6.0
public boolean isVisibilityPublic()

Gets whether the route visibility is public or not.

toString

public @NonNull String toString()