Search code examples
androidchromecast

Chromecast custom selector dialog


Is there a way to make a custom chromecast selector dialog? I have been looking through the documentation and can't find anything on how to do this.

example


Solution

  • You can do that:

    1. First, extend MediaRouteChooserDialogFragment, and call that, say, MyChooserDialogFragment.
    2. Next, extend the MediaRouteDialogFactory (call that, say, MyMediaRouteDialogFactory) and override the method onCreateChooserDialogFragment(). In there, you need to return an instance of MyChooserDialogFragment:

      public MediaRouteChooserDialogFragment onCreateChooserDialogFragment() {
          return new MyChooserDialogFragment();
      }
      
    3. Finally, set this factory on the action provider:

      mediaRouteActionProvider.setDialogFactory(new MyMediaRouteDialogFactory());