当我播放正常内容时,它在 模拟器。
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中更改videoId。
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
答案 0 :(得分:0)
尝试向您的glib-2.0
origin
添加 playerVars
参数,即
dictionary
从NSDictionary *playerVars = @{
@"controls" : @0,
@"playsinline" : @1,
@"autohide" : @1,
@"showinfo" : @0,
@"modestbranding" : @1,
@"origin":@"https://www.youtube.com"
};
API文档开始,
来源:此参数为IFrame API提供了额外的安全措施,并且仅支持IFrame嵌入。如果您正在使用 IFrame API,这意味着您正在设置enablejsapi参数 值设为1,则应始终将域指定为来源 参数值。
您可以详细了解here。