Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When should HTML5 video fall back to Flash player?

I'm working on implementing a fallback mechanism for the HTML5 video player. I've got a way to replace it with the swfobject Flash player, but how should I detect if any issues have developed?

In other words, if we use the following list of error events that can be thrown, which one should trigger the Flash player replacement? Or should we simply do a replacement if any error is thrown?

Also, where should the onError handler be called? I'm thinking on the video tag, but want to make sure. Your guidance is much appreciated. Thanks.

   function failed(e) {
     // video playback failed - show a message saying why
     switch (e.target.error.code) {
       case e.target.error.MEDIA_ERR_ABORTED:
         alert('You aborted the video playback.');
         break;
       case e.target.error.MEDIA_ERR_NETWORK:
         alert('A network error caused the video download to fail part-way.');
         break;
       case e.target.error.MEDIA_ERR_DECODE:
         alert('The video playback was aborted due to a corruption problem or because the video used features your browser did not support.');
         break;
       case e.target.error.MEDIA_ERR_SRC_NOT_SUPPORTED:
         alert('The video could not be loaded, either because the server or network failed or because the format is not supported.');
         break;
       default:
         alert('An unknown error occurred.');
         break;
     }
   }
like image 637
Alex Avatar asked Jan 21 '23 18:01

Alex


1 Answers

The trouble here is that many issues can't be fixed by switching to Flash. In fact, the only time you're really benefited by switching to Flash is in IE, FF, and Opera when you've got an MP4 to play, and in all browsers when you've got an FLV. (This is obviously subject to change based on native Flash support for webm / Theora.)

For this reason, we've done the following for the JW Player for HTML5:

  • Ask the browser if it can play the file.
  • If the browser can't play the file, check the list of supported file types for Flash based on the file's extension.
  • If Flash can't play the file, offer a download link.

This solution isn't foolproof, but it gets you 90%+ of the way there.

Best,

Zach

Developer, LongTail Video

like image 53
Zachary Ozer Avatar answered Feb 04 '23 19:02

Zachary Ozer