android.support.v7.media.MediaRouter.RouteInfo Java Examples
The following examples show how to use
android.support.v7.media.MediaRouter.RouteInfo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainActivity.java From android-MediaRouter with Apache License 2.0 | 6 votes |
private void updateButtons() { MediaRouter.RouteInfo route = mMediaRouter.getSelectedRoute(); // show pause or resume icon depending on current state mPauseResumeButton.setImageResource( mPaused ? R.drawable.ic_action_play : R.drawable.ic_action_pause); // disable pause/resume/stop if no session mPauseResumeButton.setEnabled(mSessionManager.hasSession()); mStopButton.setEnabled(mSessionManager.hasSession()); // only enable seek bar when duration is known PlaylistItem item = getCheckedPlaylistItem(); mSeekBar.setEnabled(item != null && item.getDuration() > 0); if (mRemoteControlClient != null) { mRemoteControlClient.setPlaybackState(mPaused ? RemoteControlClient.PLAYSTATE_PAUSED : RemoteControlClient.PLAYSTATE_PLAYING); } }
Example #2
Source File: CastMediaRouterCallback.java From android with Apache License 2.0 | 6 votes |
@Override public void onRouteAdded(MediaRouter router, RouteInfo route) { super.onRouteAdded(router, route); if (!router.getDefaultRoute().equals(route)) { if (++mRouteCount == 1) { BaseCastManager.getCastManager().onCastAvailabilityChanged(true); } selectDeviceInterface.onCastDeviceDetected(route); } if (BaseCastManager.getCastManager().getReconnectionStatus() == ReconnectionStatus.STARTED) { String routeId = Utils.getStringFromPreference(mContext, BaseCastManager.PREFS_KEY_ROUTE_ID); if (route.getId().equals(routeId)) { // we found the route, so lets go with that LOGD(TAG, "onRouteAdded: Attempting to recover a session with info=" + route); BaseCastManager.getCastManager().setReconnectionStatus( ReconnectionStatus.IN_PROGRESS); CastDevice device = CastDevice.getFromBundle(route.getExtras()); LOGD(TAG, "onRouteAdded: Attempting to recover a session with device: " + device.getFriendlyName()); selectDeviceInterface.onDeviceSelected(device); } } }
Example #3
Source File: BaseCastManager.java From android with Apache License 2.0 | 6 votes |
private void reconnectSessionIfPossibleInternal(RouteInfo theRoute) { if (isConnected()) { return; } String sessionId = Utils.getStringFromPreference(mContext, PREFS_KEY_SESSION_ID); String routeId = Utils.getStringFromPreference(mContext, PREFS_KEY_ROUTE_ID); LOGD(TAG, "reconnectSessionIfPossible() Retrieved from preferences: " + "sessionId=" + sessionId + ", routeId=" + routeId); if (null == sessionId || null == routeId) { return; } mReconnectionStatus = ReconnectionStatus.IN_PROGRESS; CastDevice device = CastDevice.getFromBundle(theRoute.getExtras()); if (null != device) { LOGD(TAG, "trying to acquire Cast Client for " + device); onDeviceSelected(device); } }
Example #4
Source File: DefaultMediaRouteController.java From 365browser with Apache License 2.0 | 6 votes |
@Override protected void onRouteSelectedEvent(MediaRouter router, RouteInfo route) { Log.d(TAG, "Selected route %s", route); if (!route.isSelected()) return; RecordCastAction.castPlayRequested(); RecordCastAction.remotePlaybackDeviceSelected( RecordCastAction.DEVICE_TYPE_CAST_GENERIC); installBroadcastReceivers(); if (getMediaStateListener() == null) { showCastError(route.getName()); release(); return; } if (route != getCurrentRoute()) { registerRoute(route); clearStreamState(); } mPositionExtrapolator.clear(); notifyRouteSelected(route); }
Example #5
Source File: DefaultMediaRouteController.java From AndroidChromium with Apache License 2.0 | 6 votes |
@Override protected void onRouteSelectedEvent(MediaRouter router, RouteInfo route) { Log.d(TAG, "Selected route %s", route); if (!route.isSelected()) return; RecordCastAction.castPlayRequested(); RecordCastAction.remotePlaybackDeviceSelected( RecordCastAction.DEVICE_TYPE_CAST_GENERIC); installBroadcastReceivers(); if (getMediaStateListener() == null) { showCastError(route.getName()); release(); return; } if (route != getCurrentRoute()) { registerRoute(route); clearStreamState(); } mPositionExtrapolator.clear(); notifyRouteSelected(route); }
Example #6
Source File: AbstractMediaRouteController.java From 365browser with Apache License 2.0 | 6 votes |
@Override public void onRouteChanged(MediaRouter router, RouteInfo route) { // We only care about changes to the current route. if (!route.equals(getCurrentRoute())) return; // When there is no wifi connection, this condition becomes true. if (route.isConnecting()) { // We don't want to post the same Runnable twice. if (!mConnectionFailureNotifierQueued) { mConnectionFailureNotifierQueued = true; getHandler().postDelayed(mConnectionFailureNotifier, CONNECTION_FAILURE_NOTIFICATION_DELAY_MS); } } else { // Only cancel the disconnect if we already posted the message. We can get into this // situation if we swap the current route provider (for example, switching to a YT // video while casting a non-YT video). if (mConnectionFailureNotifierQueued) { // We have reconnected, cancel the delayed disconnect. getHandler().removeCallbacks(mConnectionFailureNotifier); mConnectionFailureNotifierQueued = false; } } }
Example #7
Source File: BaseCastManager.java From UTubeTV with The Unlicense | 6 votes |
private void reconnectSessionIfPossibleInternal(RouteInfo theRoute) { if (isConnected()) { return; } String sessionId = CastUtils.getStringFromPreference(mContext, PREFS_KEY_SESSION_ID); String routeId = CastUtils.getStringFromPreference(mContext, PREFS_KEY_ROUTE_ID); CastUtils.LOGD(TAG, "reconnectSessionIfPossible() Retrieved from preferences: " + "sessionId=" + sessionId + ", routeId=" + routeId); if (null == sessionId || null == routeId) { return; } mReconnectionStatus = ReconnectionStatus.IN_PROGRESS; CastDevice device = CastDevice.getFromBundle(theRoute.getExtras()); if (null != device) { CastUtils.LOGD(TAG, "trying to acquire Cast Client for " + device); onDeviceSelected(device); } }
Example #8
Source File: AbstractMediaRouteController.java From delion with Apache License 2.0 | 6 votes |
@Override public void onRouteChanged(MediaRouter router, RouteInfo route) { // We only care about changes to the current route. if (!route.equals(getCurrentRoute())) return; // When there is no wifi connection, this condition becomes true. if (route.isConnecting()) { // We don't want to post the same Runnable twice. if (!mConnectionFailureNotifierQueued) { mConnectionFailureNotifierQueued = true; getHandler().postDelayed(mConnectionFailureNotifier, CONNECTION_FAILURE_NOTIFICATION_DELAY_MS); } } else { // Only cancel the disconnect if we already posted the message. We can get into this // situation if we swap the current route provider (for example, switching to a YT // video while casting a non-YT video). if (mConnectionFailureNotifierQueued) { // We have reconnected, cancel the delayed disconnect. getHandler().removeCallbacks(mConnectionFailureNotifier); mConnectionFailureNotifierQueued = false; } } }
Example #9
Source File: AbstractMediaRouteController.java From AndroidChromium with Apache License 2.0 | 6 votes |
@Override public void onRouteChanged(MediaRouter router, RouteInfo route) { // We only care about changes to the current route. if (!route.equals(getCurrentRoute())) return; // When there is no wifi connection, this condition becomes true. if (route.isConnecting()) { // We don't want to post the same Runnable twice. if (!mConnectionFailureNotifierQueued) { mConnectionFailureNotifierQueued = true; getHandler().postDelayed(mConnectionFailureNotifier, CONNECTION_FAILURE_NOTIFICATION_DELAY_MS); } } else { // Only cancel the disconnect if we already posted the message. We can get into this // situation if we swap the current route provider (for example, switching to a YT // video while casting a non-YT video). if (mConnectionFailureNotifierQueued) { // We have reconnected, cancel the delayed disconnect. getHandler().removeCallbacks(mConnectionFailureNotifier); mConnectionFailureNotifierQueued = false; } } }
Example #10
Source File: DefaultMediaRouteController.java From delion with Apache License 2.0 | 6 votes |
@Override protected void onRouteSelectedEvent(MediaRouter router, RouteInfo route) { Log.d(TAG, "Selected route %s", route); if (!route.isSelected()) return; RecordCastAction.castPlayRequested(); RecordCastAction.remotePlaybackDeviceSelected( RecordCastAction.DEVICE_TYPE_CAST_GENERIC); installBroadcastReceivers(); if (getMediaStateListener() == null) { showCastError(route.getName()); release(); return; } if (route != getCurrentRoute()) { registerRoute(route); clearStreamState(); } mPositionExtrapolator.clear(); notifyRouteSelected(route); }
Example #11
Source File: SampleMediaRouterActivity.java From V.FlyoutTest with MIT License | 5 votes |
private void updateButtons() { MediaRouter.RouteInfo route = mMediaRouter.getSelectedRoute(); // show pause or resume icon depending on current state mPauseResumeButton.setImageResource(mSessionManager.isPaused() ? R.drawable.ic_media_play : R.drawable.ic_media_pause); // only enable seek bar when duration is known PlaylistItem item = getCheckedPlaylistItem(); mSeekBar.setEnabled(item != null && item.getDuration() > 0); if (mRemoteControlClient != null) { mRemoteControlClient.setPlaybackState(mSessionManager.isPaused() ? RemoteControlClient.PLAYSTATE_PAUSED : RemoteControlClient.PLAYSTATE_PLAYING); } }
Example #12
Source File: CastMediaRouteProvider.java From delion with Apache License 2.0 | 5 votes |
@Override public void startObservingMediaSinks(String sourceId) { if (mAndroidMediaRouter == null) return; MediaSource source = MediaSource.from(sourceId); if (source == null) return; MediaRouteSelector routeSelector = source.buildRouteSelector(); if (routeSelector == null) { // If the application invalid, report no devices available. onSinksReceived(sourceId, new ArrayList<MediaSink>()); return; } String applicationId = source.getApplicationId(); DiscoveryCallback callback = mDiscoveryCallbacks.get(applicationId); if (callback != null) { callback.addSourceUrn(sourceId); return; } List<MediaSink> knownSinks = new ArrayList<MediaSink>(); for (RouteInfo route : mAndroidMediaRouter.getRoutes()) { if (route.matchesSelector(routeSelector)) { knownSinks.add(MediaSink.fromRoute(route)); } } callback = new DiscoveryCallback(sourceId, knownSinks, this, routeSelector); mAndroidMediaRouter.addCallback( routeSelector, callback, MediaRouter.CALLBACK_FLAG_REQUEST_DISCOVERY); mDiscoveryCallbacks.put(applicationId, callback); }
Example #13
Source File: AbstractMediaRouteController.java From AndroidChromium with Apache License 2.0 | 5 votes |
@Override public final boolean isRemotePlaybackAvailable() { if (mediaRouterInitializationFailed()) return false; return getMediaRouter().getSelectedRoute().getPlaybackType() == MediaRouter.RouteInfo.PLAYBACK_TYPE_REMOTE || getMediaRouter().isRouteAvailable( mMediaRouteSelector, MediaRouter.AVAILABILITY_FLAG_IGNORE_DEFAULT_ROUTE); }
Example #14
Source File: AbstractMediaRouteController.java From AndroidChromium with Apache License 2.0 | 5 votes |
@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(); } }
Example #15
Source File: MediaSink.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * @param sinkId The id of the sink to find among known media routes. * @param router The instance of {@link MediaRouter} to enumerate the routes with. * @return A {@link MediaSink} corresponding to the {@link RouteInfo} with the specified id if * found, null otherwise. */ @Nullable public static MediaSink fromSinkId(String sinkId, MediaRouter router) { for (MediaRouter.RouteInfo route : router.getRoutes()) { MediaSink sink = MediaSink.fromRoute(route); if (sink.getId().equals(sinkId)) return sink; } return null; }
Example #16
Source File: DefaultMediaRouteController.java From AndroidChromium with Apache License 2.0 | 5 votes |
@Override public void setRemoteVolume(int delta) { boolean canChangeRemoteVolume = (getCurrentRoute().getVolumeHandling() == MediaRouter.RouteInfo.PLAYBACK_VOLUME_VARIABLE); if (currentRouteSupportsRemotePlayback() && canChangeRemoteVolume) { getCurrentRoute().requestUpdateVolume(delta); } }
Example #17
Source File: BaseCastManager.java From android with Apache License 2.0 | 5 votes |
@Override public void onCastDeviceDetected(RouteInfo info) { if (null != mBaseCastConsumers) { synchronized (mBaseCastConsumers) { for (IBaseCastConsumer consumer : mBaseCastConsumers) { try { consumer.onCastDeviceDetected(info); } catch (Exception e) { LOGE(TAG, "onCastDeviceDetected(): Failed to inform " + consumer, e); } } } } }
Example #18
Source File: SampleMediaRouterActivity.java From V.FlyoutTest with MIT License | 5 votes |
@Override public void onRouteSelected(MediaRouter router, RouteInfo route) { Log.d(TAG, "onRouteSelected: route=" + route); mPlayer = Player.create(SampleMediaRouterActivity.this, route); mPlayer.updatePresentation(); mSessionManager.setPlayer(mPlayer); mSessionManager.unsuspend(); registerRCC(); updateUi(); }
Example #19
Source File: CastMediaRouterCallback.java From UTubeTV with The Unlicense | 5 votes |
@Override public void onRouteSelected(MediaRouter router, RouteInfo info) { CastUtils.LOGD(TAG, "onRouteSelected: info=" + info); if (BaseCastManager.getCastManager() .getReconnectionStatus() == BaseCastManager.ReconnectionStatus.FINALIZE) { BaseCastManager.getCastManager().setReconnectionStatus(ReconnectionStatus.INACTIVE); BaseCastManager.getCastManager().cancelReconnectionTask(); return; } CastUtils.saveStringToPreference(mContext, BaseCastManager.PREFS_KEY_ROUTE_ID, info.getId()); CastDevice device = CastDevice.getFromBundle(info.getExtras()); selectDeviceInterface.onDeviceSelected(device); CastUtils.LOGD(TAG, "onResult: mSelectedDevice=" + device.getFriendlyName()); }
Example #20
Source File: CastMediaRouterCallback.java From android with Apache License 2.0 | 5 votes |
@Override public void onRouteRemoved(MediaRouter router, RouteInfo route) { super.onRouteRemoved(router, route); if (--mRouteCount == 0) { BaseCastManager.getCastManager().onCastAvailabilityChanged(false); } }
Example #21
Source File: DefaultMediaRouteController.java From 365browser with Apache License 2.0 | 5 votes |
@Override public void setRemoteVolume(int delta) { boolean canChangeRemoteVolume = (getCurrentRoute().getVolumeHandling() == MediaRouter.RouteInfo.PLAYBACK_VOLUME_VARIABLE); if (currentRouteSupportsRemotePlayback() && canChangeRemoteVolume) { getCurrentRoute().requestUpdateVolume(delta); } }
Example #22
Source File: MainActivity.java From android-MediaRouter with Apache License 2.0 | 5 votes |
private void updateRouteDescription() { RouteInfo route = mMediaRouter.getSelectedRoute(); mInfoTextView.setText( "Currently selected route:" + "\nName: " + route.getName() + "\nProvider: " + route.getProvider().getPackageName() + "\nDescription: " + route.getDescription() + "\nStatistics: " + mSessionManager.getStatistics()); }
Example #23
Source File: MainActivity.java From AndroidDemoProjects with Apache License 2.0 | 5 votes |
@Override public void onRouteSelected(MediaRouter router, RouteInfo info) { initCastClientListener(); initRemoteMediaPlayer(); mSelectedDevice = CastDevice.getFromBundle( info.getExtras() ); launchReceiver(); }
Example #24
Source File: AbstractMediaRouteController.java From 365browser with Apache License 2.0 | 5 votes |
@Override public final boolean isRemotePlaybackAvailable() { if (mediaRouterInitializationFailed()) return false; return getMediaRouter().getSelectedRoute().getPlaybackType() == MediaRouter.RouteInfo.PLAYBACK_TYPE_REMOTE || getMediaRouter().isRouteAvailable( mMediaRouteSelector, MediaRouter.AVAILABILITY_FLAG_IGNORE_DEFAULT_ROUTE); }
Example #25
Source File: AbstractMediaRouteController.java From 365browser with Apache License 2.0 | 5 votes |
protected final void notifyRouteSelected(RouteInfo route) { for (UiListener listener : mUiListeners) { listener.onRouteSelected(route.getName(), this); } if (!canCastMedia()) return; if (mMediaStateListener == null) return; mMediaStateListener.pauseLocal(); mMediaStateListener.onCastStarting(route.getName()); startCastingVideo(); }
Example #26
Source File: RemotePlayer.java From V.FlyoutTest with MIT License | 5 votes |
@Override public void connect(RouteInfo route) { mRoute = route; mClient = new RemotePlaybackClient(mContext, route); mClient.setStatusCallback(mStatusCallback); if (DEBUG) { Log.d(TAG, "connected to: " + route + ", isRemotePlaybackSupported: " + mClient.isRemotePlaybackSupported() + ", isQueuingSupported: "+ mClient.isQueuingSupported()); } }
Example #27
Source File: MediaSink.java From 365browser with Apache License 2.0 | 5 votes |
/** * @param sinkId The id of the sink to find among known media routes. * @param router The instance of {@link MediaRouter} to enumerate the routes with. * @return A {@link MediaSink} corresponding to the {@link RouteInfo} with the specified id if * found, null otherwise. */ @Nullable public static MediaSink fromSinkId(String sinkId, MediaRouter router) { for (MediaRouter.RouteInfo route : router.getRoutes()) { MediaSink sink = MediaSink.fromRoute(route); if (sink.getId().equals(sinkId)) return sink; } return null; }
Example #28
Source File: RemotePlayer.java From android-MediaRouter with Apache License 2.0 | 5 votes |
@Override public void connect(RouteInfo route) { mRoute = route; mClient = new RemotePlaybackClient(mContext, route); mClient.setStatusCallback(mStatusCallback); if (DEBUG) { Log.d(TAG, "connected to: " + route + ", isRemotePlaybackSupported: " + mClient.isRemotePlaybackSupported() + ", isQueuingSupported: "+ mClient.isQueuingSupported()); } }
Example #29
Source File: MainActivity.java From android-MediaRouter with Apache License 2.0 | 5 votes |
@Override public void onRouteUnselected(MediaRouter router, RouteInfo route) { Log.d(TAG, "onRouteUnselected: route=" + route); unregisterRemoteControlClient(); PlaylistItem item = getCheckedPlaylistItem(); if (item != null) { long pos = item.getPosition() + (mPaused ? 0 : (SystemClock.elapsedRealtime() - item.getTimestamp())); mSessionManager.suspend(pos); } mPlayer.updatePresentation(); mPlayer.release(); }
Example #30
Source File: DefaultMediaRouteController.java From delion with Apache License 2.0 | 5 votes |
@Override public void setRemoteVolume(int delta) { boolean canChangeRemoteVolume = (getCurrentRoute().getVolumeHandling() == MediaRouter.RouteInfo.PLAYBACK_VOLUME_VARIABLE); if (currentRouteSupportsRemotePlayback() && canChangeRemoteVolume) { getCurrentRoute().requestUpdateVolume(delta); } }