30

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.

Jonik
  • 80,077
  • 70
  • 264
  • 372
Karthik
  • 4,943
  • 19
  • 53
  • 86
  • 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 Answers2

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
  • 1
    It 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
  • but in case of only hide forward button? – Ahmad Arslan Apr 18 '16 at 09:23
  • 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
  • 3
    Due 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