Categories
Archives
-
September 2010 (1)
-
August 2010 (3)
-
June 2010 (1)
-
May 2010 (2)
-
April 2010 (1)
-
March 2010 (6)
-
January 2010 (1)
-
December 2009 (3)
-
November 2009 (5)
-
October 2009 (10)
-
September 2009 (1)
-
June 2009 (1)
-
October 2008 (1)
-
August 2008 (1)
-
May 2008 (1)
-
April 2008 (2)
-
February 2008 (1)
-
January 2008 (4)
-
On how to play HTML5 video
Most web developers agree that the ability to play video on webpages is a must, however the jury is out on how these videos should be played. I’m of course referring to the HTML 5 video format controversy. Throw FlashPlayer into the mix and you’ll end up with a humongous fight leading fast to nowhere. Based on this, focusing on finding a solution, I tried to piece together a player using both HTML 5 video, and FlashPlayer for less capable browsers like Internet Explorer. You can find a demo alpha version of the player here: http://makingria.com/demo/html5/videoplayer/
Browser support
The player supports the following browsers:
How to build it
My approach to building the player was based on my not so patented “falling down the stairs” method. In plain English this means that playback methods are ranked in a list, falling down the list as support for the wanted playback method is not found. To accomplish this we utilize the HTML5 video tags ability to hold a list of different source videos. If no support for html5 video is found the video tag will be replaced by swfObject using the Modernizer JS framework.
The list looks as follows:
I wanted the player to support play/pause controls, zoom control and outputting the current time and the duration of the video no matter what video playback method being used. I accomplished this by using JavaScript to control all of these aspects of the video, even when using FlashPlayer as the video playback method. If you want to see how this was done in practice, go take a peek at the JavaScript. The code for the FlashPlayer based player can be found here.
Performance
CPU usage is a challenge when playing high resolution video. On my computer, a ThinkPad Intel Core 2 Duo 2.66 GHz with 4 GB RAM (Windows 7 64 Bit) I found that the combination of HTML 5 video playback in WebKit based browsers using the H.264 codec gave the best results when playing a 720p HD video. Also notice the smooth scaling when testing the video in WebKit based browsers.
Final thoughts