3

I am displaying the videos in a list. After playing the videos one after another it is displaying video can't play error in android naught only in Remaining all the versions are working fine.Please help me to resolve this issue. Below is the my code for playing the video in video view.

 videoview.setVideoURI(Uri.parse(streamInfo.video_streams.get(0).url));

                    viewHolder.large_videoview.seekTo(starttime * 1000);
                    viewHolder.large_videoview.start();


  videoview.setOnPreparedListener(new OnPreparedListener() {
                // Close the progress bar and play the video
                public void onPrepared(MediaPlayer mp) {
                    mMediaPlayer = mp;

                    mp.setOnInfoListener(new MediaPlayer.OnInfoListener() {
                        @Override
                        public boolean onInfo(MediaPlayer mp, int what, int extra) {
                            Log.e("large_videoview", "<><>onInfo");

                            if (what == MediaPlayer.MEDIA_INFO_BUFFERING_START)
                                //Log.e("buffering starts", "buffering starts");
                                if (what == MediaPlayer.MEDIA_INFO_BUFFERING_END)
                                    Log.e("buffering ends", "<><>buffering ends");
                            return false;
                        }
                    });
                }
            });

getting this error in my log cat

E/MediaPlayer: invoke failed: wrong state 0, mPlayer(0x7a30b0e0)

E/MediaPlayer: Error (1,-19)

E/MediaPlayer: Error (1,-1010)

Lassie
  • 984
  • 11
  • 25
  • This is unrelated to your question, but it will never print the "buffering ends" log in its current state. `what` cannot be two values at once, and by commenting the "buffering starts" log you have made both if conditions apply to the "buffering ends" log. Brackets are your friend. – Dave Sep 08 '17 at 14:05

1 Answers1

0

Are you sure you are doing like this?

videoview.setOnPreparedListener(new OnPreparedListener() {

                public void onPrepared(MediaPlayer mp) {
                    videoview.start();
                }
            });

i.e wait for VideoView to be prepared & once it's prepared, you call start() on it?

Sandip Fichadiya
  • 3,430
  • 2
  • 21
  • 47