gpt4 book ai didi

ios - UIWebView youtube iframe api autoplay/playsinline 在 iOS7 中退出工作

转载 作者:可可西里 更新时间:2023-11-01 03:52:14 26 4
gpt4 key购买 nike

此代码非常适合在 iOS 6 uiwebview 中自动播放内联视频。但是,我升级到 iOS 7,现在我的视频不会自动播放。有时视频会自动播放,有时不会。它会自动播放大约 10% 的时间。大多数时候我得到一个纺车。如果我从 src 标签中删除 &playsinline=1 它将自动全屏播放(不是我想要的)。我花了很多时间为这个应用程序创建一个自定义播放器,但现在它无法正常工作。非常感谢任何帮助。

_youTubeWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 20, 320, 184)];
_youTubeWebView.delegate = self;
_youTubeWebView.scrollView.bounces = NO;
_youTubeWebView.allowsInlineMediaPlayback = YES;
_youTubeWebView.mediaPlaybackAllowsAirPlay = YES;
_youTubeWebView.mediaPlaybackRequiresUserAction = NO;
[self.view addSubview:_youTubeWebView];

NSString* embedHTML = [NSString stringWithFormat:@"<html><body style='margin:0px;padding:0px;'><script type='text/javascript' src='http://www.youtube.com/iframe_api'></script><script type='text/javascript'>function onYouTubeIframeAPIReady(){ytplayer=new YT.Player('playerId',{events:{onReady:onPlayerReady}})}function onPlayerReady(a){ a.target.playVideo(); }</script><iframe id='playerId' type='text/html' width='%@' height='%@'src='http://www.youtube.com/embed/%@?enablejsapi=1&rel=0&playsinline=1&controls=0&showinfo=0' frameborder='0'></body></html>", w, h, videoId];
[_youTubeWebView loadHTMLString:embedHTML baseURL:nil];

这是一个快速测试文件的链接。 videoPlayerTest.zip

最佳答案

这听起来像是针对 Youtube iframe 播放器 API 的以下开放错误:

Issue 5204: js iframe api playVideo() doesn't play video in iOS 7

http://code.google.com/p/gdata-issues/issues/detail?id=5204

关于ios - UIWebView youtube iframe api autoplay/playsinline 在 iOS7 中退出工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19235653/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com