Video doesn't loop Android VideoView

android, android-videoview, loops

Solution

Try `onPreparedListener` instead of `onCompletionListener`:

myVideoView.setOnPreparedListener(new OnPreparedListener() {
    @Override
    public void onPrepared(MediaPlayer mp) {
        mp.setLooping(true);
    }
});

Hope this helps.

Problem

I am trying to build an android app that will loop a video! The problem is that it never loops! It plays the video only once! During debugging i realized that the "myVideoView.setOnCompletionListener" is being executed but the video doesn't play! I also try "mp.reset()" inside the CompletionListener. Maybe i am missing something in a different file, such as the Manifest? Any thoughts? Here is my code: ``` final VideoView myVideoView = (VideoView)findViewById(R.id.myvideoview); myVideoView.setVideoURI(Uri.parse(SrcPath)); myVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { @Override public void onPrepared(MediaPlayer arg0) { myVideoView.requestFocus(); myVideoView.start(); } }); myVideoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { public void onCompletion(MediaPlayer mp) { myVideoView.setVideoURI(Uri.parse(SrcPath)); } }); ```

Original source