Search code examples
androidchromecast

Chomecast is not showing up with Selector config: MediaControlIntent.CATEGORY_LIVE_VIDEO


I'm trying to Launch my Android app, Discover nearby cast devices, Connect to selected cast device, Send a Presentation to it, Close app and disconnect from cast device.

Right now I have tested different cases with the MediaRouteSelector to detect devices:

        mMediaRouteSelector = new MediaRouteSelector.Builder()
            .addControlCategory(MediaControlIntent.CATEGORY_LIVE_AUDIO)
            .addControlCategory(MediaControlIntent.CATEGORY_LIVE_VIDEO)
            .addControlCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK)
            .build();

Chromecast is only detected if MediaControlIntent.CATEGORY_REMOTE_PLAYBACK is added to the selector, when I got the callback when selecting the device there is no Display on the MediaRouter:

private class MyMediaRouterCallback extends MediaRouter.Callback {
  @Override
  public void onRouteSelected(MediaRouter router, RouteInfo route) {
    route.getPresentationDisplay(); // null Display
  }

  @Override
  public void onRouteUnselected(MediaRouter router, RouteInfo route) {}  }

As per documentation (CATEGORY_LIVE_VIDEO), this is the parameter I need to pass to the Selector in order to find a cast device that will work with the Presentation API., which in my case is not showing my ChromeCast device.

I know if I connect manually to my ChromeCast via Settings I can get a Presentation Display from the MediaRouter, but in this case I need to do configure it within my app.

Is there any way to connect to my ChromeCast device within my app in order to be able to send a Presentation to it? Or how can I achive to set my ChromeCast device in the same configuration it has when connecting to it via Settings?


Solution

  • To get the Presentation working with chromecast, you currently need to manually start Screen Casting first.