Hi I am newbie at android,
I have 2 videos and want to play them consecutively in a VideoView, it works fine, first video played and then second video goes on but when the second video finished, it started again and cause a infinite loop. I can not figure out why.
public void videoPlay(){
videoNames = new ArrayList<>();
videoNames.add("home");
videoNames.add("car");
Uri videoUri = Uri.parse("android.resource://" + MainActivity.this.getPackageName() + "/raw/"
+ videoNames.get(0));
mVideoView.setVideoURI(videoUri);
mVideoView.start();
mVideoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
try {
mp.reset();
Uri videoUri = Uri.parse("android.resource://" + MainActivity.this.getPackageName() + "/raw/"
+ videoNames.get(1));
mVideoView.setVideoURI(videoUri);
mVideoView.start();
} catch(Exception e){
Toast.makeText(MainActivity.this,e.toString(), Toast.LENGTH_LONG).show();
}
}
});
}
I tried pause()
and stopPlayback()
but it did not help, when I try these, first video play then stops.
Here is the error
Android QCMediaPlayer not present