【问题标题】:embedded youtube videos in uiwebview are no longer workinguiwebview 中嵌入的 youtube 视频不再有效
【发布时间】:2013-10-04 21:27:01
【问题描述】:

我正在使用 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];

【问题讨论】:

    标签: ios objective-c uiwebview youtube


    【解决方案1】:

    将 /embed/... 改为 /v/... 就可以了。

    【讨论】:

    • 感谢您的回复,它对我不起作用,所以我将整个 html 更改为仅引用 youtube 网站的移动版本
    【解决方案2】:

    我将整个 html 更改为仅引用 youtube 网站的移动版本

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-12-09
      • 2011-09-11
      • 2011-12-08
      • 2013-01-19
      • 1970-01-01
      • 1970-01-01
      • 2014-04-02
      • 1970-01-01
      相关资源
      最近更新 更多