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

OnPrepareTransferListener

interface OnPrepareTransferListener
androidx.mediarouter.media.MediaRouter.OnPrepareTransferListener

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

Summary

Public methods
abstract Unit
onPrepareTransfer(@NonNull fromRoute: MediaRouter.RouteInfo, @NonNull toRoute: MediaRouter.RouteInfo, @NonNull transferNotifier: MediaRouter.TransferNotifier)

Implement this to handle transfer seamlessly.

Public methods

onPrepareTransfer

abstract fun onPrepareTransfer(
    @NonNull fromRoute: MediaRouter.RouteInfo,
    @NonNull toRoute: MediaRouter.RouteInfo,
    @NonNull transferNotifier: MediaRouter.TransferNotifier
): Unit

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 TransferNotifier#notifyPrepareFinished() to stop media being played on the previous route and release resources.

Callback#onRouteUnselected(MediaRouter, RouteInfo, int) and Callback#onRouteSelected(MediaRouter, RouteInfo, int) are called just after this is called and the selected route is changed. You may begin transferring media when 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.