有了最新版本的iOS、iPad和iPhone,Youtube播放器(iframe版本)就不再起作用了。我知道苹果在自动播放嵌入式视频方面的新限制.问题是,如果我点击iPad设备上的Youtube视频播放器,流就不会启动,但它只是保持缓冲。
你知道热能修好它吗?
发布于 2014-02-26 11:02:29
对于iOS设备,您应该使用HTML5而不是js。
只需使用下面的代码将视频添加到应用程序:
NSString *videoURL = @"http://www.youtube.com/embed/VIDEO_ID";
NSString* embedHTML = [NSString stringWithFormat:@"\
<html><head>\
<style type=\"text/css\">\
iframe {position:absolute; top:50%%; margin-top:-130px;}\
body {\
background-color: transparent;\
color: white;\
}\
</style>\
</head><body style=\"margin:0\">\
<iframe width=\"100%%\" height=\"240px\" src=\"%@\" frameborder=\"0\" allowfullscreen></iframe>\
</body></html>",videoURL];
self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];编辑:
根据注释,您使用的是HTML5而不是Objective,只需将Demo.html中的所有代码替换为下面的代码:
<iframe class="youtube-player" type="text/html" width="640" height="385" src="http://www.youtube.com/embed/qbexOeoH5hg" allowfullscreen frameborder="0">
</iframe>这应该适用于iOS :)
注:
受保护的视频不能按照YouTube的策略嵌入,所以当尝试播放示例中提到的视频时,您会看到一个错误:"This video contains content from "Copyright owner"(VEVO in our example) it is restricted from playback on certain sites, watch it on YouTube",其他不受保护的视频可以在所有设备上工作。
https://stackoverflow.com/questions/22039085
复制相似问题