iPhone上的HTML5内嵌视频与iPad /浏览器 [英] HTML5 inline video on iPhone vs iPad/Browser

查看:120
本文介绍了iPhone上的HTML5内嵌视频与iPad /浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个HTML5视频播放器(非常简单),可以在iPad和浏览器上完美运行。



然而,当我在iPhone上打开它时,我只得到一个播放按钮,当按下时,在我的所有东西之上打开一个新窗口上的原生视频播放器。



这意味着我无法访问我的自定义控件和时间跟踪(使用Javascript编写),因为视频现在正在隔离。



有什么方法可以覆盖苹果iPhone上的HTML5视频控制并获得它工作就像在ipad上?



干杯

解决方案



我无处可去,并向Apple提交了一个错误。



几周后他们得到了回到我这里,非常简单地说,我应该将webkit-playsinline添加到HTML上的视频标记中,并在UIWebView中添加allowInlineMediaPlayback属性。



所以最终,这就是它的秘密ks like:

HTML

 < video id =player width =480height =320webkit-playsinline> 

Obj-C

  webview.allowsInlineMediaPlayback = YES; 

所有工作都很好:)



希望这可以帮助某人,因为它几乎没有记录,我唯一可以找到对webkit-playsinline的引用的地方是在iAds参考中,它说:仅iAds JS。


I've created an HTML5 video player (very simple) that works perfectly on the iPad and the browser.

However, when I open it on the iPhone, I only get a play button which, when pressed, opens the native video player on a new window, on top of all my stuff.

That means I lose access to my custom controls and time tracking (written in Javascript), since the video is now running isolated.

Is there any way to override Apple's control of HTML5 video on the iphone and get it working like on the ipad?

Cheers

解决方案

Right,

I was going nowhere with this and filed a bug with Apple.

After a couple of weeks they got back to me saying, very simply, that I should add "webkit-playsinline" to the video tag on the HTML, as well as adding the "allowsInlineMediaPlayback" property on the UIWebView.

So in the end, this is what it looks like:

HTML

<video id="player" width="480" height="320" webkit-playsinline>

Obj-C

webview.allowsInlineMediaPlayback = YES;

And all works just fine :)

Hope this helps someone, as it's virtually undocumented and the only place I could find a reference to "webkit-playsinline" was in the iAds reference, where it says: "iAds JS only".

这篇关于iPhone上的HTML5内嵌视频与iPad /浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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