开发者

What user agents support mp4/H.264 video in the HTML5 <video> tag?

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.


Desktop:

  • IE6-8: None
  • IE9-10: H.264
  • Chrome: WebM and H.264
  • Firefox 3.6: Ogg Theora
  • Firefox 4+: WebM
  • Opera: WebM
  • Safari: H.264

Mobile:

  • iOS: H.264
  • Chrome Android: H.264 and WebM
  • Firefox Android: H.264 and WebM
  • IE for Windows Phone 7.5 - 8: H.264
  • Opera 12: H.264

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:

if (!Modernizr.video)
{
    // Implement some Flash fallback
}

or, if you're explicitly detecting a particular codec...

if (!Modernizr.video || (Modernizr.video && !Modernizr.video.h264))
{
    // Flash fallback here
}


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜