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

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

问题描述

我将 YouTube 视频嵌入到 iOS 应用的 UIWebView 中.我在 这个 YouTube 上使用方法 2"博客文章以嵌入视频.这很好用,除了因为 iOS 管理媒体播放器,我无法确定视频是否正在播放或已完成.我不想在视频播放时将该视图与另一个视图交换,但我没有找到确定这一点的好方法.有任何想法吗?如果有一种方法可以获取 JavaScript 回调,那会起作用,或者如果有一种方法可以使用 HTML5 <video> 标记嵌入 YouTube 视频,那也会起作用(我已经试过了)并没有获得成功).

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).

推荐答案

您可以将 javascript 注入 UIWebView(请参阅 http://iphoneincubator.com/blog/windows-views/how-to-inject-javascript-functions-into-a-uiwebview)... 其他关于 javascript 和 UIWebView 的有趣内容可以在 此处这里.

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.

尝试将此与此实验性 youtube API 一起使用(请参阅 http://code.google.com/apis/youtube/iframe_api_reference.html)...这应该可以满足您的需求.

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.

另一个用于从 javascript 回调到您的代码的有用资源是 此处.

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

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

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