Home » Java » Play a video from SD card and loop the video using videoView

Play a video from SD card and loop the video using videoView

Posted by: admin June 30, 2018 Leave a comment

Questions:

My goal here is to play all the videos from a folder in SDCard for example all the videos in the download folder and play it on loop. But my problem now is when i start the app, the app always shows an error say “Can’t play this video”.

This is my code and i appreciate the help.

@Override
protected void onResume() {

    super.onResume();
    VideoView video = (VideoView) findViewById(R.id.videoview1);
    video.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
        @Override
        public void onPrepared(MediaPlayer mp) {
            mp.setLooping(true);
        }
    });
    video.setVideoPath("/storage/extSdCard/Download/great.mp4");
    video.start();

}
Answers: