Search in sources :

Example 1 with MediaRouteSelector

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;
}
Also used : MediaRouteSelector(android.support.v7.media.MediaRouteSelector) MediaRouteControllerDialogFragment(android.support.v7.app.MediaRouteControllerDialogFragment) DialogFragment(android.support.v4.app.DialogFragment)

Example 2 with MediaRouteSelector

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();
}
Also used : MediaRouteSelector(android.support.v7.media.MediaRouteSelector) CustomMediaRouteDialogFactory(com.example.mediarouter.mediaroutedialog.CustomMediaRouteDialogFactory)

Example 3 with MediaRouteSelector

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();
}
Also used : View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) MediaRouteSelector(android.support.v7.media.MediaRouteSelector) ListView(android.widget.ListView) AdapterView(android.widget.AdapterView) RouteInfo(android.support.v7.media.MediaRouter.RouteInfo)

Example 4 with MediaRouteSelector

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;
}
Also used : MediaRouteSelector(android.support.v7.media.MediaRouteSelector) MediaRouteChooserDialogFragment(android.support.v7.app.MediaRouteChooserDialogFragment) DialogFragment(android.support.v4.app.DialogFragment)

Example 5 with MediaRouteSelector

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);
}
Also used : MediaRouteSelector(android.support.v7.media.MediaRouteSelector) ArrayList(java.util.ArrayList) RouteInfo(android.support.v7.media.MediaRouter.RouteInfo)

Aggregations

MediaRouteSelector (android.support.v7.media.MediaRouteSelector)5 DialogFragment (android.support.v4.app.DialogFragment)2 RouteInfo (android.support.v7.media.MediaRouter.RouteInfo)2 MediaRouteChooserDialogFragment (android.support.v7.app.MediaRouteChooserDialogFragment)1 MediaRouteControllerDialogFragment (android.support.v7.app.MediaRouteControllerDialogFragment)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 ListView (android.widget.ListView)1 CustomMediaRouteDialogFactory (com.example.mediarouter.mediaroutedialog.CustomMediaRouteDialogFactory)1 ArrayList (java.util.ArrayList)1