RouteController
abstract class RouteController
kotlin.Any | |
↳ | androidx.mediarouter.media.MediaRouteProvider.RouteController |
Provides control over a particular route.
The media router obtains a route controller for a route whenever it needs to control a route. When a route is selected, the media router invokes the onSelect
method of its route controller. While selected, the media router may call other methods of the route controller to request that it perform certain actions to the route. When a route is unselected, the media router invokes the onUnselect(int)
method of its route controller. When the media route no longer needs the route controller it will invoke the onRelease
method to allow the route controller to free its resources.
There may be multiple route controllers simultaneously active for the same route. Each route controller will be released separately.
All operations on the route controller are asynchronous and results are communicated via callbacks.
Summary
Public constructors | |
---|---|
<init>() Provides control over a particular route. |
Public methods | |
---|---|
open Boolean |
onControlRequest(intent: Intent!, @Nullable callback: MediaRouter.ControlRequestCallback?) Performs a |
open Unit |
Releases the route controller, allowing it to free its resources. |
open Unit |
onSelect() Selects the route. |
open Unit |
onSetVolume(volume: Int) Requests to set the volume of the route. |
open Unit |
Unselects the route. |
open Unit |
onUnselect(reason: Int) Unselects the route and provides a reason. |
open Unit |
onUpdateVolume(delta: Int) Requests an incremental volume update for the route. |
Public constructors
<init>
RouteController()
Provides control over a particular route.
The media router obtains a route controller for a route whenever it needs to control a route. When a route is selected, the media router invokes the onSelect
method of its route controller. While selected, the media router may call other methods of the route controller to request that it perform certain actions to the route. When a route is unselected, the media router invokes the onUnselect(int)
method of its route controller. When the media route no longer needs the route controller it will invoke the onRelease
method to allow the route controller to free its resources.
There may be multiple route controllers simultaneously active for the same route. Each route controller will be released separately.
All operations on the route controller are asynchronous and results are communicated via callbacks.
Public methods
onControlRequest
open fun onControlRequest(
intent: Intent!,
@Nullable callback: MediaRouter.ControlRequestCallback?
): Boolean
Performs a media control
request asynchronously on behalf of the route.
Parameters | |
---|---|
intent |
Intent!: A media control intent . |
callback |
MediaRouter.ControlRequestCallback?: A ControlRequestCallback to invoke with the result of the request, or null if no result is required. |
Return | |
---|---|
Boolean |
True if the controller intends to handle the request and will invoke the callback when finished. False if the controller will not handle the request and will not invoke the callback. |
See Also
onRelease
open fun onRelease(): Unit
Releases the route controller, allowing it to free its resources.
onSetVolume
open fun onSetVolume(volume: Int): Unit
Requests to set the volume of the route.
Parameters | |
---|---|
volume |
Int: The new volume value between 0 and MediaRouteDescriptor#getVolumeMax . |
onUnselect
open funonUnselect(): Unit
Deprecated: Use onUnselect(int)
instead.
Unselects the route.
onUnselect
open fun onUnselect(reason: Int): Unit
Unselects the route and provides a reason. The default implementation calls onUnselect()
.
The reason provided will be one of the following:
MediaRouter#UNSELECT_REASON_UNKNOWN
MediaRouter#UNSELECT_REASON_DISCONNECTED
MediaRouter#UNSELECT_REASON_STOPPED
MediaRouter#UNSELECT_REASON_ROUTE_CHANGED
Parameters | |
---|---|
reason |
Int: The reason for unselecting the route. |