Note that there are some explanatory texts on larger screens.

plurals
  1. POMediaController Visibilty
    primarykey
    data
    text
    <p>I have an android application that uses a VideoView to play videos and I am also using a media controller. </p> <p>My problem is i am unable to prevent the media controller from disappearing while the video is playing and i would also like to make the media controller visible before the video starts so that the user can use the media controller to initially start the video. I have tried using using MediaController.show(0), but that didn't solve my problem. Here is my code :</p> <pre><code>public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); mVideoView = (VideoView) findViewById(R.id.surface_view); mPlay = (ImageButton) findViewById(R.id.play); mPause = (ImageButton) findViewById(R.id.pause); mReset = (ImageButton) findViewById(R.id.reset); mStop = (ImageButton) findViewById(R.id.stop); MediaController mc = new MediaController(this); mVideoView.setMediaController(mc); mPlay.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub playVideo(); } }); mPause.setOnClickListener(new OnClickListener() { public void onClick(View view) { if (mVideoView != null) { mVideoView.pause(); } } }); mReset.setOnClickListener(new OnClickListener() { public void onClick(View view) { if (mVideoView != null) { mVideoView.seekTo(0); } } }); mStop.setOnClickListener(new OnClickListener() { public void onClick(View view) { if (mVideoView != null) { current = null; mVideoView.stopPlayback(); } } }); } private void playVideo() { try { final String path = "http://toop.voxelperfect.net/video6.mp4"; System.out.println("path "+path); Log.v(TAG, "path: " + path); if (path == null || path.length() == 0) { Toast.makeText(SampleActivity.this, "File URL/path is empty", Toast.LENGTH_LONG).show(); } else { System.out.println("else "); // If the path has not changed, just start the media player if (path.equals(current) &amp;&amp; mVideoView != null) { System.out.println("mVideoView.start() "); mVideoView.start(); mVideoView.requestFocus(); return; } current = path; current = path; MediaController mc = new MediaController(this); mVideoView.setMediaController(mc); mVideoView.setVideoURI(Uri.parse(path)); mVideoView.start(); mVideoView.requestFocus(); mc.show(0); } } catch (Exception e) { Log.e(TAG, "error: " + e.getMessage()); if (mVideoView != null) { mVideoView.stopPlayback(); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload