private void showMediaRouteDialog(MediaStateListener player, MediaRouteController controller, Activity activity) { FragmentManager fm = ((FragmentActivity) activity).getSupportFragmentManager(); if (fm == null) { throw new IllegalStateException("The activity must be a subclass of FragmentActivity"); } MediaRouteDialogFactory factory = new MediaRouteChooserDialogFactory(player, controller, activity); if (fm.findFragmentByTag( "android.support.v7.mediarouter:MediaRouteChooserDialogFragment") != null) { Log.w(TAG, "showDialog(): Route chooser dialog already showing!"); return; } MediaRouteChooserDialogFragment f = factory.onCreateChooserDialogFragment(); f.setRouteSelector(controller.buildMediaRouteSelector()); f.show(fm, "android.support.v7.mediarouter:MediaRouteChooserDialogFragment"); }
/** * called after the user finishes the screen capture permissions activity * @param requestCode arbitrary int representing why the activity was started * @param resultCode int indicating success or failure * @param data an Intent representing screen capture permission */ @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode != SCREEN_CAPTURE_REQUEST) { // this request wasn't meant for us } else if (resultCode != AppCompatActivity.RESULT_OK) { Toast.makeText(this, "Screen casting won't work without capture permission", Toast.LENGTH_LONG).show(); } else { mPermissionsResultCode = resultCode; mPermissionsData = data; if (mProvider != null && mProvider.getMediaRouteButton() != null) { MediaRouteDialogFactory factory = mProvider.getMediaRouteButton().getDialogFactory(); MediaRouteChooserDialogFragment chooser = factory.onCreateChooserDialogFragment(); chooser.setRouteSelector(mSelector); FragmentManager fm = getSupportFragmentManager(); chooser.show(fm, CastScreenMediaRouteButton.CHOOSER_TAG); } else { Log.e(TAG, "Null action provider or route button - " + PLEASE_REPORT_BUG); } } }
private void showMediaRouteDialog(MediaRouteController controller, Activity activity) { FragmentManager fm = ((FragmentActivity) activity).getSupportFragmentManager(); if (fm == null) { throw new IllegalStateException("The activity must be a subclass of FragmentActivity"); } MediaRouteDialogFactory factory = new ChromeMediaRouteDialogFactory(); if (fm.findFragmentByTag( "android.support.v7.mediarouter:MediaRouteChooserDialogFragment") != null) { Log.w(TAG, "showDialog(): Route chooser dialog already showing!"); return; } MediaRouteChooserDialogFragment f = factory.onCreateChooserDialogFragment(); f.setRouteSelector(controller.buildMediaRouteSelector()); f.show(fm, "android.support.v7.mediarouter:MediaRouteChooserDialogFragment"); }
@Override public MediaRouteChooserDialogFragment onCreateChooserDialogFragment() { return new MediaRouteChooserDialogFragment() { final SystemVisibilitySaver mVisibilitySaver = new SystemVisibilitySaver(); @Override public MediaRouteChooserDialog onCreateChooserDialog( Context context, Bundle savedInstanceState) { mVisibilitySaver.saveSystemVisibility(getActivity()); return new MediaRouteChooserDialog(context); } @Override public void onStop() { super.onStop(); mVisibilitySaver.restoreSystemVisibility(getActivity()); } }; }
private void openCastDialog() { final FragmentManager fm = getSupportFragmentManager(); MediaRouteChooserDialogFragment f = MediaRouteDialogFactory.getDefault().onCreateChooserDialogFragment(); f.setRouteSelector(CastContext.getSharedInstance(this).getMergedSelector()); f.show(fm, "android.support.v7.mediarouter:MediaRouteChooserDialogFragment"); }
@Override public MediaRouteChooserDialogFragment onCreateChooserDialogFragment() { return new Fragment(mController, mPlayer); }
@NonNull @Override public MediaRouteChooserDialogFragment onCreateChooserDialogFragment() { return new CustomMediaRouteChooserDialogFragment(); }
@Override public MediaRouteChooserDialogFragment onCreateChooserDialogFragment() { return new CustomMediaRouteChooserDialogFragment(); }