Google is committed to advancing racial equity for Black communities. See how.

MediaRouter.OnPrepareTransferListener

public static interface MediaRouter.OnPrepareTransferListener

androidx.mediarouter.media.MediaRouter.OnPrepareTransferListener


Listener for receiving events when the selected route is about to be changed.

Summary

Public methods

abstract void onPrepareTransfer(MediaRouter.RouteInfo fromRoute, MediaRouter.RouteInfo toRoute, MediaRouter.TransferNotifier transferNotifier)

Implement this to handle transfer seamlessly.

Public methods

onPrepareTransfer

public abstract void onPrepareTransfer (MediaRouter.RouteInfo fromRoute, 
                MediaRouter.RouteInfo toRoute, 
                MediaRouter.TransferNotifier transferNotifier)

Implement this to handle transfer seamlessly.

Setting the listener will defer stopping the previous route, from which you may get the media status to resume media seamlessly on the new route. When transfer is prepared call MediaRouter.TransferNotifier.notifyPrepareFinished() to stop media being played on the previous route and release resources.

MediaRouter.Callback.onRouteUnselected(MediaRouter, RouteInfo, int) and MediaRouter.Callback.onRouteSelected(MediaRouter, RouteInfo, int) are called just after this is called and the selected route is changed. You may begin transferring media when MediaRouter.Callback.onRouteSelected(MediaRouter, RouteInfo, int) is called.

Parameters
fromRoute MediaRouter.RouteInfo: The route that is about to be unselected.

toRoute MediaRouter.RouteInfo: The route that is about to be selected.

transferNotifier MediaRouter.TransferNotifier: the object used to notify finish of preparation.