1

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
ysfcyln
  • 2,857
  • 6
  • 34
  • 61
  • Possible duplicate of [Why MediaPlayer throws NOT present error when creating instance of it?](http://stackoverflow.com/questions/24501086/why-mediaplayer-throws-not-present-error-when-creating-instance-of-it) –  Oct 22 '16 at 15:42

0 Answers0