Reputation: 5415
Im adding chromecast support into an app Im working on and Ive noticed that I see every test device that streams video including an xbox one and numerous rokus, smart tv's, and apple tv's that we develop on. Now I cant cast to them directly so I was wondering two things.
First can I use the mediarouter api's on android to cast to these devices and second how can I keep them from showing up in the device selection list.
EDIT: This is how I set up my MediaRouteSelector
mMediaRouter = MediaRouter.getInstance(getApplicationContext());
mediaRouteSelector = new MediaRouteSelector.Builder()
.addControlCategory(CastMediaControlIntent.categoryForCast(Config.ChromecastRecieverID))
.addControlCategory(MediaControlIntent.CATEGORY_LIVE_AUDIO)
.addControlCategory(MediaControlIntent.CATEGORY_LIVE_VIDEO)
.addControlCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK)
.build();
MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item);
MediaRouteActionProvider mediaRouteActionProvider =
(MediaRouteActionProvider) MenuItemCompat.getActionProvider(mediaRouteMenuItem);
if(mediaRouteActionProvider==null){
mediaRouteActionProvider = new MediaRouteActionProvider(this);
MenuItemCompat.setActionProvider(mediaRouteMenuItem, mediaRouteActionProvider);
}
mediaRouteActionProvider.setRouteSelector(this.mediaRouteSelector);
mediaRouteActionProvider.setDialogFactory(new MediaRouteDialogFactory() {
@Override
public MediaRouteControllerDialogFragment onCreateControllerDialogFragment() {
return new MediaRouteControllerDialogFragment() {
@Override
public MediaRouteControllerDialog onCreateControllerDialog(
Context context, Bundle savedInstanceState) {
MediaRouteControllerDialog mControllerDialog = new MediaRouteControllerDialog(BaseActivity.this);
return mControllerDialog;
}
};
}
});
Upvotes: 0
Views: 931
Reputation: 1007534
Now I cant cast to them directly
Your code is not written to only "cast". Hence, you will pick up:
Anything that is paired with your device that provides a live audio route, like Bluetooth speakers
Anything that is connected with your device that provides a live video route, like Miracast
Anything that an app on your device publishes a MediaRouteProvider
for that implements the RemotePlaybackClient
protocol (basically, Chromecast minus the more advanced receiver customization options)
First can I use the mediarouter api's on android to cast to these devices
That depends on your use of the verb "cast". All are available media routes, whether for live audio, live video, standard Android remote playback, or Chromecast-specific remote playback.
how can I keep them from showing up in the device selection list
If you do not want to be delivering content to those things, remove the categories from your MediaRouteSelector
.
Upvotes: 1