(function(audiojs,audiojsInstance,container){var path=(function(){var re=new RegExp('audio(\.min)?\.js.*'),scripts=document.getElementsByTagName('script');for(var i=0,ii=scripts.length;i \ \ \ \ ',settings:{autoplay:false,loop:false,preload:true,imageLocation:path+'player-graphics.gif',swfLocation:path+'audiojs.swf',useFlash:(function(){var a=document.createElement('audio');return!(a.canPlayType&&a.canPlayType('audio/mpeg;').replace(/no/,''));})(),hasFlash:(function(){if(navigator.plugins&&navigator.plugins.length&&navigator.plugins['Shockwave Flash']){return true;}else if(navigator.mimeTypes&&navigator.mimeTypes.length){var mimeType=navigator.mimeTypes['application/x-shockwave-flash'];return mimeType&&mimeType.enabledPlugin;}else{try{var ax=new ActiveXObject('ShockwaveFlash.ShockwaveFlash');return true;}catch(e){}} return false;})(),createPlayer:{markup:'\
\

\

\

\

\
\
\
\
\
\
\ 00:0000:00 \
\
',playPauseClass:'play-pause',scrubberClass:'scrubber',progressClass:'progress',loaderClass:'loaded',timeClass:'time',durationClass:'duration',playedClass:'played',errorMessageClass:'error-message',playingClass:'playing',loadingClass:'loading',errorClass:'error'},trackEnded:function(e){},flashError:function(){var player=this.settings.createPlayer,errorMessage=getByClass(player.errorMessageClass,this.wrapper),html='Missing flash player plugin.';if(this.mp3)html+=' Download audio file.';container[audiojs].helpers.removeClass(this.wrapper,player.loadingClass);container[audiojs].helpers.addClass(this.wrapper,player.errorClass);errorMessage.innerHTML=html;},loadError:function(e){var player=this.settings.createPlayer,errorMessage=getByClass(player.errorMessageClass,this.wrapper);container[audiojs].helpers.removeClass(this.wrapper,player.loadingClass);container[audiojs].helpers.addClass(this.wrapper,player.errorClass);errorMessage.innerHTML='Error loading: "'+this.mp3+'"';},init:function(){var player=this.settings.createPlayer;container[audiojs].helpers.addClass(this.wrapper,player.loadingClass);},loadStarted:function(){var player=this.settings.createPlayer,duration=getByClass(player.durationClass,this.wrapper),m=Math.floor(this.duration/60),s=Math.floor(this.duration%60);container[audiojs].helpers.removeClass(this.wrapper,player.loadingClass);duration.innerHTML=((m<10?'0':'')+m+':'+(s<10?'0':'')+s);},loadProgress:function(percent){var player=this.settings.createPlayer,scrubber=getByClass(player.scrubberClass,this.wrapper),loaded=getByClass(player.loaderClass,this.wrapper);loaded.style.width=(scrubber.offsetWidth*percent)+'px';},playPause:function(){if(this.playing)this.settings.play();else this.settings.pause();},play:function(){var player=this.settings.createPlayer;container[audiojs].helpers.addClass(this.wrapper,player.playingClass);},pause:function(){var player=this.settings.createPlayer;container[audiojs].helpers.removeClass(this.wrapper,player.playingClass);},updatePlayhead:function(percent){var player=this.settings.createPlayer,scrubber=getByClass(player.scrubberClass,this.wrapper),progress=getByClass(player.progressClass,this.wrapper);progress.style.width=(scrubber.offsetWidth*percent)+'px';var played=getByClass(player.playedClass,this.wrapper),p=this.duration*percent,m=Math.floor(p/60),s=Math.floor(p%60);played.innerHTML=((m<10?'0':'')+m+':'+(s<10?'0':'')+s);}},create:function(element,options){var options=options||{} if(element.length){return this.createAll(options,element);}else{return this.newInstance(element,options);}},createAll:function(options,elements){var audioElements=elements||document.getElementsByTagName('audio'),instances=[] options=options||{};for(var i=0,ii=audioElements.length;iaudio.loadedPercent)return;audio.updatePlayhead.call(audio,[percent]) audio.element.skipTo(percent);} audio['updatePlayhead']=function(percent){audio.settings.updatePlayhead.apply(audio,[percent]);} audio['play']=function(){if(!audio.settings.preload){audio.settings.preload=true;audio.element.init(audio.mp3);} audio.playing=true;audio.element.pplay();audio.settings.play.apply(audio);} audio['pause']=function(){audio.playing=false;audio.element.ppause();audio.settings.pause.apply(audio);} audio['setVolume']=function(v){audio.element.setVolume(v);} audio['loadStarted']=function(){audio.swfReady=true;if(audio.settings.preload)audio.element.init(audio.mp3);if(audio.settings.autoplay)audio.play.apply(audio);}},injectFlash:function(audio,id){var flashSource=this.flashSource.replace(/\$1/g,id);flashSource=flashSource.replace(/\$2/g,audio.settings.swfLocation);flashSource=flashSource.replace(/\$3/g,(+new Date+Math.random()));var html=audio.wrapper.innerHTML,div=document.createElement('div');div.innerHTML=flashSource+html;audio.wrapper.innerHTML=div.innerHTML;audio.element=this.helpers.getSwf(id);},helpers:{merge:function(obj1,obj2){for(attr in obj2){if(obj1.hasOwnProperty(attr)||obj2.hasOwnProperty(attr)){obj1[attr]=obj2[attr];}}},clone:function(obj){if(obj==null||typeof(obj)!=='object')return obj;var temp=new obj.constructor();for(var key in obj)temp[key]=arguments.callee(obj[key]);return temp;},addClass:function(element,className){var re=new RegExp('(\\s|^)'+className+'(\\s|$)');if(re.test(element.className))return;element.className+=' '+className;},removeClass:function(element,className){var re=new RegExp('(\\s|^)'+className+'(\\s|$)');element.className=element.className.replace(re,' ');},injectCss:function(audio,string){var prepend='',styles=document.getElementsByTagName('style'),css=string.replace(/\$1/g,audio.settings.imageLocation);for(var i=0,ii=styles.length;i1?swf[swf.length-1]:swf;}},events:{memoryLeaking:false,listeners:[],addListener:function(element,eventName,func){if(element.addEventListener){element.addEventListener(eventName,func,false);}else if(element.attachEvent){this.listeners.push(element);if(!this.memoryLeaking){window.attachEvent('onunload',function(){if(this.listeners){for(var i=0,ii=this.listeners.length;i-1){if(!ios)audio.init.apply(audio);} if(audio.element.readyState>1){if(audio.settings.autoplay)audio.play.apply(audio);clearInterval(readyTimer);loadTimer=setInterval(function(){audio.loadProgress.apply(audio);if(audio.loadedPercent>=1)clearInterval(loadTimer);});}},10);audio.readyTimer=readyTimer;audio.loadTimer=loadTimer;},purge:function(d){var a=d.attributes,i;if(a){for(i=0;ithis.loadedPercent)return;this.element.currentTime=this.duration*percent;this.updatePlayhead();},load:function(mp3){this.loadStartedCalled=false;this.source.setAttribute('src',mp3);this.element.load();this.mp3=mp3;container[audiojs].events.trackLoadProgress(this);},loadError:function(){this.settings.loadError.apply(this);},init:function(){this.settings.init.apply(this);},loadStarted:function(){if(!this.element.duration)return false;this.duration=this.element.duration;this.updatePlayhead();this.settings.loadStarted.apply(this);},loadProgress:function(){if(this.element.buffered!=null&&this.element.buffered.length){if(!this.loadStartedCalled){this.loadStartedCalled=this.loadStarted();} var durationLoaded=this.element.buffered.end(this.element.buffered.length-1);this.loadedPercent=durationLoaded/this.duration;this.settings.loadProgress.apply(this,[this.loadedPercent]);}},playPause:function(){if(this.playing)this.pause();else this.play();},play:function(){var ios=(/(ipod|iphone|ipad)/i).test(navigator.userAgent);if(ios&&this.element.readyState==0)this.init.apply(this);if(!this.settings.preload){this.settings.preload=true;this.element.setAttribute('preload','auto');container[audiojs].events.trackLoadProgress(this);} this.playing=true;this.element.play();this.settings.play.apply(this);},pause:function(){this.playing=false;this.element.pause();this.settings.pause.apply(this);},setVolume:function(v){this.element.volume=v;},trackEnded:function(e){this.skipTo.apply(this,[0]);if(!this.settings.loop)this.pause.apply(this);this.settings.trackEnded.apply(this);}} var getByClass=function(searchClass,node){var matches=[];node=node||document;if(node.getElementsByClassName){matches=node.getElementsByClassName(searchClass);}else{var i,l,els=node.getElementsByTagName("*"),pattern=new RegExp("(^|\\s)"+searchClass+"(\\s|$)");for(i=0,l=els.length;i1?matches:matches[0];};})('audiojs','audiojsInstance',this);