哪些用户代理支持 HTML5
哪些用户代理支持 HTML5 video
标记,使用 mp4 作为容器,使用 H.264 作为编解码器?有人为此想出了一个正则表达式吗?
更新: 谢谢大家的评论。我忘了提及,我最好想在后端执行此操作,这意味着现代化器之类的东西无法工作。
What user agents support the HTML5 video
tag, using mp4 as the container and H.264 as the codec? Has anyone come up with a regex for this?
UPDATE:
Thanks for the comments, everyone. I forgot to mention, I preferably want to do this on the back-end, which means something like modernizer wouldn't work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
桌面电脑:
移动设备:
请参阅 HTML5 测试 了解更多信息。注意:Android 的默认浏览器(称为“浏览器”)没有列出对任何编解码器的支持,但我认为这由手机供应商决定,我很确定您可以保证 H.264 作为硬件加速该编解码器往往内置于移动处理器中。另外,关于桌面版 Firefox,它获得了 H.264 支持 今年晚些时候。
编辑:以上支持矩阵已于 2013 年 3 月 22 日更新
因此,您需要支持的两种视频格式是 WebM 和 H.264。但 H.264 似乎正日益成为网络视频事实上的标准。
不要使用用户代理嗅探,这是出了名的不可靠且容易出错。有更好的方法来检测
标记支持。
例如,看看Modernizer,它可以让你写:
或者,如果你明确检测特定的编解码器...
Desktop:
Mobile:
See HTML5 Test for more information. Notes: the default browser for Android (called "Browser") doesn't list support for any codec, but I think it's up to the phone vendors to decide this, I'm pretty sure you can guarantee H.264 as hardware acceleration for that codec tends to be built into mobile processors. Also regarding Firefox for Desktop, it's getting H.264 support later this year.
Edit: above support matrix was updated on 2013/03/22
So the two video formats you'd need to support are WebM and H.264. But seems that H.264 is increasingly becoming the de-facto standard for video on the web.
DON'T use user agent sniffing, it's notoriously unreliable and error prone. There are simply better ways of detecting
<video>
tag support.For instance, have a look at Modernizer which lets you write:
or, if you're explicitly detecting a particular codec...
不确定正则表达式,尽管我认为您不需要用户代理嗅探 -
元素旨在包含对多种格式的视频的引用,以便用户代理能够玩他们支持的那个。请参阅深入了解 HTML5 的视频章节,了解一个很好的示例。
Dive into HTML5 还提供了支持 HTML5 视频的浏览器的良好列表。
Not sure about a regex, although I don’t think you need user agent sniffing — the
<video>
element is designed to contain references to the video in several formats in such a way that user agents will play the one they support. See Dive into HTML5’s video chapter for a great example.Dive into HTML5 also has a good list of browser support of HTML5 video.