/* * WPaudio v3.1 (http://wpaudio.com) * by Todd Iceton (todd@wpaudio.com) * * Converts an mp3 link to a simple player styled by HTML & CSS, powered by HTML5 with SoundManager2 Flash fallback * * Copyright 2010 Todd Iceton (email: todd@wpaudio.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ _wpaudio.css={inline:{'.wpaudio-container':{display:'inline-block','font-family':'Sans-serif','line-height':1,'*display':'inline',zoom:1},'.wpaudio-container a':{color:_wpaudio.style.link_color,'text-decoration':'none'},'.wpaudio-container .wpaudio':{'font-family':_wpaudio.style.text_font,'font-size':_wpaudio.style.text_size,'font-weight':_wpaudio.style.text_weight,'letter-spacing':_wpaudio.style.text_letter_spacing},'.wpaudio-play':{margin:'0 5px 0 0',width:'14px',height:'13px',background:'#ccc','vertical-align':'baseline'},'.wpaudio-slide':{display:'none'},'.wpaudio-bar':{position:'relative',margin:'2px 0 0 19px',height:'5px','font-size':'1px',background:_wpaudio.style.bar_base_bg},'.wpaudio-bar-playable':{position:'absolute',top:0,left:0,right:'100%',height:'5px','z-index':11,background:_wpaudio.style.bar_load_bg},'.wpaudio-bar-position':{position:'absolute',top:0,left:0,right:'100%',height:'5px','z-index':12,background:_wpaudio.style.bar_position_bg},'.wpaudio-bar-click':{position:'absolute',top:0,left:0,right:0,width:'100%',height:'5px','z-index':13,cursor:'pointer'},'.wpaudio-meta':{margin:'3px 0 0 19px','font-size':'11px',color:_wpaudio.style.sub_color},'.wpaudio-download':{float:'right'}},head:{'.wpaudio-container a:visited':{color:_wpaudio.style.link_color},'.wpaudio-container a:hover':{color:_wpaudio.style.link_hover_color}}};(function(){var css='';jQuery.each(jQuery.extend({},_wpaudio.css.inline,_wpaudio.css.head),function(css_group,css_rules){css+=css_group+'{';jQuery.each(css_rules,function(css_item,css_value){css+=css_item+':'+css_value+';';});if(!css_rules.margin){css+='margin:0;';} if(!css_rules.border){css+='border:0;';} if(!css_rules.padding){css+='padding:0;';} css+='}';});jQuery('head').append('');}());function Wpaudio(elem){this.elem=elem;var player;this.player=player;var getUrl=function(){return _wpaudio.enc[elem.id]?_wpaudio.enc[elem.id]:elem.href;};this.getUrl=getUrl;var isPlaying=function(){return player.isPlaying();};this.isPlaying=isPlaying;var play=function(){jQuery('.wpaudio-playing').each(function(i,v){v.wpaudio.pause();});player.play();jQuery(elem).addClass('wpaudio-playing').parent().find('.wpaudio-slide:hidden').slideDown();};this.play=play;var pause=function(){player.pause();jQuery(elem).removeClass('wpaudio-playing');};this.pause=pause;var seek=function(percent){if(!isPlaying()){play();} player.seek(percent);};this.seek=seek;var updateDisplay=function(){var info=player.getInfo();var button_url=(info.is_playing)?_wpaudio.url+'/wpaudio-pause.png':_wpaudio.url+'/wpaudio-play.png';if(button_url!==jQuery(elem).children('.wpaudio-play').attr('src')){jQuery(elem).children('.wpaudio-play').attr('src',button_url);} jQuery(elem).parent().find('.wpaudio-bar-position').css({left:String((info.playable_start/info.duration)||0)+'%',width:String((info.position-info.playable_start)/info.duration*100||0)+'%'});jQuery(elem).parent().find('.wpaudio-bar-playable').css({left:String((info.playable_start/info.duration)||0)+'%',width:String((info.playable_end-info.playable_start)/info.duration*100||0)+'%'});var min=Math.floor(info.position/60);var sec=Math.floor(info.position%60);var time_string=min+':';if(sec<10){time_string+='0';} time_string+=sec;jQuery(elem).parent().find('.wpaudio-position').text(time_string);};this.updateDisplay=updateDisplay;var slider='
';jQuery(elem).click(function(){if(isPlaying()){pause();} else{play();} jQuery(this).blur();return false;}).prepend('