Skip to content

Instantly share code, notes, and snippets.

@banterability
Created May 21, 2010 21:04
Show Gist options
  • Save banterability/409431 to your computer and use it in GitHub Desktop.
Save banterability/409431 to your computer and use it in GitHub Desktop.
html5 with a fallback for mp3-hating firefox with a fallback to flash with a fallback to a link
<div class="html5audio">
<div id="no-ogg" style="display:none;">
<div id="flash-player">
<a href="foo.mp3">Download Audio</a>
</div>
</div>
<audio controls>
<source src="foo.mp3" type="audio/mpeg" />
<div id="flash-player">
<a href="foo.mp3">Download Audio</a>
</div>
</audio>
</div>
<script type="text/javascript" charset="utf-8">
function embedFlash(){
var flashvars = {};
// define flashvars
var params = {};
// define params
var attributes = {};
// define attributes
swfobject.embedSWF("player.swf", "flash-player", "180", "14", "9.0.0", false, flashvars, params, attributes);
}
$(document).ready(function() {
if ($.browser.mozilla){
$('audio').remove();
$('div.html5audio div#no-ogg').show();
} else {
$("div.html5audio div#no-ogg *").remove();
}
embedFlash();
});
</script>
@banterability
Copy link
Author

To do: one more level -- flash detection -- for the saddest of sad browsers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment