Вопрос

lets say I have 3 mp4 files a.mp4,b.mp4,c.mp4. How can I dynamically click on a button and shift from one file to another in mediaplayer . Mediaplayer will play a.mp4 and onclick of a button it will stop and play b.mp4 . How can I get this functionality. I am using TextureView in place of VideoView.

Thanks

Это было полезно?

Решение 2

It worked using

           mediaplayer.reset();
           mediaplayer.setDataSource();

This simple.

Другие советы

Well you can implement something like this...

changeVidButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
                        //Get mediaplayer object while setting the video

                        mediaplayerObject.release();

                        //Set next video
                        if(video2)  //video2 and video3 are booleans to control path 
                            mediaplayerObject.setDataSource(/*ur next video path*/);
                        else if(video3)
                            mediaplayerObject.setDataSource(/*ur next video path*/);
                        ....
                        ....
                    }
});

You can change this logic as per your need.

Hope this helps. Cheers.:)

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top