我正在使用uiwebview播放嵌入的YouTube视频,但今天它突然停止工作,任何人都知道可以解决这个问题吗?
NSString* videoHTML = [NSString stringWithFormat:@"\
<html>\
<head>\
<style type=\"text/css\">\
iframe {position:absolute; top:50%%; margin-top:-130px;}\
body {background-color:#000; margin:0;}\
</style>\
<script type=\"text/javascript\" src=\"https://www.youtube.com/player_api\"></script>\
<script>\
var player;\
function onYouTubeIframeAPIReady() {\
player = new YT.Player('player',{ events: {\
'onReady': onPlayerReady}\
});}\
function onPlayerReady(event) {\
setTimeout(function() {\
event.target.playVideo();\
}, 1000);\
}\
</script>\
</head>\
<body>\
<iframe class=\"youtube-player\" background-color:#000000 allowtransparency= \"true\" type=\"text/html\" width=100%% height=240px src=\"http://www.youtube.com/embed/%@?fs=1&autoplay=1&rel=0&version=3&enablejsapi=1&showinfo=0\" frameborder=\"0\" allowfullscreen/>\
</body>\
</html>",self.videoID];
[self.webView loadHTMLString:videoHTML baseURL:nil];
[webView setAllowsInlineMediaPlayback:YES];
答案 0 :(得分:1)
更改/嵌入/ ...到/ v / ...它会正常工作。
答案 1 :(得分:0)
我将整个html更改为仅适用于youtube网站的移动版