public MediaRouterRouteInfoAssert hasId(String id) { isNotNull(); String actualId = actual.getId(); assertThat(actualId) // .overridingErrorMessage("Expected id <%s> but was <%s>.", id, actualId) // .isEqualTo(id); return this; }
@Override protected void onRouteUnselectedEvent(MediaRouter router, RouteInfo route) { Log.d(TAG, "Unselected route %s", route); // Preserve our best guess as to the final position; this is needed to reset the // local position while switching back to local playback. mPositionExtrapolator.onPaused(); if (getCurrentRoute() != null && route.getId().equals(getCurrentRoute().getId())) { clearStreamState(); } }
@Override public void onRouteUnselected(MediaRouter router, RouteInfo route) { onRouteUnselectedEvent(router, route); if (getCurrentRoute() != null && !getCurrentRoute().isDefault() && route.getId().equals(getCurrentRoute().getId())) { RecordCastAction.castEndedTimeRemaining(getDuration(), getDuration() - getPosition()); release(); } } }
private void sendControlIntent(final Intent intent, final ResultBundleHandler bundleHandler) { Log.d(TAG, "Sending intent to %s %s", getCurrentRoute().getName(), getCurrentRoute().getId()); logIntent("sendControlIntent ", intent); if (getCurrentRoute().isDefault()) { Log.d(TAG, "Route is default, not sending"); return; } getCurrentRoute().sendControlRequest(intent, new MediaRouter.ControlRequestCallback() { @Override public void onResult(Bundle data) { if (data != null && bundleHandler != null) bundleHandler.onResult(data); } @Override public void onError(String message, Bundle data) { logControlRequestError(intent, message, data); int errorCode = 0; if (data != null) { errorCode = data.getInt(CastMediaControlIntent.EXTRA_ERROR_CODE); } sendErrorToListeners(errorCode); if (bundleHandler != null) bundleHandler.onError(message, data); } }); }
/** * @param route The route information provided by Android. * @return A new MediaSink instance corresponding to the specified {@link RouteInfo}. */ public static MediaSink fromRoute(MediaRouter.RouteInfo route) { return new MediaSink( route.getId(), route.getName(), CastDevice.getFromBundle(route.getExtras())); }
@RemovableInRelease private void logRoute(String message, RouteInfo route) { if (route != null) { Log.d(TAG, message + " " + route.getName() + " " + route.getId()); } }