MediaRouteProvider
abstract class MediaRouteProvider
kotlin.Any | |
↳ | androidx.mediarouter.media.MediaRouteProvider |
Media route providers are used to publish additional media routes for use within an application. Media route providers may also be declared as a service to publish additional media routes to all applications in the system.
The purpose of a media route provider is to discover media routes that satisfy the criteria specified by the current MediaRouteDiscoveryRequest
and publish a MediaRouteProviderDescriptor
with information about each route by calling setDescriptor
to notify the currently registered Callback
.
The provider should watch for changes to the discovery request by implementing onDiscoveryRequestChanged
and updating the set of routes that it is attempting to discover. It should also handle route control requests such as volume changes or media control intents
by implementing #onCreateRouteController to return a RouteController
for a particular route.
A media route provider can support dynamic group
that allows the user to add or remove a route from the selected route dynamically. To control dynamic group, DynamicGroupRouteController
returned by onCreateDynamicGroupRouteController
is used instead of RouteController
.
A media route provider may be used privately within the scope of a single application process by calling MediaRouter.addProvider
to add it to the local MediaRouter
. A media route provider may also be made available globally to all applications by registering a MediaRouteProviderService
in the provider's manifest. When the media route provider is registered as a service, all applications that use the media router API will be able to discover and used the provider's routes without having to install anything else.
This object must only be accessed on the main thread.
Summary
Nested classes | |
---|---|
abstract |
Callback which is invoked when route information becomes available or changes. |
abstract |
Provides control over a dynamic group route. |
Describes properties of the route provider's implementation. |
|
abstract |
Provides control over a particular route. |
Public constructors | |
---|---|
Creates a media route provider. |
Public methods | |
---|---|
Context! |
Gets the context of the media route provider. |
MediaRouteProviderDescriptor? |
Gets the provider's descriptor. |
MediaRouteDiscoveryRequest? |
Gets the current discovery request which informs the provider about the kinds of routes to discover and whether to perform active scanning. |
Handler! |
Gets the provider's handler which is associated with the main thread. |
MediaRouteProvider.ProviderMetadata! |
Gets some metadata about the provider's implementation. |
open MediaRouteProvider.DynamicGroupRouteController? |
onCreateDynamicGroupRouteController(@NonNull initialMemberRouteId: String) Creates a |
open MediaRouteProvider.RouteController? |
onCreateRouteController(@NonNull routeId: String) Called by the media router to obtain a route controller for a particular route. |
open Unit |
onDiscoveryRequestChanged(@Nullable request: MediaRouteDiscoveryRequest?) Called by the media router when the |
Unit |
setCallback(@Nullable callback: MediaRouteProvider.Callback?) Sets a callback to invoke when the provider's descriptor changes. |
Unit |
setDescriptor(@Nullable descriptor: MediaRouteProviderDescriptor?) Sets the provider's descriptor. |
Unit |
setDiscoveryRequest(request: MediaRouteDiscoveryRequest!) Sets a discovery request to inform the provider about the kinds of routes that its clients would like to discover and whether to perform active scanning. |
Public constructors
<init>
MediaRouteProvider(@NonNull context: Context)
Creates a media route provider.
Parameters | |
---|---|
context |
Context: The context. |
Public methods
getDescriptor
@Nullable fun getDescriptor(): MediaRouteProviderDescriptor?
Gets the provider's descriptor.
The descriptor describes the state of the media route provider and the routes that it publishes. Watch for changes to the descriptor by registering a callback
with setCallback
.
Return | |
---|---|
MediaRouteProviderDescriptor? |
The media route provider descriptor, or null if none. |
See Also
getDiscoveryRequest
@Nullable fun getDiscoveryRequest(): MediaRouteDiscoveryRequest?
Gets the current discovery request which informs the provider about the kinds of routes to discover and whether to perform active scanning.
Return | |
---|---|
MediaRouteDiscoveryRequest? |
The current discovery request, or null if no discovery is needed at this time. |
See Also
getHandler
fun getHandler(): Handler!
Gets the provider's handler which is associated with the main thread.
getMetadata
fun getMetadata(): MediaRouteProvider.ProviderMetadata!
Gets some metadata about the provider's implementation.