Java Code Examples for android.support.v7.media.MediaRouter.RouteInfo#matchesSelector()
The following examples show how to use
android.support.v7.media.MediaRouter.RouteInfo#matchesSelector() .
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: 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 2
Source File: CastMediaRouteProvider.java From AndroidChromium 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 3
Source File: CastMediaRouteProvider.java From 365browser with Apache License 2.0 | 4 votes |
@Override public void startObservingMediaSinks(String sourceId) { if (mAndroidMediaRouter == null) { // If the MediaRouter API is not available, report no devices so the page doesn't even // try to cast. onSinksReceived(sourceId, new ArrayList<MediaSink>()); return; } MediaSource source = MediaSource.from(sourceId); if (source == null) { // If the source is invalid, report no devices available. onSinksReceived(sourceId, new ArrayList<MediaSink>()); 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); }