I am trying to build an app that plays a list of videos. Its a very basic implementation based on the API samples.
The playlist (array of video_ids) gets loaded using player.loadVideos
method. Changes in the player state are tracked using an implementation of PlayerStateChangeListener
.
Everything works great, and the videos play back-to-back (as expected).
When there is an error in playing the video, (eg. YouTubePlayer.ErrorReason.NOT_PLAYABLE
), it gets captured in the onError
method of PlayerStateChangeListener
, and I call player.next()
there to move on to the next video.
However, player.next
does not work after there is an error - basically once there is an error, there is nothing that I can do that would skip that video and play the next one that is queued up in the playlist.
When a player error occurs while YouTubePlayer plays a playlist, calling next() has no effect. I believe this is because errors in YouTubePlayer are non-recoverable. The solution is to reload the playlist with the next playlist index.
So, to keep track of the current playlist index,
Then, in onError(),