Fallback options for HTML5 video
The HTML5 <video> element only works on a few, often bleeding edge, browsers. For tinyvid I've been only supporting this subset of browsers. Recently I put in support for a simple fallback option for other browsers.
In browsers that don't support <video> the element is ignored. The contents of the element are still processed however. This means any HTML elements within <video>...</video> will display to the user on those browsers. The most basic fallback option is to tell the user that their browser doesn't support video:
It's possible to play Theora videos using a Java Applet called Cortado. This can be used as a fallback for users that have Java support but no HTML5 video support:
These fallback options don't allow creating your own controls with JavaScript and using the nice HTML5 media API. They work best when you only want a single fallback option and use the built-in controls.
There are JavaScript libraries that can be used to emulate the HTML5 media API. Or you can write a simple wrapper to do this yourself. The basic approach is to use <video> in your page and insert a JavaScript file at the top. When loaded this fill searches the document for usages of <video>. It detects what capabilities the browser has (native video support, Flash, Cortado, mplayer/vlc plugin, etc) and replaces the <video> element with the correct HTML code to instantiate the fallback. The JavaScript can then create a wrapper object that emulates the HTML5 API and calls the underlying plugin methods, etc if possible.
Examples of this type of library can be seen in use:I've added very simple fallback to tinyvid using the Cortado applet. If the browser doesn't support <video> it displays a link the user can click to go to a page that uses the applet. The server decides whether to use native video or the applet depending on a URL parameter. Here's a link to a native video player, and the applet version:For the applet version the server queries the Ogg file for the width, height and duration of the video so it can embed that data in the applet parameters. In some cases I can't get the width and height. This is due to some of the videos being stored on backup storage (via Amazon S3) and I can't locally analyze it to get the data. In that case the applet dimensions are set to 320x240.
Categories: video
In browsers that don't support <video> the element is ignored. The contents of the element are still processed however. This means any HTML elements within <video>...</video> will display to the user on those browsers. The most basic fallback option is to tell the user that their browser doesn't support video:
<video>In my blog in the past I've used the video element to display the Theora video, and fallback to a YouTube hosted video if the browser doesn't support it. This was done with code like:
<p>pSorry, your browser doesn't support the video element<p>
</video>
<video src="/video_bling.ogg" controls>On <video> enabled browsers this uses built in support. On others it uses the Flash player to play the YouTube video.
<object width="425" height="350">
<param name="movie"
value="http://www.youtube.com/v/vvtdkxCIKC8"></param>
<embed src="http://www.youtube.com/v/vvtdkxCIKC8"
type="application/x-shockwave-flash"
width="425"
height="350"> </embed>
</object>>/video>
It's possible to play Theora videos using a Java Applet called Cortado. This can be used as a fallback for users that have Java support but no HTML5 video support:
<video src="test.ogg" controls>The Cortado applet cannot be used for video's hosted on another domain however. They must be on the same domain as that serving the cortado applet.
<applet code="com.fluendo.player.Cortado.class"
archive="cortado.jar"
width="320"
height="240">
<param name="url" value="test.ogg"></param>
<param name="duration" value="229.015"></param>
</applet>
</video>
These fallback options don't allow creating your own controls with JavaScript and using the nice HTML5 media API. They work best when you only want a single fallback option and use the built-in controls.
There are JavaScript libraries that can be used to emulate the HTML5 media API. Or you can write a simple wrapper to do this yourself. The basic approach is to use <video> in your page and insert a JavaScript file at the top. When loaded this fill searches the document for usages of <video>. It detects what capabilities the browser has (native video support, Flash, Cortado, mplayer/vlc plugin, etc) and replaces the <video> element with the correct HTML code to instantiate the fallback. The JavaScript can then create a wrapper object that emulates the HTML5 API and calls the underlying plugin methods, etc if possible.
Examples of this type of library can be seen in use:I've added very simple fallback to tinyvid using the Cortado applet. If the browser doesn't support <video> it displays a link the user can click to go to a page that uses the applet. The server decides whether to use native video or the applet depending on a URL parameter. Here's a link to a native video player, and the applet version:For the applet version the server queries the Ogg file for the width, height and duration of the video so it can embed that data in the applet parameters. In some cases I can't get the width and height. This is due to some of the videos being stored on backup storage (via Amazon S3) and I can't locally analyze it to get the data. In that case the applet dimensions are set to 320x240.
Categories: video
Labels: mozilla

7 Comments:
There are browser plugins such as xine and mplayer which are capable of playing ogg video files. Since the same plugin may already be installed in case the user is watching some Windows Media content online, this would be the easiest way to get video to the user, getting the user into using Flash or Java plugins.
We can even mix that and give the user multiple fallback, so in case his browser doesn't have native ogg support use the plugin, and if even this doesn't help - use Flash or Java.
Yes, the various JS libraries I link to do the mixing so that it picks out of the possible options, including plugins.
Great post! I noticed you use Amazon S3 for storage. i would appreciate if you try out my freeware FTP-like Amazon S3 client http://cloudberrylab.com/
Is it impossible for the java and plugin based players to integrate better, or is it just not been done?
In particular could they be used purely for the video playback and let the controls be implemented via javascript?
This is the future. It's just a matter of time until there is a JS library that will automatically parse the video tag on page load, and then fall back to supported media types for clients that do not have native support for Video and Audio (and SVG, and Canvas, even embedded fonts) tags. This way, we'll keep our markup clean, and still provide support for old or less functional browsers. As soon as some of these libraries are able to do that (and other basic things, like support column markup that makes sense - floating divs is tiring work), there will be a lot to get excited about again, in the world of HTML and standards - even without the support of MS.
Just to add to that - it should already be possible to write audio tag support that will fall back to Flash and even play ogg vorbis (there are two different swf based decoders available). Exposing a JS based API modeled on the HTML 5 API to do controls should also be very doable, even easy - today. Video codecs would be harder - but I'd love to see someone grab alchemy and give it a try. :-)
For use as a fallback, I have just wrote a Shockwave Flash file for video that has the same controls as the default firefox native video: http://braydon.com/blog/foxyvideo
I get how to fall back on any thing flash or java player when the browser does not support the video tag
------
But, how to fall back on flash when the browser actually support the video ta but not the codec.
Is there a way without have to use some javascipt.
Post a Comment
<< Home