use of android.support.v7.media.MediaRouteSelector in project AndroidChromium by JackyAndroid.
the class MediaRouteControllerDialogManager method openDialogInternal.
@Override
protected DialogFragment openDialogInternal(FragmentManager fm) {
if (fm.findFragmentByTag(DIALOG_FRAGMENT_TAG) != null)
return null;
Fragment fragment = new Fragment(this, mCallback);
MediaRouteSelector selector = mediaSource().buildRouteSelector();
if (selector == null)
return null;
androidMediaRouter().addCallback(selector, mCallback);
fragment.show(fm, DIALOG_FRAGMENT_TAG);
fm.executePendingTransactions();
return fragment;
}
use of android.support.v7.media.MediaRouteSelector in project MediaRouter-Cast-Button-android by googlecast.
the class MediaRouterCustomDialogActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.media_router_action_bar_button);
mCustomMediaRouteDialogFactory = new CustomMediaRouteDialogFactory();
mMediaRouter = MediaRouter.getInstance(getApplicationContext());
// Create a MediaRouteSelector for the type of routes your app supports
mMediaRouteSelector = new MediaRouteSelector.Builder().addControlCategory(CastMediaControlIntent.categoryForCast(getResources().getString(R.string.app_id))).build();
// Create a MediaRouter callback for discovery events
mMediaRouterCallback = new MyMediaRouterCallback();
}
use of android.support.v7.media.MediaRouteSelector in project MediaRouter-Cast-Button-android by googlecast.
the class MediaRouterDiscoveryActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.media_router_discovery);
// Create a list control for displaying the names of the
// devices discovered by the MediaRouter
final ListView listview = (ListView) findViewById(R.id.listview);
mRouteNames = new ArrayList<String>();
mAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mRouteNames);
listview.setAdapter(mAdapter);
listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, final View view, int position, long id) {
Log.d(TAG, "onItemClick: position=" + position);
MediaRouter.RouteInfo info = mRouteInfos.get(position);
mMediaRouter.selectRoute(info);
}
});
mMediaRouter = MediaRouter.getInstance(getApplicationContext());
// Create a MediaRouteSelector for the type of routes your app supports
mMediaRouteSelector = new MediaRouteSelector.Builder().addControlCategory(CastMediaControlIntent.categoryForCast(getResources().getString(R.string.app_id))).build();
// Create a MediaRouter callback for discovery events
mMediaRouterCallback = new MyMediaRouterCallback();
}
use of android.support.v7.media.MediaRouteSelector in project AndroidChromium by JackyAndroid.
the class MediaRouteChooserDialogManager method openDialogInternal.
@Override
protected DialogFragment openDialogInternal(FragmentManager fm) {
if (fm.findFragmentByTag(DIALOG_FRAGMENT_TAG) != null)
return null;
Fragment fragment = new Fragment(this);
MediaRouteSelector selector = mediaSource().buildRouteSelector();
if (selector == null)
return null;
fragment.setRouteSelector(selector);
fragment.show(fm, DIALOG_FRAGMENT_TAG);
fm.executePendingTransactions();
return fragment;
}
use of android.support.v7.media.MediaRouteSelector in project AndroidChromium by JackyAndroid.
the class CastMediaRouteProvider method startObservingMediaSinks.
@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);
}
Aggregations