我使用 Google Web Designer 创建了一个 HTML5 页面。 Here
在模拟器中,自动播放功能无法正常工作。
视频也像下图一样被复制。
我用来展示的代码是:
- (void)viewWillAppear:(BOOL)animated{
NSURL *url = [NSURL URLWithString:@"http://finedine.s3.amazonaws.com/finedine_ads/video_ad.html"];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval: 10.0];
[webView loadRequest:requestObj];
self.webView.scalesPageToFit = YES;
}
我该如何解决这个问题?
更新:我用下面的代码显示它:
if(!adView.isBeingPresented){
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard"
bundle: nil];
adView= (AdViewController*)[mainStoryboard instantiateViewControllerWithIdentifier: @"AdViewController"];
}
if(![adView isBeingPresented])
[[KGModal sharedInstance] showWithContentViewController:adView];
//[self.window.rootViewController presentViewController:adView animated:YES completion:nil];
最佳答案
由于限制,嵌入 webview 时自动播放将不起作用,必须在网页上的某种触摸交互时调用 video.play()
。
User Control of Downloads Over Cellular Networks
In Safari on iOS (for all devices, including iPad), where the user may be on a cellular network and be charged per data unit, preload and autoplay are disabled. No data is loaded until the user initiates it. This means the JavaScript
play()
andload()
methods are also inactive until the user initiates playback, unless theplay()
orload()
method is triggered by user action. In other words, a user-initiated Play button works, but anonLoad="play()"
event does not.
- 阅读更多信息 iOS-Specific Considerations在 Apple 开发门户网站上。
关于视频中出现的双屏,这是youtube 提供的嵌入式视频的3d 版本。我没有使用过 Google Web Designer,但可能有某种设置可以加载另一种视频。
关于ios - 如何显示 HTML5 页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21946065/