html5 视频后备建议(无 Flash)
我正在寻找一种创造性的方法,在某些情况下用图像替换 HTML5 视频。不想处理闪光灯或类似的东西来使视频正常工作......宁愿给他们一个图像。
如果出现以下情况,请向他们提供图像:
如果桌面浏览器不支持 HTML5 视频
如果用户是移动设备
看起来很简单...特别是如果不支持视频,则将 Modernizr 用于带有 display:none;
的 css 标签...所以这里有一个警告:HTML5 视频是边缘到边缘并以使用 JavaScript 屏幕,我希望图像具有相同的行为。
我最初的想法很简单:海报属性。适用于 iPad 和 iPhone 3/3gs,但可在 iPhone 4 上播放。此外,不适用于 IE,IE 显然会显示“我不知道这是什么”,甚至不理会海报。
我在 http://kzmnt.com/test/ 设置了测试,
期待您的建议!
I'm looking for a creative way to replace an HTML5 video with an image under a few circumstances. Don't want to deal with flash or anything like that to make the video work... would rather give them an image.
Give them the image if:
If the desktop browser doesn't support HTML5 video
If the user is mobile
Seems simple... especially by using Modernizr for css tags with display:none;
if the video isn't supported ... so here's the caveat: The HTML5 video is edge to edge and centered to the screen with JavaScript and I'd like the image to have the same behavior.
My initial thought was simple: poster attribute. Works on an iPad and iPhone 3/3gs, but is playable on an iPhone 4.. Also, doesn't work on IE, which apparently says "I don't know what this is" and doesn't even bother with the poster.
I've got a test set up at http://kzmnt.com/test/
Looking forward to your advice!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过以下方式检查是否支持 HTML5 视频:
就移动设备而言,请尝试使用一些媒体查询。
上面的代码来自 http://diveintohtml5.ep.io/detect.html#video-格式。
You can check if HTML5 video is supported with the following:
As far as mobile goes, try using some media queries.
The above code is from http://diveintohtml5.ep.io/detect.html#video-formats.
在大约 1100px 后使用媒体查询并将其替换为使用 css 背景大小设置为覆盖的图像!
Used a media query after about 1100px and replaced it with an image using css background size set to cover!