Created
June 28, 2010 18:02
-
-
Save robv/456158 to your computer and use it in GitHub Desktop.
This file contains 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
/* | |
* Sample usage: | |
* | |
* HTML: <video width="629" height="350" src="file.m4v" controls="true" poster="file.png"></video> | |
* Javascript: $('video').video({swf_player: '/flash/flowplayer-3.2.2.swf'}); | |
* | |
* | |
*/ | |
(function($) { | |
$.fn.video = function(params) { | |
params = $.extend({swf_player: '/flash/flowplayer-3.2.2.swf'}, params); | |
return this.each(function() { | |
var $this = $(this); | |
if((navigator.userAgent.match(/Safari/i))) | |
{ | |
// Do nothing. | |
} | |
else | |
{ | |
width = $this.attr('width'); | |
height = $this.attr('height'); | |
source = $this.attr('src'); | |
$this.replaceWith('<object width="' + width + '" height="' + height + '" id="_player" name="_player" data="' + params.swf_player + '" type="application/x-shockwave-flash"><param name="movie" value="' + params.swf_player + '" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="flashvars" value=\'config={"clip":{"url":"' + source + '"}}\' /></object>'); | |
} | |
}); | |
return this; | |
}; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment