YTPlayerView不在模拟器上播放内容(解码失败,错误代码为)



当我播放正常内容时,它在模拟器。

YTPlayerView参数

@implementation SingleVideoViewController
- (void)viewDidLoad {
[super viewDidLoad];
NSString *videoId = @"weRHyjj34ZE";
// For a full list of player parameters, see the documentation for the HTML5 player
// at: https://developers.google.com/youtube/player_parameters?playerVersion=HTML5
NSDictionary *playerVars = @{
@"controls" : @0,
@"playsinline" : @1,
@"autohide" : @1,
@"showinfo" : @0,
@"modestbranding" : @1
};
self.playerView.delegate = self;
[self.playerView loadWithVideoId:videoId playerVars:playerVars];

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(receivedPlaybackStartedNotification:)
name:@"Playback started"
object:nil];
}

但是,如果我的播放列表中有高清视频,它会给出以下错误和代码https://github.com/youtube/youtube-ios-player-helper

Git项目提供了代码,只需下载并在SingleVideoViewController中更改视频ID即可。

Decoding failed with error code -1
Decoding: C0 0x01E00168 0x0000304A 0x22111100 0x00000000 6668
Options: 1x-1 [0000002D,01E0010F] 0001C060
Decoding failed with error code 7
Decoding: C0 0x01E00168 0x0000304A 0x22111100 0x00000000 773
Options: 1x-1 [0000002D,01E0010F] 0001C060
Decoding failed with error code -1
Decoding: C0 0x01E00168 0x0000304A 0x22111100 0x00000000 773
Options: 480x360 [FFFFFFFF,FFFFFFFF] 0001C060

尝试将origin参数添加到playerVarsdictionary,即

NSDictionary *playerVars = @{
@"controls" : @0,
@"playsinline" : @1,
@"autohide" : @1,
@"showinfo" : @0,
@"modestbranding" : @1,
@"origin":@"https://www.youtube.com"
};

来自YouTubeAPI文件、

来源:此参数为IFrame API提供额外的安全措施,仅支持IFrame嵌入。如果您正在使用IFrame API,这意味着您正在设置enablejsapi参数如果值为1,则应始终将域指定为原点参数值。

您可以在此处阅读更多信息。

最新更新