Skip to content

Instantly share code, notes, and snippets.

@toddanglin
Created November 1, 2013 16:23
Show Gist options
  • Save toddanglin/7267876 to your computer and use it in GitHub Desktop.
Save toddanglin/7267876 to your computer and use it in GitHub Desktop.
Example Flash video embed code with HTML5 replacement via JavaScript when HTML5 H.264 is available
<!--Embedded somewhere in an HTML file-->
<div id="vidHolder">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" width="200" height="200">
<param name="flashvars" value="file=YOUR-VIDEO.mp4" />
<param name="movie" value="content/player.swf" />
<embed src="content/player.swf" width="200" height="200" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="file=YOUR-VIDEO.mp4" />
</object>
</div>
//Probably called during page load/init
//(Requires Modernizr library to work: http://modernizr.com/)
if(Modernizr.video.h264 != ""){
//HTML5 H.264 supported, let's create an HTML5 video element
var vid = document.createElement("video");
vid.src = "content/YOUR-VIDEO.mp4";
$(vid).attr("type","video/mp4").attr("autoplay","autoplay").attr("loop","loop").attr("controls","controls").height("200").width("200");
//Remove the Flash video player and append the new HTML5 player
$("#vidHolder").empty().append(vid);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment