I am using VideoView for playing video in my app but I would like to hide the controls in it. How can I do that? Thanks.
Asked
Active
Viewed 3.2k times
30
-
use framelayout and put videoview and other controls that you want to hide/show. (e.g. play-pause button in middle of the videoview, that hide/show when video is playing or in pause state). – Hiren Dabhi Mar 12 '12 at 05:30
2 Answers
76
To the Controls in the VideoView
, we can set MediaController
to null
.
videoView.setMediaController(null)

double-beep
- 5,031
- 17
- 33
- 41

Sadeshkumar Periyasamy
- 4,848
- 1
- 26
- 31
-
1It works but on some devices you will get the Null point exception: Caused by: java.lang.NullPointerException at android.widget.VideoView.setMediaController(VideoView.java:270) – Marqs Mar 30 '12 at 15:05
-
-
The later answer works better than the accepted answer here. Setting in invisible controller is more predictable behavior than setting null. – Matthew Bahr Jul 07 '17 at 00:24
29
Try this:
MediaController ctrl = new MediaController(context);
ctrl.setVisibility(View.GONE);
videoView.setMediaController(ctrl);

ZimaXXX
- 1,255
- 11
- 11
-
3Due to me using MediaPlayer.OnPreparedListener to control the volume of my videoview i didnt have the luxury of setting .setMediaController(null), instead this soultion worked perfectly. thanks! – Logic1 Jun 24 '15 at 05:56
-
This is weird. if ctrl.setVisible(View.VISIBLE) after .GONE, it doesnt show – chitgoks Oct 27 '21 at 02:15