com.google.android.gms.cast.framework.CastButtonFactory Java Examples

The following examples show how to use com.google.android.gms.cast.framework.CastButtonFactory. 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: StreamFragment.java    From Pocket-Plays-for-Twitch with GNU General Public License v3.0 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) {
            MenuItem routeItem = CastButtonFactory.setUpMediaRouteButton(getContext().getApplicationContext(), menu, R.id.media_route_menu_item);
        }

        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 #2
Source File: BaseAppActivity.java    From edx-app-android with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // TODO: Replace the try-catch block with more appropriate logic so Travis-ci build get passed.
    // Can't access the CastButtonFactory while executing test cases of "CourseUnitNavigationActivityTest"
    // and throw exception.
    try {
        if (googleCastDelegate != null && (googleCastDelegate.isConnected() || showGoogleCastButton())) {
            getMenuInflater().inflate(R.menu.google_cast_menu_item, menu);
            mediaRouteMenuItem = CastButtonFactory.setUpMediaRouteButton(getApplicationContext(),
                    menu, R.id.media_route_menu_item);
            // show the introduction overlay.
            if (isInForeground()) {
                googleCastDelegate.showIntroductoryOverlay(this, mediaRouteMenuItem);
            }
        }
    } catch (Exception e) {
        logger.error(e, true);
    }
    return super.onCreateOptionsMenu(menu);
}
 
Example #3
Source File: LikedVideosFragment.java    From Loop with Apache License 2.0 6 votes vote down vote up
@Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        super.onCreateOptionsMenu(menu, inflater);

        inflater.inflate(R.menu.videos_menu, menu);

        mediaRouteMenuItem = CastButtonFactory.setUpMediaRouteButton(getContext().getApplicationContext(), menu, R.id.media_route);

        MenuItem item = menu.findItem(R.id.action_search);
//        mSearchViewWidget.setMenuItem(item);

//        // Get the SearchView and set the searchable configuration
//        SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
//        SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
//
//        // Assumes current activity is the searchable activity
//        searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
//        searchView.setQueryRefinementEnabled(true);
    }
 
Example #4
Source File: WatchLaterVideosFragment.java    From Loop with Apache License 2.0 6 votes vote down vote up
@Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        super.onCreateOptionsMenu(menu, inflater);

        inflater.inflate(R.menu.videos_menu, menu);

        mediaRouteMenuItem = CastButtonFactory.setUpMediaRouteButton(getContext().getApplicationContext(), menu, R.id.media_route);

        // Get the SearchView and set the searchable configuration
//        SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
//        SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
//
//        // Assumes current activity is the searchable activity
//        searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
//        searchView.setQueryRefinementEnabled(true);
    }
 
Example #5
Source File: GoogleCastButtonManager.java    From react-native-google-cast with MIT License 6 votes vote down vote up
@Override
public MediaRouteButton createViewInstance(ThemedReactContext context) {
  CastContext castContext = CastContext.getSharedInstance(context);

  final MediaRouteButton button = new ColorableMediaRouteButton(context);
  googleCastButtonManagerInstance = button;

  CastButtonFactory.setUpMediaRouteButton(context, button);

  updateButtonState(button, castContext.getCastState());

  castContext.addCastStateListener(new CastStateListener() {
    @Override
    public void onCastStateChanged(int newState) {
      GoogleCastButtonManager.this.updateButtonState(button, newState);
    }
  });

  return button;
}
 
Example #6
Source File: MyActivity.java    From googleads-ima-android with Apache License 2.0 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.my, menu);

  CastButtonFactory.setUpMediaRouteButton(
      getApplicationContext(), menu, R.id.media_route_menu_item);
  return true;
}
 
Example #7
Source File: MainActivity.java    From vinyl-cast with MIT License 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.main, menu);
    CastButtonFactory.setUpMediaRouteButton(getApplicationContext(), menu, R.id.media_route_menu_item);
    return true;
}
 
Example #8
Source File: ExpandedControlsActivity.java    From AndroidDemoProjects with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.menu_main, menu);
    CastButtonFactory.setUpMediaRouteButton(this, menu, R.id.media_route_menu_item);
    return true;
}
 
Example #9
Source File: MainActivity.java    From AndroidDemoProjects with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.menu_main, menu);
    mMediaRouterButton = CastButtonFactory.setUpMediaRouteButton(getApplicationContext(),
            menu,
            R.id.media_route_menu_item);

    showIntroductoryOverlay();

    return true;
}
 
Example #10
Source File: ExpandedControlsActivity.java    From edx-app-android with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.google_cast_menu_item, menu);
    CastButtonFactory.setUpMediaRouteButton(this, menu, R.id.media_route_menu_item);
    return true;
}
 
Example #11
Source File: ChromeCastSettingFragmentActivity.java    From DeviceConnect-Android with MIT License 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.browse, menu);
    mediaRouteMenuItem = CastButtonFactory.setUpMediaRouteButton(this, menu,
            R.id.media_route_menu_item);
    showIntroductoryOverlay();
    return true;
}
 
Example #12
Source File: PlayerController.java    From klingar with Apache License 2.0 5 votes vote down vote up
@Override public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
  super.onCreateOptionsMenu(menu, inflater);
  inflater.inflate(R.menu.menu_main, menu);
  inflater.inflate(R.menu.menu_player, menu);
  CastButtonFactory.setUpMediaRouteButton(getApplicationContext(), menu,
      R.id.media_route_menu_item);
}
 
Example #13
Source File: VideoBrowserActivity.java    From cast-videos-android with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.browse, menu);
    mediaRouteMenuItem = CastButtonFactory.setUpMediaRouteButton(getApplicationContext(), menu,
            R.id.media_route_menu_item);
    return true;
}
 
Example #14
Source File: LocalPlayerActivity.java    From cast-videos-android with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.browse, menu);
    mediaRouteMenuItem = CastButtonFactory.setUpMediaRouteButton(getApplicationContext(), menu,
            R.id.media_route_menu_item);
    return true;
}
 
Example #15
Source File: ExpandedControlsActivity.java    From cast-videos-android with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.expanded_controller, menu);
    CastButtonFactory.setUpMediaRouteButton(this, menu, R.id.media_route_menu_item);
    return true;
}
 
Example #16
Source File: GoogleCastExpandedControlsActivity.java    From react-native-google-cast with MIT License 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.cast_expanded_controller_menu, menu);
    CastButtonFactory.setUpMediaRouteButton(this, menu, R.id.media_route_menu_item);
    return true;
}
 
Example #17
Source File: QueueListViewActivity.java    From CastVideos-android with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.queue_menu, menu);
    CastButtonFactory.setUpMediaRouteButton(getApplicationContext(), menu,
            R.id.media_route_menu_item);
    return true;
}
 
Example #18
Source File: VideoBrowserActivity.java    From CastVideos-android with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.browse, menu);
    mediaRouteMenuItem = CastButtonFactory.setUpMediaRouteButton(getApplicationContext(), menu,
            R.id.media_route_menu_item);
    mQueueMenuItem = menu.findItem(R.id.action_show_queue);
    showIntroductoryOverlay();
    return true;
}
 
Example #19
Source File: LocalPlayerActivity.java    From CastVideos-android with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.player, menu);
    CastButtonFactory.setUpMediaRouteButton(getApplicationContext(), menu,
            R.id.media_route_menu_item);
    mQueueMenuItem = menu.findItem(R.id.action_show_queue);
    return true;
}
 
Example #20
Source File: ExpandedControlsActivity.java    From CastVideos-android with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.expanded_controller, menu);
    CastButtonFactory.setUpMediaRouteButton(this, menu, R.id.media_route_menu_item);
    return true;
}
 
Example #21
Source File: ExpandedControlsActivity.java    From Casty with MIT License 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.casty_discovery, menu);
    CastButtonFactory.setUpMediaRouteButton(this, menu, R.id.casty_media_route_menu_item);
    return true;
}
 
Example #22
Source File: MainActivity.java    From Pocket-Plays-for-Twitch with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_main_activity, menu);

    if (mCastContext != null) {
        MenuItem routeItem = CastButtonFactory.setUpMediaRouteButton(getApplicationContext(), menu, R.id.media_route_menu_item);
    }
    return true;
}
 
Example #23
Source File: BrowserController.java    From klingar with Apache License 2.0 4 votes vote down vote up
@Override public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
  super.onCreateOptionsMenu(menu, inflater);
  inflater.inflate(R.menu.menu_main, menu);
  CastButtonFactory.setUpMediaRouteButton(getApplicationContext(), menu,
      R.id.media_route_menu_item);
}
 
Example #24
Source File: DetailController.java    From klingar with Apache License 2.0 4 votes vote down vote up
@Override public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
  super.onCreateOptionsMenu(menu, inflater);
  inflater.inflate(R.menu.menu_main, menu);
  CastButtonFactory.setUpMediaRouteButton(getApplicationContext(), menu,
      R.id.media_route_menu_item);
}
 
Example #25
Source File: BaseActivity.java    From SkyTube with GNU General Public License v3.0 4 votes vote down vote up
/**
 * This will be called when the options menu has been created. It's needed to set up the cast icon
 */
protected void onOptionsMenuCreated(Menu menu) {
	MenuItem mediaRouteMenuItem = CastButtonFactory.setUpMediaRouteButton(getApplicationContext(), menu, R.id.media_route_menu_item);
}
 
Example #26
Source File: VideoDetailsFragment.java    From Loop with Apache License 2.0 4 votes vote down vote up
private void setUpCastButton(){
    Drawable remoteIndicatorDrawable = getRemoteIndicatorDrawable();
    DrawableCompat.setTint(remoteIndicatorDrawable, ContextCompat.getColor(getContext(), android.R.color.white));
    mediaRouteButton.setRemoteIndicatorDrawable(remoteIndicatorDrawable);
    CastButtonFactory.setUpMediaRouteButton(getContext().getApplicationContext(), mediaRouteButton);
}
 
Example #27
Source File: Casty.java    From Casty with MIT License 4 votes vote down vote up
private void setUpMediaRouteMenuItem(Menu menu) {
    CastButtonFactory.setUpMediaRouteButton(activity, menu, R.id.casty_media_route_menu_item);
}
 
Example #28
Source File: Casty.java    From Casty with MIT License 2 votes vote down vote up
/**
 * Makes {@link MediaRouteButton} react to discovery events.
 * Must be run on UiThread.
 *
 * @param mediaRouteButton Button to be set up
 */
@UiThread
public void setUpMediaRouteButton(@NonNull MediaRouteButton mediaRouteButton) {
    CastButtonFactory.setUpMediaRouteButton(activity, mediaRouteButton);
}