added in version 22.1.0
belongs to Maven artifact com.android.support:mediarouter-v7:28.0.0-alpha1

MediaRouteProvider

public abstract class MediaRouteProvider
extends Object

java.lang.Object
   ↳ android.support.v7.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(MediaRouteProviderDescriptor) to notify the currently registered MediaRouteProvider.Callback.

The provider should watch for changes to the discovery request by implementing onDiscoveryRequestChanged(MediaRouteDiscoveryRequest) 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(String) to return a MediaRouteProvider.RouteController for a particular route.

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

class MediaRouteProvider.Callback

Callback which is invoked when route information becomes available or changes. 

class MediaRouteProvider.ProviderMetadata

Describes properties of the route provider's implementation. 

class MediaRouteProvider.RouteController

Provides control over a particular route. 

Public constructors

MediaRouteProvider(Context context)

Creates a media route provider.

Public methods

final Context getContext()

Gets the context of the media route provider.

final MediaRouteProviderDescriptor getDescriptor()

Gets the provider's descriptor.

final MediaRouteDiscoveryRequest getDiscoveryRequest()

Gets the current discovery request which informs the provider about the kinds of routes to discover and whether to perform active scanning.

final Handler getHandler()

Gets the provider's handler which is associated with the main thread.

final MediaRouteProvider.ProviderMetadata getMetadata()

Gets some metadata about the provider's implementation.

MediaRouteProvider.RouteController onCreateRouteController(String routeId)

Called by the media router to obtain a route controller for a particular route.

void onDiscoveryRequestChanged(MediaRouteDiscoveryRequest request)

Called by the media router when the discovery request has changed.

final void setCallback(MediaRouteProvider.Callback callback)

Sets a callback to invoke when the provider's descriptor changes.

final void setDescriptor(MediaRouteProviderDescriptor descriptor)

Sets the provider's descriptor.

final void setDiscoveryRequest(MediaRouteDiscoveryRequest request)

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.

Inherited methods

From class java.lang.Object