Created
June 6, 2011 13:58
-
-
Save lafeber/1010308 to your computer and use it in GitHub Desktop.
Replace html5 video tag with flash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Replaces video tag (src=[file].mp4) with flash for Firefox, Opera and IE <9 | |
Make sure you have flowplayer! (www.flowplayer.org) | |
width, height and src of the video should be set | |
*/ | |
function replaceVideoWithFlash() { | |
if(navigator.userAgent.indexOf('Firefox') != -1 || navigator.userAgent.indexOf('Opera') != -1 || ( navigator.userAgent.indexOf('MSIE') != -1 && parseFloat(navigator.appVersion.split("MSIE")[1]) < 9 )) { | |
var videos = document.getElementsByTagName('video'); | |
for(var i=0; i < videos.length ; i++) { | |
var video = videos[i]; | |
var src = video['src']; | |
var width = video['width']; | |
var height = video['height']; | |
fvideodiv = document.createElement('div'); | |
fvideodiv.innerHTML = '<object id="flowplayer_'+i+'" width="' + width + '" height="' + height + '" data="flowplayer-3.2.7.swf" type="application/x-shockwave-flash">' + | |
'<param name="movie" value="flowplayer-3.2.7.swf" />' + | |
'<param name="allowfullscreen" value="true" />' + | |
'<param name="flashvars" value=\'config={"clip":"' + src + '"}\' />' + | |
'</object>'; | |
video.parentNode.insertBefore(fvideodiv, video); | |
video.parentNode.removeChild(video); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment