I have been studying this for quite some time, and I am trying to do the same, so hopefully this will help someone else. I use crossbrowsertesting.com and literally test it in almost every browser known to man. The solution I got currently works in Opera, Chrome, Firefox 3.5+, IE8 +, iPhone 3GS, iPhone 4, iPhone 4, iPhone 5, iPhone 5, iPad 1+, Android 2.3+, Windows Phone 8.
Dynamic change of sources
Changing a video dynamically is very difficult, and with Flash fallback you will need to remove the video from the DOM / page and add it again so that Flash is updated because Flash does not recognize dynamic updates for Flash vars. If you intend to use JavaScript to dynamically change it, I would completely remove all <source> elements and just use canPlayType to set src in JavaScript and break or return after the first supported video type and don't forget to dynamically update flash var mp4. In addition, some browsers will not register that you changed the source unless you name video.load() . I believe that the .load() problem you were experiencing can be fixed by calling video.pause() . Removing and adding video elements can slow down the browser, as it continues to buffer remote video, but there is a workaround .
Cross browser support
As for the actual part of the cross browser, I came to Video For Everybody . I already tried the MediaelementJS Wordpress plugin, which, as it turned out, caused a lot more problems than it solved. I suspect the problems are related to the Wordpress plugin, not the library. I am trying to find something that works without JavaScript, if possible. So far, what I came up with is simple HTML:
<video width="300" height="150" controls="controls" poster="http://sandbox.thewikies.com/vfe-generator/images/big-buck-bunny_poster.jpg" class="responsive"> <source src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.ogv" type="video/ogg" /> <source src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4" type="video/mp4" /> <source src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.webm" type="video/webm" /> <source src="http://alex-watson.net/wp-content/uploads/2014/07/big_buck_bunny.iphone.mp4" type="video/mp4" /> <source src="http://alex-watson.net/wp-content/uploads/2014/07/big_buck_bunny.iphone3g.mp4" type="video/mp4" /> <object type="application/x-shockwave-flash" data="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf" width="561" height="297"> <param name="movie" value="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf" /> <param name="allowFullScreen" value="true" /> <param name="wmode" value="transparent" /> <param name="flashVars" value="config={'playlist':['http://sandbox.thewikies.com/vfe-generator/images/big-buck-bunny_poster.jpg',{'url':'http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4','autoPlay':false}]}" /> <img alt="No Video" src="http://sandbox.thewikies.com/vfe-generator/images/big-buck-bunny_poster.jpg" width="561" height="297" title="No video playback capabilities, please download the video below" /> </object> <strong>Download video:</strong> <a href="video.mp4">MP4 format</a> | <a href="video.ogv">Ogg format</a> | <a href="video.webm">WebM format</a> </video>
Important notes :
- The inclusion of ogg as the first
<source> ended because Mac OS Firefox stops trying to play the video if it encounters MP4 as the first <source> . - The correct MIME types are important .ogv files must be
video/ogg , not video/ogv - If you have HD video, the best transcoder I have found for HD quality OGG files, Firefogg
- The
.iphone.mp4 file is for iPhone 4+, which will only play videos that are MPEG-4 with H.264 Baseline 3 Video and AAC audio. The best transcoder I found for this format is Handbrake, using the iPhone and iPod Touch will work on the iPhone 4+, but in order to get the iPhone 3GS working, you need to use the iPod preset, which has a much lower resolution, which I added as video.iphone3g.mp4 . - In the future, we will be able to use the
media attribute for <source> elements to target mobile devices to media queries, but now older Apple and Android devices do not support it well enough.