MediaRouter.Callback


public abstract class MediaRouter.Callback


Interface for receiving events about media routing changes. All methods of this interface will be called from the application's main thread.

A Callback will only receive events relevant to routes that the callback was registered for unless the CALLBACK_FLAG_UNFILTERED_EVENTS flag was specified in addCallback.

Summary

Public constructors

Public methods

void

Called when a media route provider has been added.

void

Called when a property of the indicated media route provider has changed.

void

Called when a media route provider has been removed.

void

Called when a media route has been added.

void

Called when a property of the indicated media route has changed.

void
onRouteConnected(
    @NonNull MediaRouter router,
    @NonNull MediaRouter.RouteInfo connectedRoute,
    @NonNull MediaRouter.RouteInfo requestedRoute
)

Called when the supplied media route becomes connected.

void
onRouteDisconnected(
    @NonNull MediaRouter router,
    @NonNull MediaRouter.RouteInfo route,
    int reason
)

Called when the supplied media route becomes disconnected.

void

Called when a media route's presentation display changes.

void

Called when a media route has been removed.

void

This method is deprecated.

Use onRouteSelected instead.

void
onRouteSelected(
    @NonNull MediaRouter router,
    @NonNull MediaRouter.RouteInfo route,
    int reason
)

Called when the supplied media route becomes selected as the active route.

void
onRouteSelected(
    @NonNull MediaRouter router,
    @NonNull MediaRouter.RouteInfo selectedRoute,
    int reason,
    @NonNull MediaRouter.RouteInfo requestedRoute
)

Called when the supplied media route becomes selected as the active route, which may be different from the route requested by selectRoute.

void

This method is deprecated.

Use onRouteUnselected instead.

void
onRouteUnselected(
    @NonNull MediaRouter router,
    @NonNull MediaRouter.RouteInfo route,
    int reason
)

Called when the supplied media route becomes unselected as the active route.

void

Called when a media route's volume changes.

Public constructors

Callback

Added in 1.1.0
public Callback()

Public methods

onProviderAdded

Added in 1.1.0
public void onProviderAdded(
    @NonNull MediaRouter router,
    @NonNull MediaRouter.ProviderInfo provider
)

Called when a media route provider has been added.

Parameters
@NonNull MediaRouter router

The media router reporting the event.

@NonNull MediaRouter.ProviderInfo provider

The provider that has become available for use.

onProviderChanged

Added in 1.1.0
public void onProviderChanged(
    @NonNull MediaRouter router,
    @NonNull MediaRouter.ProviderInfo provider
)

Called when a property of the indicated media route provider has changed.

Parameters
@NonNull MediaRouter router

The media router reporting the event.

@NonNull MediaRouter.ProviderInfo provider

The provider that was changed.

onProviderRemoved

Added in 1.1.0
public void onProviderRemoved(
    @NonNull MediaRouter router,
    @NonNull MediaRouter.ProviderInfo provider
)

Called when a media route provider has been removed.

Parameters
@NonNull MediaRouter router

The media router reporting the event.

@NonNull MediaRouter.ProviderInfo provider

The provider that has been removed from availability.

onRouteAdded

Added in 1.1.0
public void onRouteAdded(
    @NonNull MediaRouter router,
    @NonNull MediaRouter.RouteInfo route
)

Called when a media route has been added.

Parameters
@NonNull MediaRouter router

The media router reporting the event.

@NonNull MediaRouter.RouteInfo route

The route that has become available for use.

onRouteChanged

Added in 1.1.0
public void onRouteChanged(
    @NonNull MediaRouter router,
    @NonNull MediaRouter.RouteInfo route
)

Called when a property of the indicated media route has changed.

Parameters
@NonNull MediaRouter router

The media router reporting the event.

@NonNull MediaRouter.RouteInfo route

The route that was changed.

onRouteConnected

Added in 1.8.0-alpha01
public void onRouteConnected(
    @NonNull MediaRouter router,
    @NonNull MediaRouter.RouteInfo connectedRoute,
    @NonNull MediaRouter.RouteInfo requestedRoute
)

Called when the supplied media route becomes connected.

Route connection doesn't affect the selected route. Apps can keep their selected routes while connecting to other routes.

Parameters
@NonNull MediaRouter router

the media router reporting the event.

@NonNull MediaRouter.RouteInfo connectedRoute

the route that has been connected.

@NonNull MediaRouter.RouteInfo requestedRoute

the route that was requested to be connected.

onRouteDisconnected

Added in 1.8.0-alpha01
public void onRouteDisconnected(
    @NonNull MediaRouter router,
    @NonNull MediaRouter.RouteInfo route,
    int reason
)

Called when the supplied media route becomes disconnected.

Route disconnection doesn't affect the selected route. Apps can keep their selected route while disconnecting other connected routes.

Parameters
@NonNull MediaRouter router

the media router reporting the event.

@NonNull MediaRouter.RouteInfo route

the route that has been disconnected.

int reason

the reason for disconnecting the route.

onRoutePresentationDisplayChanged

Added in 1.1.0
public void onRoutePresentationDisplayChanged(
    @NonNull MediaRouter router,
    @NonNull MediaRouter.RouteInfo route
)

Called when a media route's presentation display changes.

This method is called whenever the route's presentation display becomes available, is removed or has changes to some of its properties (such as its size).

Parameters
@NonNull MediaRouter router

The media router reporting the event.

@NonNull MediaRouter.RouteInfo route

The route whose presentation display changed.

onRouteRemoved

Added in 1.1.0
public void onRouteRemoved(
    @NonNull MediaRouter router,
    @NonNull MediaRouter.RouteInfo route
)

Called when a media route has been removed.

Parameters
@NonNull MediaRouter router

The media router reporting the event.

@NonNull MediaRouter.RouteInfo route

The route that has been removed from availability.

onRouteSelected

Added in 1.1.0
Deprecated in 1.2.0
public void onRouteSelected(
    @NonNull MediaRouter router,
    @NonNull MediaRouter.RouteInfo route
)

Called when the supplied media route becomes selected as the active route.

Parameters
@NonNull MediaRouter router

The media router reporting the event.

@NonNull MediaRouter.RouteInfo route

The route that has been selected.

onRouteSelected

Added in 1.2.0
public void onRouteSelected(
    @NonNull MediaRouter router,
    @NonNull MediaRouter.RouteInfo route,
    int reason
)

Called when the supplied media route becomes selected as the active route.

The reason provided will be one of the following:

Parameters
@NonNull MediaRouter router

The media router reporting the event.

@NonNull MediaRouter.RouteInfo route

The route that has been selected.

int reason

The reason for unselecting the previous route.

onRouteSelected

Added in 1.2.0
public void onRouteSelected(
    @NonNull MediaRouter router,
    @NonNull MediaRouter.RouteInfo selectedRoute,
    int reason,
    @NonNull MediaRouter.RouteInfo requestedRoute
)

Called when the supplied media route becomes selected as the active route, which may be different from the route requested by selectRoute. That can happen when media transfer feature is enabled. The default implementation calls onRouteSelected with the actually selected route.

Parameters
@NonNull MediaRouter router

The media router reporting the event.

@NonNull MediaRouter.RouteInfo selectedRoute

The route that has been selected.

int reason

The reason for unselecting the previous route.

@NonNull MediaRouter.RouteInfo requestedRoute

The route that was requested to be selected.

onRouteUnselected

Added in 1.1.0
Deprecated in 1.2.0
public void onRouteUnselected(
    @NonNull MediaRouter router,
    @NonNull MediaRouter.RouteInfo route
)

Called when the supplied media route becomes unselected as the active route. For detailed reason, override onRouteUnselected instead.

Parameters
@NonNull MediaRouter router

The media router reporting the event.

@NonNull MediaRouter.RouteInfo route

The route that has been unselected.

onRouteUnselected

Added in 1.1.0
public void onRouteUnselected(
    @NonNull MediaRouter router,
    @NonNull MediaRouter.RouteInfo route,
    int reason
)

Called when the supplied media route becomes unselected as the active route. The default implementation calls onRouteUnselected.

The reason provided will be one of the following:

Parameters
@NonNull MediaRouter router

The media router reporting the event.

@NonNull MediaRouter.RouteInfo route

The route that has been unselected.

int reason

The reason for unselecting the route.

onRouteVolumeChanged

Added in 1.1.0
public void onRouteVolumeChanged(
    @NonNull MediaRouter router,
    @NonNull MediaRouter.RouteInfo route
)

Called when a media route's volume changes.

Parameters
@NonNull MediaRouter router

The media router reporting the event.

@NonNull MediaRouter.RouteInfo route

The route whose volume changed.