Skip to content

Instantly share code, notes, and snippets.

@lafeber
Created June 6, 2011 13:58
Show Gist options
  • Save lafeber/1010308 to your computer and use it in GitHub Desktop.
Save lafeber/1010308 to your computer and use it in GitHub Desktop.

Revisions

  1. @invalid-email-address Anonymous revised this gist Jun 6, 2011. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions replaceVideoWithFlash.js
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    /** 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 )) {
  2. @invalid-email-address Anonymous created this gist Jun 6, 2011.
    22 changes: 22 additions & 0 deletions replaceVideoWithFlash.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    /** Replaces video tag (src=[file].mp4) with flash for Firefox, Opera and IE <9
    Make sure you have flowplayer! (www.flowplayer.org)
    */
    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);
    }
    }
    }