Convert button is not shown in the demo… here is a solution to the problem.
Convert button is not shown in the demo
I’m running a demo from https://github.com/googlecast/CastVideos-android .
It depends on the library located here https://github.com/googlecast/CastCompanionLibrary-android
The project sets up all the necessary libraries and required jars.
The project compiles and runs without problems, except that the chromecast button does not appear in the actionBar.
If I modify onCreate with the following, the button appears:
mSelector = new MediaRouteSelector.Builder()
.addControlCategory(MediaControlIntent.CATEGORY_LIVE_AUDIO)
.addControlCategory(MediaControlIntent.CATEGORY_LIVE_VIDEO)
.addControlCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK)
.addControlCategory(CastMediaControlIntent.categoryForCast(getResources().getString(R.string.app_id))).build();
and modify onCreateOptionsMenu :
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.main, menu);
mediaRouteMenuItem = mCastManager.addMediaRouterButton(menu, R.id.media_route_menu_item);
Attach the MediaRouteSelector to the menu item
MenuItem
mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item);
MediaRouteActionProvider mediaRouteActionProvider = (MediaRouteActionProvider)MenuItemCompat.getActionProvider(mediaRouteMenuItem);
mediaRouteActionProvider.setRouteSelector(mSelector);
return true;
}
If I simply keep onCreateOptionsMenu out of the box, then it doesn’t work.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.main, menu);
mediaRouteMenuItem = mCastManager.addMediaRouterButton(menu, R.id.media_route_menu_item);
return true;
}
Any thoughts on why this is?
Solution
Your device may not be whitelisted for your app. You may need to check the instructions here