Java Code Examples for android.support.v7.app.MediaRouteActionProvider

The following are top voted examples for showing how to use android.support.v7.app.MediaRouteActionProvider. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Android-app   File: VideoPlayerActivity.java   View source code 6 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);

    // Inflate the menu and configure the media router action provider.
    getMenuInflater().inflate(R.menu.media_route_menu_item, menu);

    // Attach the MediaRouteSelector to the menu item
    MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item);
    MediaRouteActionProvider mediaRouteActionProvider =
            (MediaRouteActionProvider)MenuItemCompat.getActionProvider(
                    mediaRouteMenuItem);
    // Attach the MediaRouteSelector that you built in onCreate()
    mediaRouteActionProvider.setRouteSelector(mSelector);

    // Return true to show the menu.
    return true;
}
 
Example 2
Project: Pocket-Plays-for-Twitch   File: StreamFragment.java   View source code 6 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
	super.onCreateOptionsMenu(menu, inflater);
	if (!embedded) {
		// Only add chromecast btn for live streams
		if (vodId == null) {
			mCastManager.addMediaRouterButton(menu, R.id.media_route_menu_item);

			MenuItem routeItem = menu.findItem(R.id.media_route_menu_item);
			MediaRouteActionProvider mediaRouteButton = (MediaRouteActionProvider) MenuItemCompat.getActionProvider(routeItem);
			mediaRouteButton.setDialogFactory(mMediaRouteDialogFactory);
		}

		optionsMenuItem = menu.findItem(R.id.menu_item_options);
		optionsMenuItem.setVisible(false);
		optionsMenuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
			@Override
			public boolean onMenuItemClick(MenuItem menuItem) {
				if (mQualityButton != null) {
					mQualityButton.performClick();
				}
				return true;
			}
		});
	}
}
 
Example 3
Project: android-cast-remote-display-sample   File: MainActivity.java   View source code 6 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
  MenuInflater inflater = getMenuInflater();
  inflater.inflate(R.menu.activity_main_actions, menu);

  if (mediaRouteSelector != null) {
    MenuItem mediaRouteMenuItem = menu.findItem(R.id.action_cast);
    if (MenuItemCompat.getActionProvider(
        mediaRouteMenuItem) instanceof MediaRouteActionProvider) {
      MediaRouteActionProvider mediaRouteActionProvider =
          (MediaRouteActionProvider) MenuItemCompat.getActionProvider(mediaRouteMenuItem);
      mediaRouteActionProvider.setRouteSelector(mediaRouteSelector);
    }
  }
  return true;
}
 
Example 4
Project: PinCast-Sender-Android   File: PinCastActivity.java   View source code 6 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {

    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.main, menu);
    MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item);

    MediaRouteActionProvider mediaRouteActionProvider
            = (MediaRouteActionProvider) MenuItemCompat
            .getActionProvider(mediaRouteMenuItem);

    // Set the MediaRouteActionProvider selector to discover devices.
    mediaRouteActionProvider.setRouteSelector(mMediaRouteSelector);

    return true;
}
 
Example 5
Project: informant-droid   File: SampleMediaRouterActivity.java   View source code 6 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Be sure to call the super class.
    super.onCreateOptionsMenu(menu);

    // Inflate the menu and configure the media router action provider.
    getMenuInflater().inflate(R.menu.sample_media_router_menu, menu);

    MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item);
    MediaRouteActionProvider mediaRouteActionProvider =
            (MediaRouteActionProvider)MenuItemCompat.getActionProvider(mediaRouteMenuItem);
    mediaRouteActionProvider.setRouteSelector(mSelector);

    // Return true to show the menu.
    return true;
}
 
Example 6
Project: aos-Video   File: VideoInfoActivityFragment.java   View source code 5 votes vote down vote up
@Override
public void onResume() {
    if(ArchosVideoCastManager.isCastAvailable()) {
        mMediaRouteSelector = new MediaRouteSelector.Builder()
                .addControlCategory(CastMediaControlIntent.categoryForCast(ArchosVideoCastManager.getInstance().appId))
                .build();
    }
    if(mIsLeavingPlayerActivity)
        StoreRatingDialogBuilder.displayStoreRatingDialogIfNeeded(getContext());
    mIsLeavingPlayerActivity = false;
    if(mMediaRouteMenuItem!=null) ((MediaRouteActionProvider) MenuItemCompat.getActionProvider(mMediaRouteMenuItem)).setRouteSelector(mMediaRouteSelector);
    super.onResume();
}
 
Example 7
Project: aos-Video   File: MainActivity.java   View source code 5 votes vote down vote up
@Override
public void onResume() {
    super.onResume();
    if(ArchosVideoCastManager.isCastAvailable()) {
        mMediaRouteSelector = new MediaRouteSelector.Builder()
                .addControlCategory(CastMediaControlIntent.categoryForCast(ArchosVideoCastManager.getInstance().appId))
                .build();
        if (mMediaRouteMenuItem != null)
            ((MediaRouteActionProvider) MenuItemCompat.getActionProvider(mMediaRouteMenuItem)).setRouteSelector(mMediaRouteSelector);
    }
    mPermissionChecker.checkAndRequestPermission(this);
    //check if app has been bought after
    if (adLayout != null)
        adLayout.resume();

    if (ArchosUtils.isFreeVersion(this)) {
        BillingUtils u = new BillingUtils(this);
        u.checkPayement(new IsPaidCallback(this) {

            @Override
            public void hasBeenPaid(int isPaid) {
                super.hasBeenPaid(isPaid);
                if (checkPayement(isPaid)) {
                    if(adLayout!=null) {
                        adLayout.setEnabled(false);
                        adLayout.setVisibility(View.GONE);
                    }else if (amazonAdLayout!=null){
                        amazonAdLayout.setEnabled(false);
                        amazonAdLayout.setVisibility(View.GONE);
                    }
                }
            }
        });
    }

    registerReceiver(mTraktRelogBroadcastReceiver,new IntentFilter(Trakt.TRAKT_ISSUE_REFRESH_TOKEN));
    getContentResolver().registerContentObserver(VideoStore.Video.Media.EXTERNAL_CONTENT_URI,
            false, mGlobalResumeContentObserver);
}
 
Example 8
Project: Pocket-Plays-for-Twitch   File: MainActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
	MenuInflater inflater = getMenuInflater();
	inflater.inflate(R.menu.menu_main_activity, menu);
	mCastManager.addMediaRouterButton(menu, R.id.media_route_menu_item);

	MenuItem routeItem = menu.findItem(R.id.media_route_menu_item);
	MediaRouteActionProvider mediaRouteButton = (MediaRouteActionProvider) MenuItemCompat.getActionProvider(routeItem);
	mediaRouteButton.setDialogFactory(mMediaRouteDialogFactory);

	return true;
}
 
Example 9
Project: Pocket-Plays-for-Twitch   File: BaseCastManager.java   View source code 5 votes vote down vote up
/**
 * Adds and wires up the Media Router cast button. It returns a reference to the Media Router
 * menu item if the caller needs such reference. It is assumed that the enclosing
 * {@link android.app.Activity} inherits (directly or indirectly) from
 * {@link android.support.v7.app.AppCompatActivity}.
 *
 * @param menu Menu reference
 * @param menuResourceId The resource id of the cast button in the xml menu descriptor file
 */
public final MenuItem addMediaRouterButton(Menu menu, int menuResourceId) {
    MenuItem mediaRouteMenuItem = menu.findItem(menuResourceId);
    MediaRouteActionProvider mediaRouteActionProvider = (MediaRouteActionProvider)
            MenuItemCompat.getActionProvider(mediaRouteMenuItem);
    mediaRouteActionProvider.setRouteSelector(mMediaRouteSelector);
    if (getMediaRouteDialogFactory() != null) {
        mediaRouteActionProvider.setDialogFactory(getMediaRouteDialogFactory());
    }
    return mediaRouteMenuItem;
}
 
Example 10
Project: OCast-Java   File: MainActivity.java   View source code 5 votes vote down vote up
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.main, menu);

    mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item);
    MediaRouteActionProvider actionProvider = (MediaRouteActionProvider) MenuItemCompat.getActionProvider(mediaRouteMenuItem);

    MediaRouteSelector.Builder builder = new MediaRouteSelector.Builder().addControlCategory(OCastMediaRouteProvider.CATEGORY_OCAST);
    MediaRouteSelector customSelector = builder.build();
    actionProvider.setRouteSelector(customSelector);

    return true;
}
 
Example 11
Project: android-tibits   File: MainActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);

    //MediaRouterButton in action bar
    getMenuInflater().inflate(R.menu.menu_main, menu);
    mVideoCastManager.addMediaRouterButton(menu, R.id.media_route_menu_item);

    MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item);
    mMenuMediaRouteActionProvider = (MediaRouteActionProvider)
            MenuItemCompat.getActionProvider(mediaRouteMenuItem);

    return true;
}
 
Example 12
Project: basscast   File: BrowseActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
    getMenuInflater().inflate(R.menu.menu_browse, menu);

    MenuItem mediaRouteMenuItem = menu.findItem(R.id.action_cast);
    MediaRouteActionProvider mediaRouteActionProvider =
            (MediaRouteActionProvider) MenuItemCompat.getActionProvider(mediaRouteMenuItem);
    mediaRouteActionProvider.setRouteSelector(mMediaRouteSelector);
    return true;
}
 
Example 13
Project: FMTech   File: kvr.java   View source code 5 votes vote down vote up
public final void a(Menu paramMenu, MenuInflater paramMenuInflater)
{
  super.a(paramMenu, paramMenuInflater);
  if (this.d == null) {}
  MediaRouteActionProvider localMediaRouteActionProvider;
  aam localaam1;
  do
  {
    do
    {
      return;
      paramMenuInflater.inflate(efj.VS, paramMenu);
      this.Z = ((MediaRouteActionProvider)mm.b(paramMenu.findItem(eyg.br)));
      localMediaRouteActionProvider = this.Z;
      localaam1 = this.d;
      if (localaam1 == null) {
        throw new IllegalArgumentException("selector must not be null");
      }
    } while (localMediaRouteActionProvider.f.equals(localaam1));
    aam localaam2 = localMediaRouteActionProvider.f;
    localaam2.a();
    if (!localaam2.b.isEmpty()) {
      localMediaRouteActionProvider.d.a(localMediaRouteActionProvider.e);
    }
    localaam1.a();
    if (!localaam1.b.isEmpty()) {
      localMediaRouteActionProvider.d.a(localaam1, localMediaRouteActionProvider.e, 0);
    }
    localMediaRouteActionProvider.f = localaam1;
    localMediaRouteActionProvider.d();
  } while (localMediaRouteActionProvider.g == null);
  localMediaRouteActionProvider.g.a(localaam1);
}
 
Example 14
Project: codelab-chromecast   File: BaseCastManager.java   View source code 5 votes vote down vote up
/**
 * Adds and wires up the Media Router cast button. It returns a pointer to the Media Router
 * menu item if the caller needs such reference. It is assumed that the enclosing
 * {@link android.app.Activity} inherits (directly or indirectly) from
 * {@link android.support.v7.app.ActionBarActivity}.
 *
 * @param menu
 * @param menuResourceId The resource id of the cast button in the xml menu descriptor file
 */
public MenuItem addMediaRouterButton(Menu menu, int menuResourceId) {
    MenuItem mediaRouteMenuItem = menu.findItem(menuResourceId);
    MediaRouteActionProvider mediaRouteActionProvider = (MediaRouteActionProvider)
            MenuItemCompat.getActionProvider(mediaRouteMenuItem);
    mediaRouteActionProvider.setRouteSelector(mMediaRouteSelector);
    if (null != getMediaRouteDialogFactory()) {
        mediaRouteActionProvider.setDialogFactory(getMediaRouteDialogFactory());
    }
    return mediaRouteMenuItem;
}
 
Example 15
Project: OpenSongTablet   File: StageMode.java   View source code 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);

    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.stage_actions, menu);

    // Setup the menu item for connecting to cast devices
    MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item);
    View mr = menu.findItem(R.id.media_route_menu_item).getActionView();
    if (mr!=null) {
        mr.setFocusable(false);
        mr.setFocusableInTouchMode(false);
    }
    MediaRouteActionProvider mediaRouteActionProvider =
            (MediaRouteActionProvider) MenuItemCompat.getActionProvider(mediaRouteMenuItem);
    if (mMediaRouteSelector != null) {
        mediaRouteActionProvider.setRouteSelector(mMediaRouteSelector);
    }

    // Force overflow icon to show, even if hardware key is present
    MenuHandlers.forceOverFlow(StageMode.this, ab, menu);

    // Set up battery monitor
    setUpBatteryMonitor();

    return true;
}
 
Example 16
Project: OpenSongTablet   File: PresenterMode.java   View source code 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);

    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.presenter_actions, menu);

    // Setup the menu item for connecting to cast devices
    // Setup the menu item for connecting to cast devices
    MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item);
    View mr = menu.findItem(R.id.media_route_menu_item).getActionView();
    if (mr!=null) {
        mr.setFocusable(false);
        mr.setFocusableInTouchMode(false);
    }
    MediaRouteActionProvider mediaRouteActionProvider =
            (MediaRouteActionProvider) MenuItemCompat.getActionProvider(mediaRouteMenuItem);
    if (mMediaRouteSelector != null) {
        mediaRouteActionProvider.setRouteSelector(mMediaRouteSelector);
    }

    // Force overflow icon to show, even if hardware key is present
    MenuHandlers.forceOverFlow(PresenterMode.this, ab, menu);

    // Set up battery monitor
    setUpBatteryMonitor();

    return true;
}
 
Example 17
Project: basscast   File: BrowseActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
    getMenuInflater().inflate(R.menu.menu_browse, menu);

    MenuItem mediaRouteMenuItem = menu.findItem(R.id.action_cast);
    MediaRouteActionProvider mediaRouteActionProvider =
            (MediaRouteActionProvider) MenuItemCompat.getActionProvider(mediaRouteMenuItem);
    mediaRouteActionProvider.setRouteSelector(mMediaRouteSelector);
    return true;
}
 
Example 18
Project: cast-codelab   File: CastActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.menu_cast, menu);

    // Step 4 (import the appcompat alternative)
    MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item);
    MediaRouteActionProvider mediaRouteActionProvider = (MediaRouteActionProvider) MenuItemCompat.getActionProvider(mediaRouteMenuItem);
    mediaRouteActionProvider.setRouteSelector(mMediaRouteSelector);
    return true;
}
 
Example 19
Project: AndroidDemoProjects   File: MainActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu( Menu menu ) {
    super.onCreateOptionsMenu( menu );
    getMenuInflater().inflate( R.menu.main, menu );
    MenuItem mediaRouteMenuItem = menu.findItem( R.id.media_route_menu_item );
    MediaRouteActionProvider mediaRouteActionProvider = (MediaRouteActionProvider) MenuItemCompat.getActionProvider( mediaRouteMenuItem );
    mediaRouteActionProvider.setRouteSelector( mMediaRouteSelector );
    return true;
}
 
Example 20
Project: castro-android   File: CastLogic.java   View source code 5 votes vote down vote up
public final void onCreateOptionsMenu(Menu menu) {
    MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item);
    MediaRouteActionProvider mediaRouteActionProvider =
            (MediaRouteActionProvider) MenuItemCompat
                    .getActionProvider(mediaRouteMenuItem);
    mediaRouteActionProvider.setRouteSelector(mState.mediaRouteSelector);
}
 
Example 21
Project: Muzik   File: PlayerActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.playermenu, menu);
    MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item);
    MediaRouteActionProvider mediaRouteActionProvider = (MediaRouteActionProvider) MenuItemCompat.getActionProvider(mediaRouteMenuItem);
    mediaRouteActionProvider.setRouteSelector(mMediaRouteSelector);
    final SharedPreferences pref = getPreferences(Context.MODE_PRIVATE);
    return true;
}
 
Example 22
Project: dojoandroidcast   File: MainActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
	super.onCreateOptionsMenu(menu);
	getMenuInflater().inflate(R.menu.main, menu);
	MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item);
	MediaRouteActionProvider mediaRouteActionProvider = (MediaRouteActionProvider) MenuItemCompat
			.getActionProvider(mediaRouteMenuItem);
	// Set the MediaRouteActionProvider selector for device discovery.
	mediaRouteActionProvider.setRouteSelector(mMediaRouteSelector);
	return true;
}
 
Example 23
Project: dojoandroidcast   File: DojoSenderActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
	super.onCreateOptionsMenu(menu);
	getMenuInflater().inflate(R.menu.main, menu);
	MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item);
	MediaRouteActionProvider mediaRouteActionProvider = (MediaRouteActionProvider) MenuItemCompat
			.getActionProvider(mediaRouteMenuItem);
	// Set the MediaRouteActionProvider selector for device discovery.
	mediaRouteActionProvider.setRouteSelector(mMediaRouteSelector);
	return true;
}
 
Example 24
Project: hello-chromecast   File: MainActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
	super.onCreateOptionsMenu(menu);
	getMenuInflater().inflate(R.menu.main, menu);
	MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item);
	MediaRouteActionProvider mediaRouteActionProvider = (MediaRouteActionProvider) MenuItemCompat.getActionProvider(mediaRouteMenuItem);
	// Set the MediaRouteActionProvider selector for device discovery.
	mediaRouteActionProvider.setRouteSelector(mMediaRouteSelector);
	return true;
}
 
Example 25
Project: Orpheus   File: BaseActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
    // Media router
    if (isCastingEnabled) {
        getMenuInflater().inflate(R.menu.cast_mediarouter_button, menu);
        // init router button
        MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item);
        MediaRouteActionProvider mediaRouteActionProvider =
                (MediaRouteActionProvider) MenuItemCompat.getActionProvider(mediaRouteMenuItem);
        mediaRouteActionProvider.setRouteSelector(mMediaRouteSelector);
    }
    return true;
}
 
Example 26
Project: android-chess   File: start.java   View source code 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
	super.onCreateOptionsMenu(menu);
	getMenuInflater().inflate(R.menu.start_topmenu, menu);
	MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item);
	MediaRouteActionProvider mediaRouteActionProvider
			= (MediaRouteActionProvider) MenuItemCompat
			.getActionProvider(mediaRouteMenuItem);
	// Set the MediaRouteActionProvider selector for device discovery.
	mediaRouteActionProvider.setRouteSelector(mMediaRouteSelector);
	return true;
}
 
Example 27
Project: XamarinAdmobTutorial   File: BaseCastPlayerActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.main, menu);
    MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item);
    MediaRouteActionProvider mediaRouteActionProvider =
            (MediaRouteActionProvider) MenuItemCompat.getActionProvider(mediaRouteMenuItem);
    mediaRouteActionProvider.setRouteSelector(mMediaRouteSelector);
    return true;
}
 
Example 28
Project: XamarinAdmobTutorial   File: GameActivity.java   View source code 5 votes vote down vote up
/**
 * Called when the options menu is first created.
 */
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.main, menu);
    MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item);
    MediaRouteActionProvider mediaRouteActionProvider =
            (MediaRouteActionProvider) MenuItemCompat.getActionProvider(mediaRouteMenuItem);
    mediaRouteActionProvider.setRouteSelector(mMediaRouteSelector);
    return true;
}
 
Example 29
Project: cards-against-robots   File: CastManager.java   View source code 5 votes vote down vote up
public void setMenu(Menu menu) {
    MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item);
    MediaRouteActionProvider mediaRouteActionProvider = (MediaRouteActionProvider) MenuItemCompat
            .getActionProvider(mediaRouteMenuItem);
    // Set the MediaRouteActionProvider selector for device discovery.
    mediaRouteActionProvider.setRouteSelector(mMediaRouteSelector);
}
 
Example 30
Project: tycka   File: TickerActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.main, menu);
    MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item);
    MediaRouteActionProvider mediaRouteActionProvider = (MediaRouteActionProvider) MenuItemCompat
            .getActionProvider(mediaRouteMenuItem);
    // Set the MediaRouteActionProvider selector for device discovery.
    mediaRouteActionProvider.setRouteSelector(mMediaRouteSelector);
    return true;
}
 
Example 31
Project: V.FlyoutTest   File: SampleMediaRouterActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Be sure to call the super class.
    super.onCreateOptionsMenu(menu);

    // Inflate the menu and configure the media router action provider.
    getMenuInflater().inflate(R.menu.sample_media_router_menu, menu);

    MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item);
    MediaRouteActionProvider mediaRouteActionProvider =
            (MediaRouteActionProvider)MenuItemCompat.getActionProvider(mediaRouteMenuItem);
    mediaRouteActionProvider.setRouteSelector(mSelector);
    mediaRouteActionProvider.setDialogFactory(new MediaRouteDialogFactory() {
        @Override
        public MediaRouteControllerDialogFragment onCreateControllerDialogFragment() {
            return new MediaRouteControllerDialogFragment() {
                @Override
                public MediaRouteControllerDialog onCreateControllerDialog(
                        Context context, Bundle savedInstanceState) {
                    mControllerDialog = new SampleMediaRouteControllerDialog(
                            context, mSessionManager, mPlayer);
                    return mControllerDialog;
                }
            };
        }
    });

    // Return true to show the menu.
    return true;
}
 
Example 32
Project: HereAStory-Android   File: BaseCastPlayerActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.main, menu);
    MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item);
    MediaRouteActionProvider mediaRouteActionProvider =
            (MediaRouteActionProvider) MenuItemCompat.getActionProvider(mediaRouteMenuItem);
    mediaRouteActionProvider.setRouteSelector(mMediaRouteSelector);
    return true;
}
 
Example 33
Project: HereAStory-Android   File: GameActivity.java   View source code 5 votes vote down vote up
/**
 * Called when the options menu is first created.
 */
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.main, menu);
    MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item);
    MediaRouteActionProvider mediaRouteActionProvider =
            (MediaRouteActionProvider) MenuItemCompat.getActionProvider(mediaRouteMenuItem);
    mediaRouteActionProvider.setRouteSelector(mMediaRouteSelector);
    return true;
}
 
Example 34
Project: CastHelloText-android-v2   File: MainActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.main, menu);
    MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item);
    MediaRouteActionProvider mediaRouteActionProvider
            = (MediaRouteActionProvider) MenuItemCompat
            .getActionProvider(mediaRouteMenuItem);
    // Set the MediaRouteActionProvider selector for device discovery.
    mediaRouteActionProvider.setRouteSelector(mMediaRouteSelector);
    return true;
}
 
Example 35
Project: CastOffline   File: CastMedia.java   View source code 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
  super.onCreateOptionsMenu(menu);
  getMenuInflater().inflate(R.menu.main, menu);
  MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item);
  MediaRouteActionProvider mediaRouteActionProvider=(MediaRouteActionProvider) MenuItemCompat.getActionProvider(mediaRouteMenuItem);
  mediaRouteActionProvider.setRouteSelector(mMediaRouteSelector);
  return true;
}
 
Example 36
Project: cast-android-tictactoe   File: GameActivity.java   View source code 5 votes vote down vote up
/**
 * Called when the options menu is first created.
 */
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.main, menu);
    MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item);
    MediaRouteActionProvider mediaRouteActionProvider =
            (MediaRouteActionProvider) MenuItemCompat.getActionProvider(mediaRouteMenuItem);
    mediaRouteActionProvider.setRouteSelector(mMediaRouteSelector);
    return true;
}
 
Example 37
Project: googleads-ima-android   File: MyActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.my, menu);

    MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item);
    MediaRouteActionProvider mediaRouteActionProvider =
            (MediaRouteActionProvider) MenuItemCompat.getActionProvider(mediaRouteMenuItem);
    mediaRouteActionProvider.setRouteSelector(sCastApplication.getMediaRouteSelector());
    mediaRouteMenuItem.setVisible(mReadyToCast);
    return true;
}
 
Example 38
Project: Jupiter-Broadcasting-Holo   File: BaseCastManager.java   View source code 5 votes vote down vote up
/**
 * Adds and wires up the Media Router cast button. It returns a pointer to the Media Router menu
 * item if the caller needs such reference. It is assumed that the enclosing
 * {@link android.app.Activity} inherits (directly or indirectly) from
 * {@link android.support.v7.app.ActionBarActivity}.
 *
 * @param menu
 * @param menuResourceId The resource id of the cast button in the xml menu descriptor file
 * @return
 */
public MenuItem addMediaRouterButton(Menu menu, int menuResourceId) {
    MenuItem mediaRouteMenuItem = menu.findItem(menuResourceId);
    MediaRouteActionProvider mediaRouteActionProvider = (MediaRouteActionProvider)
            MenuItemCompat.getActionProvider(mediaRouteMenuItem);
    mediaRouteActionProvider.setRouteSelector(mMediaRouteSelector);
    if (null != getMediaRouteDialogFactory()) {
        mediaRouteActionProvider.setDialogFactory(getMediaRouteDialogFactory());
    }
    return mediaRouteMenuItem;
}
 
Example 39
Project: Munin-for-Android   File: ChromecastHelper.java   View source code 4 votes vote down vote up
public void createOptionsMenu(Menu menu) {
	MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item);
	MediaRouteActionProvider mediaRouteActionProvider = (MediaRouteActionProvider) MenuItemCompat.getActionProvider(mediaRouteMenuItem);
	mediaRouteActionProvider.setRouteSelector(mMediaRouteSelector);
}
 
Example 40
Project: hipstacaster   File: HipstaActivity.java   View source code 4 votes vote down vote up
private void initChromeCastMenuItem(Menu menu) {
	MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item);
       MediaRouteActionProvider mediaRouteActionProvider =
               (MediaRouteActionProvider) MenuItemCompat.getActionProvider(mediaRouteMenuItem);
       mediaRouteActionProvider.setRouteSelector(mMediaRouteSelector);
}