Added in API level 30

RoutingController

class RoutingController
kotlin.Any
   ↳ android.media.MediaRouter2.RoutingController

A class to control media routing session in media route provider. For example, selecting/deselecting/transferring to routes of a session can be done through this. Instances are created when TransferCallback#onTransfer(RoutingController, RoutingController) is called, which is invoked after transferTo(android.media.MediaRoute2Info) is called.

Summary

Public methods
open Unit

Deselects a route from the remote session.

open Bundle?

Gets the control hints used to control routing session if available.

open MutableList<MediaRoute2Info!>

open String

open RoutingSessionInfo

Returns the current RoutingSessionInfo associated to this controller.

open MutableList<MediaRoute2Info!>

open MutableList<MediaRoute2Info!>

open Int

Gets the current volume of the session.

open Int

Gets the information about how volume is handled on the session.

open Int

Gets the maximum volume of the session.

open Boolean

Returns true if this controller is released, false otherwise.

open Unit

Releases this controller and the corresponding session.

open Unit

Selects a route for the remote session.

open Unit
setVolume(volume: Int)

Requests a volume change for the remote session asynchronously.

open String

Public methods

deselectRoute

Added in API level 30
open fun deselectRoute(route: MediaRoute2Info): Unit

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

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
open fun getControlHints(): Bundle?

Gets the control hints used to control routing session if available. It is set by the media route provider.

Return
Bundle? This value may be null.

getDeselectableRoutes

Added in API level 30
open fun getDeselectableRoutes(): MutableList<MediaRoute2Info!>
Return
MutableList<MediaRoute2Info!> the unmodifiable list of deselectable routes for the session. This value cannot be null.

getId

Added in API level 30
open fun getId(): String
Return
String the ID of the controller. It is globally unique. This value cannot be null.

getRoutingSessionInfo

Added in API level 34
open fun getRoutingSessionInfo(): RoutingSessionInfo

Returns the current RoutingSessionInfo associated to this controller.

Return
RoutingSessionInfo This value cannot be null.

getSelectableRoutes

Added in API level 30
open fun getSelectableRoutes(): MutableList<MediaRoute2Info!>
Return
MutableList<MediaRoute2Info!> the unmodifiable list of selectable routes for the session. This value cannot be null.

getSelectedRoutes

Added in API level 30
open fun getSelectedRoutes(): MutableList<MediaRoute2Info!>
Return
MutableList<MediaRoute2Info!> the unmodifiable list of currently selected routes This value cannot be null.

getVolume

Added in API level 30
open fun getVolume(): Int

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. Use MediaRoute2Info#getVolume() to get the volume of a route,

getVolumeHandling

Added in API level 30
open fun getVolumeHandling(): Int

Gets the information about how volume is handled on the session.

Please note that you may not control the volume of the session even when you can control the volume of each selected route in the session.

Return
Int MediaRoute2Info#PLAYBACK_VOLUME_FIXED or android.media.MediaRoute2Info#PLAYBACK_VOLUME_VARIABLE Value is android.media.MediaRoute2Info#PLAYBACK_VOLUME_FIXED, or android.media.MediaRoute2Info#PLAYBACK_VOLUME_VARIABLE

getVolumeMax

Added in API level 30
open fun getVolumeMax(): Int

Gets the maximum volume of the session.

isReleased

Added in API level 30
open fun isReleased(): Boolean

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.

See Also

release

Added in API level 30
open fun release(): Unit

Releases this controller and the 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
open fun selectRoute(route: MediaRoute2Info): Unit

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 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
open fun setVolume(volume: Int): Unit

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
open fun toString(): String
Return
String a string representation of the object.