I have implement the following code in order to test playing a video from a remote web server through it´s URL.
videoView = (VideoView)this.findViewById(R.id.
vidView=(VideoView)findViewById(R.id.vidView);
vidView.setMediaController(null);
vidView.setVideoPath( "/mnt/external_sd/somerandommovie.3gp" );
vidView.start();
vidView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
vidView.start();
}
});
I found that the listener was firing, the issue was mp.start() didn't seem to do anything, so calling start again on the original object seems to be working fine.
here is my working chunk of code:
mp.setOnCompletionListener(new MediaPlayer.OnCompletionListener()
{
public void onCompletion(MediaPlayer mp)
{
// Do whatever u need to do here
}
});
Seems you are looking for
setOnCompletionListener(MediaPlayer.OnCompletionListener l)
More in depth explanation can be found here
This shows a solution where playback is called after completion using VideoView
, MediaController
and setOnCompletionListener()
.
in your onCompletion listener, try using videoView.start(); instead of mp.start();
Make sure you are using the player on the main thread, it seems the callback only works on the main thread.