Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Shows how to hide a button, the captions button.
/**
* This app illustrates the basic behavior of the Android default media controller.
*
* @author Paul Michael Reilly
*/
public class MainActivity extends BrightcovePlayer {
// Private class constants
private final String TAG = this.getClass().getSimpleName();
@Override protected void onCreate(Bundle savedInstanceState) {
// When extending the BrightcovePlayer, we must assign the BrightcoveVideoView before
// entering the superclass. This allows for some stock video player lifecycle
// management. Establish the video object and use it's event emitter to get important
// notifications and to control logging.
setContentView(R.layout.default_activity_main);
brightcoveVideoView = (BrightcoveVideoView) findViewById(R.id.brightcove_video_view);
brightcoveVideoView.setMediaController(new BrightcoveMediaController(brightcoveVideoView));
super.onCreate(savedInstanceState);
// Hide the captions button.
View captions = this.findViewById(R.id.captions);
captions.setVisibility(View.GONE);
// Add a test video from the res/raw directory to the BrightcoveVideoView.
String PACKAGE_NAME = getApplicationContext().getPackageName();
Uri video = Uri.parse("android.resource://" + PACKAGE_NAME + "/" + R.raw.shark);
brightcoveVideoView.add(Video.createVideo(video.toString()));
}
}
@amatigianc

This comment has been minimized.

Copy link

@amatigianc amatigianc commented Jan 13, 2016

Hi, it's Giancarlo here. I tried to include the statements for hiding the 'caption buttons' as you did in this example but, at first they don't show up, but as soon as the video starts playing back, the button pops up.

@amatigianc

This comment has been minimized.

Copy link

@amatigianc amatigianc commented Jan 13, 2016

Hi, the only way to make the caption button permanetly gone, was to do this:

em.on(EventType.ANY, new EventListener() {
@OverRide
public void processEvent(Event event) {
brightcoveVideoView.getBrightcoveMediaController().getBrightcoveControlBar().findViewById(R.id.captions).setVisibility(View.GONE);
}
});

is it the right way of doing it?

@rameshandroid

This comment has been minimized.

Copy link

@rameshandroid rameshandroid commented Jun 2, 2016

I have tried for endtime, it's not working
brightcoveVideoView.getBrightcoveMediaController().getBrightcoveControlBar().findViewById(R.id.end_time).setVisibility(View.GONE);

Thanks
Ramesh

@gorjanz

This comment has been minimized.

Copy link

@gorjanz gorjanz commented Jun 28, 2016

Where do you get the resource id for "captions" (the generated one)?
In my project, there is no reference anywhere in the project towards any other UI element except the main brightcoveVideoView, referenced in the activity layout by its name: com.brightcove.player.view.BrightcoveVideoView

So anytime I try to get the resource id, in order to get the view, I get null.

View fullScreenButton = this.findViewById(com.brightcove.player.R.id.exit_full_screen); fullScreenButton.setVisibility(View.INVISIBLE);
=> results in NullPointerException

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment