Cannot get list of cast devices on the network.

I am trying to get a list of catchy devices programmatically in Android without using the MediaRouteActionProvider button in the SDK.

I create a MediaRouter and MediaRouteSelector as follows:

mMediaRouter = MediaRouter.getInstance(this);
mMediaRouteSelector = new MediaRouteSelector.Builder()
   .addControlCategory(CastMediaControlIntent.CATEGORY_CAST)
   .build();

Then I start the discovery:

mMediaRouter.addCallback(mMediaRouteSelector, mMediaRouterCallback,
   MediaRouter.CALLBACK_FLAG_PERFORM_ACTIVE_SCAN);

In the onProviderAdded callback method, I seem to get 3 providers: Android, com.google.android.youtube and com.google.android.gms. Only android provides a route called Phone.

Why didn't my chromometer device appear? Other applications can see this, so I should be able to connect.

+3
source share
2 answers

Well, for me it was like this:

onRouteAdded Media Router : "Chromecast"

+1

onRouteAdded onRouteRemoved . MediaRouter , :

playbackType == MediaRouter.RouteInfo.PLAYBACK_TYPE_REMOTE
0

All Articles