2
votes

i am trying to play Youtube videos on my app. I am using YTPlayerView library for playing a video by video id. Problem is when i am trying to play a list of videos player showing an error that "An error occurred. Please try again later. (Playback ID: someid)".

I am using the following code for playing a single video

@IBOutlet weak var playerView: YTPlayerView! // story board connection

let params = ["controls" : 2, "playsinline" : 1, "autohide" :1, "showinfo" : 0, "modestbranding" : 0, "cc_load_policy" : 0, "rel" : 1] //,
playerView.delegate = self
playerView.loadWithVideoId("v_I0rA72IJE", playerVars:params)

Its working fine for a single video. But when i try to load a list of videos by using the following code i am getting that error.

playerView.loadWithPlayerParams(params)
playerView.loadPlaylistByVideos(["v_I0rA72IJE","l-ujrOIL-9M","yw002vpbClA"], index: 0, startSeconds: 0, suggestedQuality: YTPlaybackQuality.Default)

or

playerView.cuePlaylistByVideos(["v_I0rA72IJE","l-ujrOIL-9M","yw002vpbClA"], index: 0, startSeconds: 0, suggestedQuality: YTPlaybackQuality.Default)

YTPlayerView error screen shot

Please help me to solve the issue. Please correct me if i am doing anything wrong.

1
What browsers have you used? Did the same error occur using a different browser?Teyam
i'm not using any browsers, i'm using YTPlayerView in side my app to play youtube videosRavi
check this out if it could help youPratik Jamariya

1 Answers

1
votes

Not an exact solution, but we can proceed for now

First load a single video

youtubePlayerView.loadWithVideoId(videoId, playerVars: params)

inside the playerViewDidBecomeReady(playerView: YTPlayerView) delegate method load that playlist

func playerViewDidBecomeReady(playerView: YTPlayerView)
{
  playerView.cuePlaylistByVideos(videoIdsArray, index: 0, startSeconds: 0, suggestedQuality: YTPlaybackQuality.Default)
}