Google 致力于为黑人社区推动种族平等。查看具体举措


interface OnPrepareTransferListener

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


Public methods
abstract ListenableFuture<Void!>?
onPrepareTransfer(@NonNull fromRoute: MediaRouter.RouteInfo, @NonNull toRoute: MediaRouter.RouteInfo)

Implement this to handle transfer seamlessly.

Public methods


@Nullable @MainThread abstract fun onPrepareTransfer(
    @NonNull fromRoute: MediaRouter.RouteInfo,
    @NonNull toRoute: MediaRouter.RouteInfo
): ListenableFuture<Void!>?

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 the transfer is prepared, finish the returned future to stop media being played on the previous route and release resources. This method is called on the main thread.

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.

fromRoute MediaRouter.RouteInfo: The route that is about to be unselected.
toRoute MediaRouter.RouteInfo: The route that is about to be selected.
ListenableFuture<Void!>? A ListenableFuture whose completion indicates that the transfer is prepared or null to indicate that no preparation is needed. If a future is returned until the future is complete, the media continues to be played on the previous route.