Tutorial :Video plays just the first 5 seconds



Question:

Using:

private void play() {      VideoView v = (VideoView) findViewById(R.id.videoView);      MediaPlayer mp = MediaPlayer.create(this, R.raw.video);      mp.setDisplay(v.getHolder());      mp.start();  }  

My video plays just about 5 first seconds, and stay like paused.. why does it happen? Is it something related to buffer? (I'm playing a local resource)

--

I've tried another 3gp video, and the same problem happens.


Solution:1

Combining a VideoView and a MediaPlayer may not be the right approach. VideoView uses its own MediaPlayer. Either use VideoView by itself, or use a combination of MediaPlayer and SurfaceView.


Solution:2

Working code (maybe was some problem with resource overuse):

private void play() throws Exception {      v = (VideoView) findViewById(R.id.videoView);      if (!firstPlay) {          mp.release();      }      mp = MediaPlayer.create(this, R.raw.video);      mp.setDisplay(v.getHolder());      mp.start();      firstPlay = false;  }  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »