YTPlayerView 加载视频列表

YTPlayerView load a list of videos

我正在尝试在我的应用程序上播放 Youtube 视频。我正在使用 YTPlayerView 库按视频 ID 播放视频。问题是当我尝试播放显示 "An error occurred. Please try again later. (Playback ID: someid)".

错误的视频播放器列表时

我正在使用以下代码播放单个视频

@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)

对于单个视频来说效果很好。但是,当我尝试使用以下代码加载视频列表时,出现了该错误。

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

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

请帮我解决问题。如果我做错了什么,请纠正我。

不是一个精确的解决方案,但我们现在可以继续

首先加载单个视频

youtubePlayerView.loadWithVideoId(videoId, playerVars: params)

playerViewDidBecomeReady(playerView: YTPlayerView) 委托方法中加载播放列表

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