I am 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 is set up with all the necessary libraries and the required bank.
The project compiles and does not launch any problems, except that the chromecast button does not appear in the actionBar.
A button appears if I change onCreate with the following :
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 change onCreateOptionsMenu as follows:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.main, menu);
mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item);
MediaRouteActionProvider mediaRouteActionProvider = (MediaRouteActionProvider)MenuItemCompat.getActionProvider(mediaRouteMenuItem);
mediaRouteActionProvider.setRouteSelector(mSelector);
return true;
}
If I just left onCreateOptionsMenu since it was out of the box, then this will not 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 ideas as to why this is?
Fabii source
share