I have a very simple task - just to show playback controls while playing video on VideoView
. But I can't solve it.
Here is the piece of code that I use for initializing VideoView
and setting MediaController
:
videoView.setVideoURI(Uri.parse(videoUrl));
MediaController mediaController = new MediaController(this);
videoView.setMediaController(mediaController);
videoView.setKeepScreenOn(true);
videoView.setOnPreparedListener(mp -> {
progress.setVisibility(View.GONE);
videoView.start();
mediaController.show(0);
});
The thing is that mediaController.show(0)
doesn't give any effect. Controls just show up for 3 seconds and then disappear.
Also I have tried to override MediaController's hide()
method:
@Override public void hide() {}
Well, it works - controls never hide, but unfortunately hardware 'back' button stops working. Without override hardware 'back' button on first tap close media controls, on second tap - brings user to previous screen, as expected.
Are there any working solutions?