I want to play 2 videos in a row. The first video always plays just fine. After it finishes, you can see in the log that it sets the new video URL, but then SurfaceView throws an error and the VideoView just freezes with the last frame of the first video. Nothing else happens. Any thoughts ? Thanks !
LE: Surprisingly, the OnPreparedListener gets called for the second video.
LE2: Sometimes the second video plays just fine, sometimes it doesn't... and I haven't changed a line of code between when it worked and when not. It's purely random...
LE3: Quick solution is add this line before you set the new video URL:
mVideoView.setVisibility(View.GONE);
Code from OnCompletionListener:
setCurrentPlaybackUrl(); // sets mCurrentMediaUrl to the second video URL
mVideoView.setVideoPath(mCurrentMediaUrl);
mVideoView.start();
This is the log output when the first video finishes playback:
10-22 12:32:35.762: I/AwesomePlayer(126): setDataSource_l('https://xx/TestingVideo_lo.mp4')
10-22 12:32:35.762: E/BufferQueue(123): [SurfaceView] connect: already connected (cur=3, req=3)
10-22 12:32:35.762: E/MediaPlayerService(126): setVideoSurfaceTexture failed: -22
10-22 12:32:35.762: E/BufferQueue(123): [SurfaceView] connect: already connected (cur=3, req=3)
10-22 12:32:35.762: E/MediaPlayerService(126): setVideoSurfaceTexture failed: -22
Try on the
onCompletion(MediaPlayer mp)
, to addmp.stop()
and then do your stuff .EDIT: I have tried this and it's working:
where
play_video
is the following method :The only difference is that I played the same video twice, not two different videos.