How to play videos one after another sequentially?

前端 未结 2 1960
迷失自我
迷失自我 2021-01-24 07:38

I need to play videos one after the another sequentially.I tried searching in google but dint get any answer.Please help.Its bit urgent.

This is my code



        
2条回答
  •  甜味超标
    2021-01-24 07:56

    Try this:

    videoView = (VideoView) findViewById(R.id.v);
    setup();
    videoView.setOnCompletionListener(completionListener);
    

    setup Function:

    public void setup() {
            Uri uri = Uri.parse("android.resource://" + getPackageName() + "/"
                    + R.raw.test);
            videoView.setVideoURI(uri);
            videoView.start();
        }
    

    implement onCompletionListener as:

    OnCompletionListener completionListener=new OnCompletionListener() {
    
            public void onCompletion(MediaPlayer mp) {
                mp.stop();
                setup();
            }
        };
    

提交回复
热议问题