当我尝试在tvOS中播放YouTube视频时,出现以下错误:
[MediaRemote] [MRPlaybackQueueServiceClient] playingQueueRequest AFCF4995-D293-4B5B-82F0-E701186F639F PineBoard-21384 /A600.000000x600.000000/R[0:1]响应资产请求,但出现错误 错误域= kMRMediaRemoteFrameworkErrorDomain代码= 15“操作 需要已注册客户数据源。” UserInfo = {NSLocalizedDescription =操作需要客户端数据 来源已注册。}
我正在使用XCDYouTubeKit库。
产生错误的代码是:
let playerViewController = AVPlayerViewController()
self.present(playerViewController, animated: true, completion: nil)
weak var weakPlayerViewController: AVPlayerViewController? = playerViewController
XCDYouTubeClient.default().getVideoWithIdentifier("9bZkp7q19f0") { video, error in
if (video != nil) {
let streamURLs = video?.streamURLs
var streamURL: URL?
if (streamURLs?[XCDYouTubeVideoQualityHTTPLiveStreaming] != nil) { streamURL = streamURLs?[XCDYouTubeVideoQualityHTTPLiveStreaming] }
else if (streamURLs?[XCDYouTubeVideoQuality.HD720.rawValue] != nil) { streamURL = streamURLs?[XCDYouTubeVideoQuality.HD720.rawValue] }
else if (streamURLs?[XCDYouTubeVideoQuality.medium360.rawValue] != nil) { streamURL = streamURLs?[XCDYouTubeVideoQuality.medium360.rawValue] }
else if (streamURLs?[XCDYouTubeVideoQuality.small240.rawValue] != nil) { streamURL = streamURLs?[XCDYouTubeVideoQuality.small240.rawValue] }
if let streamURL = streamURL {
weakPlayerViewController?.player = AVPlayer(url: streamURL)
weakPlayerViewController?.player?.play() // HERE IS WHERE I GET THE ERROR
}
}
}
我不明白为什么会出现此错误。 甚至,如果我在XCDYouTubeKit存储库中运行tvOS演示代码,我也会遇到相同的错误。
答案 0 :(得分:0)
将以下内容添加到appDelegate.swift应该可以纠正错误:
{{1}}