在iOS上嵌入YouTube视频的媒体回调 [英] Media Callbacks with Embedded YouTube Videos on iOS

查看:432
本文介绍了在iOS上嵌入YouTube视频的媒体回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在iOS应用程式中将YouTube影片嵌入 UIWebView 。我在此YouTube上使用方法2博客嵌入视频。这工作很好,除了因为iOS管理媒体播放器,我不能确定视频是播放还是完成。我不想在视频播放时用另一个视图交换视图,但我没有看到一个好的方法来确定。有任何想法吗?如果有一种方法可以获得JavaScript回调,那么就可以工作,或者如果有一种方法可以使用HTML5 < video> 标签嵌入YouTube视频(我试过,没有成功)。

解决方案

可以注入javascript到 UIWebView (请参阅 http://iphoneincubator.com/blog/windows-views/how-to-inject-javascript-functions-into-a-uiwebview )...关于javascript和的其他有趣的东西UIWebView 可在这里这里。 / p>

尝试与此实验性youtube API一起使用(请参阅 http://code.google.com/apis/youtube/iframe_api_reference.html )...这应该能够帮你找到你想要的。



另一个有用的资源,使得从javascript到您的代码的回调是此处


I’m embedding YouTube videos in a UIWebView for an iOS app. I’m using "Method 2" at this YouTube blog post to embed the video. This works great, except that because iOS manages the media player, I can’t determine whether the video is playing or is done. I don’t want to swap that view out with another one while the video is playing, but I don’t see a good way to determine that. Any ideas? If there’s a way to get a JavaScript callback, that will work, or if there’s a way to embed YouTube videos using the HTML5 <video> tag, that will work as well (I’ve tried that and not gotten success).

解决方案

you can inject javascript into a UIWebView (see http://iphoneincubator.com/blog/windows-views/how-to-inject-javascript-functions-into-a-uiwebview)... other interesting stuff about javascript and UIWebView can be found here and here.

try using this together with this experimental youtube API (see http://code.google.com/apis/youtube/iframe_api_reference.html)... this should be able to get you what you want.

Another useful resource for this to make a callback from javascript to your code is here.

这篇关于在iOS上嵌入YouTube视频的媒体回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆