Monday, December 21st, 2009
>John Gruber of Daring Fireball says that the HTML5 video element, simple as it is, always autobuffers on Safari, Chrome, and Firefox. It’s something others have also come up against. Any videos on the page will start downloading right away, regardless of the “autobuffer” attribute’s setting:
The HTML5 spec defines an autobuffer attribute for the video and other media elements (bold emphasis added):
The autobuffer attribute is a boolean attribute. Its presence hints to the user agent that the author believes that the media element will likely be used, even though the element does not have an autoplay attribute. (The attribute has no effect if used in conjunction with the autoplay attribute, though including both is not an error.) This attribute may be ignored altogether.
It would appear, in my testing, that all three of these browsers take the spec up on the aforebolded offer to ignore this attribute. Even if you do not explicitly turn this attribute on, Safari, Chrome, and Firefox will still auto-buffer the content for your <video> (and <audio>) elements. There is no way to suppress this using HTML markup.
As Gruber points out, this might seem like a good thing for fast UI: videos start playing as soon as the user wants them to. That would be true in a world of unlimited bandwidth, but for now, this feature is likely to be a massive bandwidth hog. There is a nice workaround, albeit one that peels back the utter simplicity of a single <video> tag:
- In the HTML markup, rather than a
<video>element, instead use an
<img>element with the intended poster frame.
- Add an
<img>element, which, when invoked, does some DOM jiggery-pokery to remove the just-clicked-upon
<img>element and replace it with a
<video>element that sources the intended video files.
And, in fact, that is exactly what I resorted to for my PastryKit videos. Do a View Source on that page to see the solution.
It’s difficult to see <video> becoming the web’s standard video component if every video buffers as soon as the page loads.
Posted by Michael Mahemoff at 6:56 pm