隨着最新版本的iOS
,iPad和iPhone,Youtube播放器(iframe js版本)不再工作。我知道蘋果在自動播放嵌入視頻方面的新限制......問題是,如果我點擊iPad設備上的Youtube視頻播放器,該流不會啓動,但它只是保持緩衝。Youtube api iframe with ipad ios7
你知不知道解決它嗎?
隨着最新版本的iOS
,iPad和iPhone,Youtube播放器(iframe js版本)不再工作。我知道蘋果在自動播放嵌入視頻方面的新限制......問題是,如果我點擊iPad設備上的Youtube視頻播放器,該流不會啓動,但它只是保持緩衝。Youtube api iframe with ipad ios7
你知不知道解決它嗎?
對於iOS設備,您應該使用HTML5而不是js API。
只需使用下面的代碼給視頻添加到您的應用程序:
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-C的,只需更換所有在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"
,其他未受保護的視頻作品中的所有設備。
好吧,這不是服務器端代碼,它是ObjectiveC,但是因爲您使用的是HTML5,您可以發佈如何將iframe添加到您的HTML5代碼嗎? – MuhammadBassio
https://www.dropbox.com/sh/5ldj1z9c5uij7vd/yEsIh1O_9j – user3355304
上面的鏈接採取我的代碼來看看吧!非常感謝! – user3355304
請給一些更多的細節,朋友。 –
我也遇到這個問題3天沒有更新IOS(我更新後)。但是這種改變是存在的,事件和playVideo()方法根本不起作用。我也在尋找解決方案。 –