Skip to main content

audio player

Ughh, so incredibly simple to add a html5 audio player with jquery.


I placed this in a html/javascript widget:

<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' type='text/javascript'/>
<script type='text/javascript'>
$(document).ready(function(){
  $("a[href$='.mp3']").each(function(){
    var s = $(this).attr('href');
    $(this).after("<p><audio controls='controls'><source src='"+   s +"'       type='audio/mpeg'/></audio></p>");
  });
});
</script>
This appends a player after all links to mp3 files.
Obvioulsy there is no need to load the  jquery library if you have it already in your template. There is also no need to use a widget, you can add the code to your template.






Comments