jQuery Flash Plugin - MP3 Player

« Back to the jQuery flash plugin

This example uses the Single MP3 Player.

Javascript:

$(document).ready(function(){
    $('a[@href$="mp3"]').flash(
        { src: 'singlemp3player.swf', height: 20, width: 100 },
        { version: 7 },
        function(htmlOptions) {
            $this = $(this);
            htmlOptions.flashvars.file = $this.attr('href');
            $this.before($.fn.flash.transform(htmlOptions));						
        }
    );
});

Before:

<li><a href="sound.mp3">sound.mp3</a></li>

After:

<li>
    <embed width="100" height="20" type="application/x-shockwave-flash" src="singlemp3player.swf" pluginspage="http://www.adobe.com/go/getflashplayer" flashvars="file=sound.mp3"/>
    <a href="sound.mp3">sound.mp3</a>
</li>