Skip to content

Instantly share code, notes, and snippets.

@imathis
Created September 23, 2010 13:41
Show Gist options
  • Select an option

  • Save imathis/593617 to your computer and use it in GitHub Desktop.

Select an option

Save imathis/593617 to your computer and use it in GitHub Desktop.
var flashPlayerLocation = "/assets/jwplayer/player.swf";
var flashPlayerSkin = "/assets/jwplayer/glow/glow.xml";
window.addEvent('domready', function() {
html5toFlash();
});
function html5toFlash(){
var videos = $$('video');
if(!videos){return}
videos.each(function(video){
source = video.getElement('source').get('src');
if(!source.contains('mp4') || !Modernizr.video.h264){
flashvid = new Element('object', {
'width': video.get('width').toInt() + 'px',
'height': video.get('height').toInt() + 19 + 'px',
'type': 'application/x-shockwave-flash',
'data': flashPlayerLocation
});
flashvid.adopt([
new Element('param', {
'name':'movie', 'value' : source
}),
new Element('param', {
'name':'allowfullscreen', 'value':'true'
}),
new Element('param', {
'name':'flashvars', 'value' : "file="+source+"&skin="+flashPlayerSkin
})
])
flashvid.inject(video, 'after');
video.dispose();
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment