/***
* jmp3 v0.2.1 - 10.10.2006 (w/eolas fix & jquery object replacement)
* an mp3 player jquery plugin (http://www.sean-o.com/jquery/jmp3)
* by sean o
*
* an easy way make any mp3 playable directly on most any web site (to those using flash & js),
* using the sleek flash single mp3 player & the fantabulous jquery.
*
* simple usage example:
* $(youridorclass).jmp3();
*
* advanced usage example:
* $("#sounddl").jmp3({
* showfilename: "false",
* backcolor: "000000",
* forecolor: "00ff00",
* width: 200,
* showdownload: "false"
* });
*
* html:
* sound.mp3
*
* note: filename must be enclosed in tag. various file paths can be set using the filepath option.
*
* copyright (c) 2006 sean o (http://www.sean-o.com)
* licensed under the mit license:
* http://www.opensource.org/licenses/mit-license.php
*
***/
jquery.fn.jmp3 = function(passedoptions){
// hard-wired options
var playerpath = "/mp3/"; // set this first: path to singlemp3player.swf
// passable options
var options = {
"filepath": "", // path to mp3 file (default: current directory)
"backcolor": "", // background color
"forecolor": "ffffff", // foreground color (buttons)
"width": "25", // width of player
"repeat": "no", // repeat mp3?
"volume": "50", // mp3 volume (0-100)
"autoplay": "false", // play immediately on page load?
"showdownload": "true", // show download button in player
"showfilename": "true" // show .mp3 filename after player
};
// use passed options, if they exist
if (passedoptions) {
jquery.extend(options, passedoptions);
}
// iterate through each object
return this.each(function(){
// filename needs to be enclosed in tag (e.g. mysong.mp3)
var filename = options.filepath + jquery(this).html();
// do nothing if not an .mp3 file
var validfilename = filename.indexof(".mp3");
if (validfilename == -1) { return false; }
// build the player html
var mp3html = '';
// don't display filename if option is set
if (options.showfilename == "false") { jquery(this).html(""); }
jquery(this).prepend(mp3html+" ");
// eolas workaround for ie (thanks kurt!)
if(jquery.browser.msie){ this.outerhtml = this.outerhtml; }
});
};