iPad/iPhone HTML5 视频加载
我试图在 iPad/iPhone 上动态加载,并注意到我无法在其上方放置 div。我将覆盖层放在 html 中,以便它在页面加载时生成,而不是通过 javascript 添加,并且视频在创建时绝对位于此元素下方。这适用于 PC,我想知道既然它是通过 js 创建的,iPhone 操作系统是否会覆盖 z-index 并强制到顶部?
还有一种方法可以覆盖默认的“无法播放图标”(带有斜杠的图标),并显示加载动画?这将通过另一条路线解决我的问题。
我的最后一个选择是在页面加载时通过 js 加载所有视频标签,并让它们在 iPad/iPhone 上彼此层叠?由于 iPhone 操作系统在收到请求之前不会加载任何视频,这行得通吗?
我的 iPhone 也遇到问题,并显示视频标签上设置的“海报”属性。
I'm trying to load on the fly on the iPad/iPhone and notice that I cannot place a div above this. I put the overlay in the html so that it's generated on page load and not added via javascript and the video when its created is absolutely positioned below this element. This works on a PC, I'm wondering if since it was created via js that the iPhone OS is overriding the z-index and forcing to the top?
Also is there a way to override the default "cannot play icon", the one with the slash, and show a loading animation instead? This would solve my issue via another route.
My last option would be to loaded all the video tags via js on page load and have them layered on top of each other for the iPad/iPhone? Since the iPhone OS won't load any video until requested would this work?
I also am having an issue with the iPhone and showing the "poster" attribute that is set on the video tag.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我找到了一个非常好的解决方法。我使用jquery,所以这是需要记住的一件事。
我的问题是,我正在构建一个 iPad Web 应用程序,左下角有一个导航按钮(我无法提供链接,因为它是一个客户端项目)。当用户单击(点击)左下角的按钮时,会出现一个下拉菜单,然后您可以单击这些菜单中的按钮以进入更深的子菜单。
问题:
视频上方的任何 li 标签(或任何与此相关的内容)都不可点击,因此在带有视频的页面上,我的点击导航的一部分(位于视频上方的部分)视频不起作用)。阅读这里的帖子实际上引导我找到了我的解决方案,很简单,它可能适用于您的情况,也可能不适用于您的情况,但我希望它适用。
我的解决方法:
现在我知道我可能缺少一些分号,或者我的编码可能已关闭,但我只是发布以供参考。基本上,当我的菜单被单击或处于活动状态时,我将从所有视频中删除控件属性,然后当菜单停用时,我将恢复控件。
您可以在任何您喜欢的地方使用此方法...您可以在视频结束后、有人将鼠标悬停在某物上(假设某物尚未在视频上)、当鼠标位于特定坐标(可能是您的坐标)内时删除控件。仅在极端情况下的解决方案)但这应该有效。
谢谢!!
-缺口
I found a pretty nice work-around. I'm using jquery, so that's one thing to keep in mind.
My issue was, I was building a Ipad web-app, with a navigation button at the bottom left (I can't give a link as it's a client project). When the user would click (tap) the button in the lower left, a drop-up menu would animate in, and then you could click the buttons in those menu's to get to deeper sub-menu's.
The problem:
any li tags (or anything for that matter) that was over the video, wouldn't be clickable, so on the pages with video, part of my tap-navigation (the part over the video wouldn't work). Reading posts here actually lead me to my solution, simple, and it may or may not work for your case, but I hope it does.
My workaround:
Now I know I may be missing some semi-colons, or my coding may be off, but I'm just posting for reference. Basically, when my menu is clicked, or is active, I'm removing the controls attribute from all videos, and then when the menu is deactivated, I'm bringing the controls back.
You could use this method anywhere you like...you could remove the controls after a video ends, after someone hovers over something (assuming that something isn't already over the video), when the mouse is within certain coordinates (may be your only solution in extreme cases) but this should work.
Thanks!!
-Nick
iPhone 不支持海报...直到 os4
iPhone doesn't support poster... until os4
您可以将图像绝对放置在视频播放器上方。 iPhone 上的 Safari 会将其呈现为透明的“播放”符号。我相信这样的东西可能会起作用:
在
iPad 上,它的工作方式可能会有所不同,具体取决于您是否使用
- 在这种情况下,您需要使用 javascript 提供自己的控件或您将无法启动媒体。根据我的经验,“无法播放”图标通常总是表明媒体无法真正播放;-) 因为有错误的 mimetype 或编解码器、不正确的 src 等。覆盖它是检查媒体负载的情况javascript 的错误异常。
我认为将媒体分层是不可能的。你也许可以通过交换位置来假装它。
You can position an image absolutely over the video player. Safari on iPhone will render it with a transparant 'play' symbol. I believe something like this may work:
And
On an iPad it may work differently depending if you use
<video controls />
or not - in which case you need to provide your own controls with javascript or you won't be able to start your media.The 'cannot play' icon is in my experience normally always an indication that the media can't really be played ;-) because of having the wrong mimetype or codec, incorrect src etc. Overriding it would be a case of checking the media load error exceptions with javascript.
Layering media on top of each other is I think impossible. You fake it maybe by switching positions.
我在使用 iPad 视频播放器时也遇到了同样的问题。从视觉上看,z 索引低于对话框的覆盖层,但实际上并非如此。如果您使用 javascript 将默认控件替换为您自己的控件,则问题就会消失。
http://sandbox.solutionsbydesign.com/montage/ipad/
我使用了 NetTuts 文章制作你自己的 HTML5 视频播放器
I was having the same exact problem with the iPad video player. Visually the z-index was lower than the overlay for the dialog box but in reality it wasn't. If you replace the default controls with your own using javascript the problem goes away.
http://sandbox.solutionsbydesign.com/montage/ipad/
I used the NetTuts article on making your own HTML5 video player