Google is committed to advancing racial equity for Black communities. See how.
Added in API level 30

MediaRouter2.RoutingController

public class MediaRouter2.RoutingController
extends Object

java.lang.Object
   ↳ android.media.MediaRouter2.RoutingController


A class to control media routing session in media route provider. For example, selecting/deselecting/transferring routes to a session can be done through this class. Instances are created by MediaRouter2.transferTo(android.media.MediaRoute2Info).

Summary

Public methods

void deselectRoute(MediaRoute2Info route)

Deselects a route from the remote session.

Bundle getControlHints()
List<MediaRoute2Info> getDeselectableRoutes()
String getId()
List<MediaRoute2Info> getSelectableRoutes()
List<MediaRoute2Info> getSelectedRoutes()
int getVolume()

Gets the current volume of the session.

int getVolumeHandling()

Gets information about how volume is handled on the session.

int getVolumeMax()

Gets the maximum volume of the session.

boolean isReleased()

Returns true if this controller is released, false otherwise.

void release()

Release this controller and corresponding session.

void selectRoute(MediaRoute2Info route)

Selects a route for the remote session.

void setVolume(int volume)

Requests a volume change for the remote session asynchronously.

String toString()

Returns a string representation of the object.

Inherited methods

Public methods

deselectRoute

Added in API level 30
public void deselectRoute (MediaRoute2Info route)

Deselects a route from the remote session. After a route is deselected, the media is expected to be stopped on the deselected routes.

The given route must satisfy all of the following conditions:

If the route doesn't meet any of above conditions, it will be ignored.

Parameters
route MediaRoute2Info: This value cannot be null.

getControlHints

Added in API level 30
public Bundle getControlHints ()

Returns
Bundle the control hints used to control routing session if available. This value may be null.

getDeselectableRoutes

Added in API level 30
public List<MediaRoute2Info> getDeselectableRoutes ()

Returns
List<MediaRoute2Info> the unmodifiable list of deselectable routes for the session. This value cannot be null.

getId

Added in API level 30
public String getId ()

Returns
String the ID of the controller. It is globally unique. This value cannot be null.

getSelectableRoutes

Added in API level 30
public List<MediaRoute2Info> getSelectableRoutes ()

Returns
List<MediaRoute2Info> the unmodifiable list of selectable routes for the session. This value cannot be null.

getSelectedRoutes

Added in API level 30
public List<MediaRoute2Info> getSelectedRoutes ()

Returns
List<MediaRoute2Info> the unmodifiable list of currently selected routes This value cannot be null.

getVolume

Added in API level 30
public int getVolume ()

Gets the current volume of the session.

When it's available, it represents the volume of routing session, which is a group of selected routes. To get the volume of a route, use MediaRoute2Info#getVolume().

Returns
int

getVolumeHandling

Added in API level 30
public int getVolumeHandling ()

Gets information about how volume is handled on the session.

Returns
int MediaRoute2Info#PLAYBACK_VOLUME_FIXED or MediaRoute2Info#PLAYBACK_VOLUME_VARIABLE Value is MediaRoute2Info.PLAYBACK_VOLUME_FIXED, or MediaRoute2Info.PLAYBACK_VOLUME_VARIABLE

getVolumeMax

Added in API level 30
public int getVolumeMax ()

Gets the maximum volume of the session.

Returns
int

isReleased

Added in API level 30
public boolean isReleased ()

Returns true if this controller is released, false otherwise. If it is released, then all other getters from this instance may return invalid values. Also, any operations to this instance will be ignored once released.

Returns
boolean

See also:

release

Added in API level 30
public void release ()

Release this controller and corresponding session. Any operations on this controller after calling this method will be ignored. The devices that are playing media will stop playing it.

selectRoute

Added in API level 30
public void selectRoute (MediaRoute2Info route)

Selects a route for the remote session. After a route is selected, the media is expected to be played to the all the selected routes. This is different from MediaRouter2#transferTo(MediaRoute2Info) transferring to a route}, where the media is expected to 'move' from one route to another.

The given route must satisfy all of the following conditions:

If the route doesn't meet any of above conditions, it will be ignored.

Parameters
route MediaRoute2Info: This value cannot be null.

setVolume

Added in API level 30
public void setVolume (int volume)

Requests a volume change for the remote session asynchronously.

Parameters
volume int: The new volume value between 0 and RoutingController#getVolumeMax (inclusive).

See also:

toString

Added in API level 30
public String toString ()

Returns a string representation of the object. In general, the 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())
 

Returns
String a string representation of the object.