如何在UIWebview中播放或停止播放youtube电影?

时间:2012-01-09 10:31:41

标签: iphone ios uiwebview

我找到了一种在webview中播放youtube的方法

这是我的示例代码:

NSString *youtubeHtmlStr = [NSString stringWithFormat:@"<iframe class=\"youtube-player\" type=\"text/html\" width=\"328\" height=\"270\" src=\"http://www.youtube.com/embed/%@\" frameborder=\"0\"></iframe>",videoPath];
[webView loadHTMLString:youtubeHtmlStr baseURL:nil];

如何知道电影正在播放?

当我点击播放图标时,它会记录一条消息

  

设置电影路径:   http://o-o.preferred.fareastone-khh1.v3.lscache5.c.youtube.com/ ......

但我不知道是谁记录了这条消息???

希望有人知道答案

非常感谢

韦伯

2 个答案:

答案 0 :(得分:0)

与html有关的是使用java-script。没有亲自尝试使用Youtube,但Google文档可能会有所帮助:http://static.googleusercontent.com/external_content/untrusted_dlcp/www.google.com/en//events/io/2011/static/presofiles/youtube_iframe_player_the_future_of_embedding.pdf

为了处理你的objective-c代码中的回放事件,你可以将网页导航到网址,如myplayer://停止使用webview委托方法处理它,当然不允许它更改页面。这样,网址会告诉你html中发生了什么。

答案 1 :(得分:0)

它无法在模拟器上运行在设备上尝试并检查结果。

相关问题