Using the HTML5 <video> tag with a Flash fallback
The HTML5 <video> tag makes it possible to embed video clips in web pages much like the <img> tag works for images. The browser provides playback without plugins such as QuickTime or Flash.
Update: Firefox 3.5+ did not like the .ogm extension for the Ogg Theora file, so I changed it to .ogg.
In its simplest form the tag looks like this:
<video src="someclip.mp4" controls></video>
Safari 3.1 and later supported <video>. Firefox 3.1 beta 2 also supported it, and Opera had a build with preliminary support. Safari played MPEG4, while Firefox supported Ogg Theora. Providing both formats in the same tag covered that gap:
<video controls>
<source src="video.m4v" type="video/mp4">
<source src="video.ogg" type="video/ogg">
</video>
For browsers without <video> support, an easy fallback is Flash with SWFObject. The video sits inside a container, and JavaScript replaces it with the Flash player when playback is not available.
<div id="demoVideoFlash">
<video id="demoVideo" controls>
<source src="video.m4v" type="video/mp4">
<source src="video.ogg" type="video/ogg">
</video>
</div>
See the native demonstration. The MDN video reference and the HTML5 specification cover the details. Flash itself is now at end of life.
Comments are closed. If a post needs a reply, use the contact form.