Files

11 lines
32 KiB
JavaScript
Executable File

/*
* Simple HTML5 Audio Player V1
* http://codecanyon.net/item/simple-html5-audio-player-v1/495024
*
* Author: Ivan da Silveira
* Version: 1.1.3
* Copyright 2011
*
* Only for the sale at the envato marketplaces
*/
(function(ad){var V=false;var P=window;var L=ad(P);var r=document;var n=ad(r);var g=navigator;var e=0;var U=[];var aa=[];var I=[];var u="AudioPlayerV1";var ag='<ul class="AudioPlayerV1 APV1_wrapper"><li><div class="APV1_play_button">&nbsp;</div></li><li><div class="APV1_seperator APV1_for_play">&nbsp;</div></li><li><div class="APV1_time_text"> 00:00 </div></li><li><div class="APV1_seperator APV1_for_time">&nbsp;</div></li><li class="APV1_container"><div class="APV1_progress_bar_container"><div class="APV1_progress_bar_wrapper"><div class="APV1_seek_bar">&nbsp;</div><div class="APV1_play_bar APV1_transition">&nbsp;</div>&nbsp;</div>&nbsp;</div></li><li><div class="APV1_seperator APV1_for_duration">&nbsp;</div></li><li><div class="APV1_duration_text"> 00:00 </div></li><li><div class="APV1_seperator APV1_for_volume">&nbsp;</div></li><li><div class="APV1_volume_button">&nbsp;</div></li><li><div class="APV1_volume_bar_container"><div class="APV1_volume_bar">&nbsp;</div>&nbsp;</div></li></ul>';var k="fn";var b="Shockwave Flash";var l="ShockwaveFlash.ShockwaveFlash";var d="application/x-shockwave-flash";var ak="10";var h="APV1_";var F="__flash__";var ay=(((P.requestAnimationFrame&&P.cancelRequestAnimationFrame)?P.requestAnimationFrame:undefined)||((P.webkitRequestAnimationFrame&&P.webkitCancelRequestAnimationFrame)?P.webkitRequestAnimationFrame:undefined)||((P.mozRequestAnimationFrame&&P.mozCancelRequestAnimationFrame)?P.mozRequestAnimationFrame:undefined)||((P.oRequestAnimationFrame&&P.oCancelRequestAnimationFrame)?P.oRequestAnimationFrame:undefined)||((P.msRequestAnimationFrame&&P.msCancelRequestAnimationFrame)?P.msRequestAnimationFrame:undefined)||undefined);var B=(P.cancelRequestAnimationFrame||P.webkitCancelRequestAnimationFrame||P.mozCancelRequestAnimationFrame||P.oCancelRequestAnimationFrame||P.msCancelRequestAnimationFrame||undefined);var N={READY:"ready",PROGRESS:"progress",TIME_UPDATE:"timeupdate",CAN_PLAY:"canplay",RATE_CHANGE:"ratechange",PLAYING:"playing",WAITING:"waiting",STARTED:"started",PLAY:"play",PAUSE:"pause",ENDED:"ended",VOLUME_CHANGE:"volumechange",DURATION_CHANGE:"durationchange",ERROR:"error"};var c={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_UP:"mouseup",MOUSE_OUT:"mouseout",MOUSE_MOVE:"mousemove",CONTEXT_MENU:"contextmenu"};var au={TRANSITION:"APV1_transition",PLAYING:"APV1_playing",MUTE:"APV1_mute",ERROR:"APV1_error"};var o={DISPLAY_BLOCK:"display:block !important;",DISPLAY_NONE:"display:none !important;",ZERO:"0 !important;",STYLE:"style"};var ah={DATA_CONTROLS_TIME:"data-controls-time",DATA_CONTROLS_VOLUME:"data-controls-volume",DATA_CONTROLS_DURATION:"data-controls-duration",DATA_VOLUME:"data-volume",DATA_FALLBACK:"data-fallback",WIDTH:"width",HEIGHT:"height",CONTROLS:"controls"};var f={menu:"false",quality:"low",wmode:"window",allowScriptAccess:"sameDomain"};if(Q(ad[k][u])){return}function aq(){return ad.browser["msie"]&&parseInt(ad.browser["version"],10)<=8}(function H(){if(aq()){r.createElement("audio");r.createElement("source")}})();function ai(aC){var az=null;var aA=r.getElementById(aC);if(aA&&aA.nodeName=="OBJECT"){if(typeof aA.SetVariable!="undefined"){az=aA}else{var aB=aA.getElementsByTagName(OBJECT)[0];if(aB){az=aB}}}return az}function ap(){if(!Q(this.available)){var aC=null;var aA=null;if(Q(g.plugins)&&q(g.plugins[b])){aA=g.plugins[b].description;if(aA&&!(Q(g.mimeTypes)&&Q(g.mimeTypes[d])&&!Q(g.mimeTypes[d].enabledPlugin))){aA=aA.replace(/^.*\s+(\S+\s+\S+$)/,"$1");aC=parseInt(aA.replace(/^(.*)\..*$/,"$1"),10)}}else{if(Q(P.ActiveXObject)){try{var az=new ActiveXObject(l);if(az){aA=az.GetVariable("$version");if(aA){aA=aA.split(" ")[1].split(",");aC=parseInt(aA[0],10)}}}catch(aB){}}}this.available=(parseInt(ak,10)<=aC)}return this.available}function v(aA,aD,aL,aH,aF,aG,aB,aI){var aE;var aJ;var aK;f.name=aA;f.flashvars="src="+aH+"&volume="+aF+"&loop="+aG+"&autoplay="+aB+"&preload="+aI+"&id="+aA;if(aq()){f.movie=aL;var aC="";for(aK in f){aJ=f[aK];if(aJ!=Object.prototype[aK]){aC+='<param name="'+aK+'" value="'+aJ+'" />'}}var az=ad("<div>");W(aD,az);az.get(0).outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="'+aA+'" width="0" height="0">'+aC+"</object>"}else{aE=ad('<object id="'+aA+'" width="0" height="0" data="'+aL+'" type="'+d+'">');for(aK in f){aJ=f[aK];if(aJ!=Object.prototype[aK]&&aK!="movie"){w(aE,ad('<param name="'+aK+'" value="'+aJ+'">'))}}W(aD,aE)}}function ae(aB,az){if(Q(ay)){if(Q(az)){A(az);var aA=ay(function(){aa[az]=null;aB.call()});aa[az]=aA;return aA}else{return ay(aB)}}else{return aB.call()}}function A(az){if(az&&Q(B)){var aA=aa[az];if(aA){B(aA)}}}function a(aB){var aA=am(aB);var az;if(aA){if(aA.match(/m(p3|3a)/i)){az="mpeg"}else{if(aA.match(/m4a|mp4/i)){az="mp4"}else{if(aA.match(/webm|webma/i)){az="webm"}else{if(aA.match(/wav/i)){az="wav"}else{if(aA.match(/og[ga]/i)){az="ogg"}}}}}}return Q(az)?"audio/"+az:""}function am(az){var aA=/^.+\.([^.]+)$/.exec(az);return at(aA)?null:aA[1]}function m(aE,aG){var aA=parseInt(aE,10),aC=Math.floor(aA/3600),az=Math.floor(aA%3600/60),aB=Math.floor(aA%3600%60);if(aG){var aF=parseInt(aG,10),aD=Math.floor(aF/3600);return((aC>0?(aD<10||aC>9?aC+":":"0"+aC+":"):(aD>0?(aD<10?"0:":"00:"):""))+(az>0?(az<10?"0":"")+az+":":"00:")+(aB<10?"0":"")+aB)}else{return((aC>0?aC+":":"")+(az>0?(az<10?"0":"")+az+":":"00:")+(aB<10?"0":"")+aB)}}function al(aC,az,aA){var aB=Number(aC);az=Number(az)||1;aA=Number(aA)||0;return aB>=az?az:(aB<=aA?aA:aB)}function C(az){aw(U,function(){if(az!=this&&!this.paused()){this.pause()}})}function Y(aA){var az=0;var aB=aA.get(0);while(aB&&!M(aB.offsetLeft)){az+=aB.offsetLeft;aB=aB.offsetParent}return az}function av(az){return Math.round(Number(az)*10)/10}function i(aB,aC,aD){if(aD){var aA=new Date();aA.setTime(aA.getTime()+(aD*86400000));var az="; expires="+aA.toGMTString()}else{var az=""}r.cookie=aB+"="+aC+az+"; path=/"}function K(aA){var aC=aA+"=";var az=r.cookie.split(";");for(var aB=0;aB<az.length;aB++){var aD=az[aB];while(aD.charAt(0)==" "){aD=aD.substring(1,aD.length)}if(aD.indexOf(aC)==0){return aD.substring(aC.length,aD.length)}}return null}function s(az){if(Q(P.localStorage)){try{localStorage.setItem(u,az)}catch(aA){i(u,az,30)}}else{i(u,az,30)}}function y(){var az;if(Q(P.localStorage)){try{az=localStorage.getItem(u)}catch(aA){}}if(!Q(az)||at(az)||M(az)){az=K(u)}return Q(az)&&!at(az)&&!M(az)?az:null}function af(aA,az){aA.html(az)}function w(aA,az){aA.append(az)}function W(aA,az){aA.after(az)}function z(az){return ad(az)["remove"]()}function O(aA,aB,az){if(az){return aA.css(aB,az)}else{return aA.css(aB)}}function D(aA,aB,az){return aA.attr(aB,az)}function T(az,aA){return az.removeAttr(aA)}function Z(az,aA){return az.text(aA)}function ao(az,aA){az.addClass(aA)}function ar(az,aA){az.removeClass(aA)}function an(aA,az,aB){aA.bind(az,aB)}function x(aA,az,aB){aA.unbind(az,aB)}function ax(aA,az){return aA.find(az)}function aw(az,aA){return ad(az)["each"](aA)}function t(aA,az){return aA.is(az)}function p(aA,az){return ad.proxy(aA,az)}function ac(aA,az){return aA.width(az)}function j(aA,az){return aA.height(az)}function aj(az){return typeof az==="function"}function q(az){return typeof az==="object"}function Q(az){return typeof(az)!=="undefined"}function at(az){return az==null}function M(az){return !(az>=0||az<0)}function X(aA,az){function aB(){}aB.prototype=az.prototype;aA.superClass_=az.prototype;aA.prototype=new aB();aA.prototype.constructor=aA}function E(){this.events_=[]}E.prototype.addEventListener=function(az,aA){this.events_[az]=this.events_[az]||[];this.events_[az].push(aA)};E.prototype.removeEventListener=function(aA,aB){var az=this.events_[aA];if(az){aw(az,function(aC){if(this===aB){az.splice(aC,1)}})}};E.prototype.hasEventListener=function(az){return Boolean(this.events_[az]&&this.events_[az].length>0)};E.prototype.dispatchEvent=function(aB){var aA=this.events_[aB];if(aA){var az=this;aw(aA,function(){this.call(az,aB)})}};E.prototype.destroy=function(){delete this.events_};function R(az,aA){E.call(this);this.element_=aA;this.object_=az;this.available=this.hasProperty("canPlayType")&&this.hasPlayableSource_();this.hackTimerInterval_=1000/10;this.hackTimerId_=null;this.isBindEvents_=false;this.isUnloading_=false;this.ready=false;this.started=false;this.canplay=false;this.currentTime_=0;this.progress_=0;this.duration_=0;if(!this.available){return}this.bindEvents_();if(aA.playing){this.playingHandler__()}this.readyHandler__()}X(R,E);R.prototype.bindEvents_=function(){if(this.isBindEvents_){return}this.isBindEvents_=true;an(this.object_,N.CAN_PLAY,p(this.canplayHandler__,this));an(this.object_,N.PLAYING,p(this.playingHandler__,this));an(this.object_,N.PLAY,p(this.playingHandler__,this));an(this.object_,N.PAUSE,p(this.pauseHandler__,this));an(this.object_,N.ENDED,p(this.endedHandler__,this));an(this.object_,N.TIME_UPDATE,p(this.timeupdateHandler__,this));an(this.object_,N.PROGRESS,p(this.progressHandler__,this));an(this.object_,N.DURATION_CHANGE,p(this.durationchangeHandler__,this));an(this.object_,N.VOLUME_CHANGE,p(this.volumechangeHandler__,this));an(this.object_,N.ERROR,p(this.errorHandler__,this))};R.prototype.unbindEvents_=function(){if(!this.isBindEvents_){return}this.isBindEvents_=false;x(this.object_,N.CAN_PLAY,this.canplayHandler__);x(this.object_,N.PLAYING,this.playingHandler__);x(this.object_,N.PLAY,this.playingHandler__);x(this.object_,N.PAUSE,this.pauseHandler__);x(this.object_,N.ENDED,this.endedHandler__);x(this.object_,N.TIME_UPDATE,this.timeupdateHandler__);x(this.object_,N.PROGRESS,this.progressHandler__);x(this.object_,N.DURATION_CHANGE,this.durationchangeHandler__);x(this.object_,N.VOLUME_CHANGE,this.volumechangeHandler__);x(this.object_,N.ERROR,this.errorHandler__)};R.prototype.destroy=function(){this.unbindEvents_();R.superClass_.destroy.call(this)};R.prototype.reset_=function(){this.canplay=false;this.started=false;this.currentTime_=0;this.progress_=0;this.duration_=0};R.prototype.hasPlayableSource_=function(){var aA=ax(this.object_,"source");var az=this;var aB;aw(aA,function(aC){var aF=D(ad(this),"src");var aD=a(aF);var aE=az.canPlayType(aD);if(aE=="maybe"||aE=="probably"){aB=aF;return false}});return aB||false};R.prototype.hasProperty=function(az){return Q(this.element_[az])};R.prototype.canPlayType=function(az){return this.element_.canPlayType(az)};R.prototype.autoplay=function(){return this.element_.autoplay};R.prototype.setAutoplay=function(az){this.element_.autoplay=az};R.prototype.loop=function(){return this.element_.loop||t(this.object_,"[loop]")};R.prototype.setLoop=function(az){this.element_.loop=az};R.prototype.preload=function(){return this.element_.preload};R.prototype.setPreload=function(az){this.element_.preload=az};R.prototype.duration=function(){return this.duration_||this.element_.duration};R.prototype.ended=function(){return this.element_.ended};R.prototype.paused=function(){return this.element_.paused};R.prototype.currentSrc=function(){return this.currentSource_||this.element_.currentSrc};R.prototype.src=function(){return this.element_.src};R.prototype.setSrc=function(az){this.element_.src=az;this.currentSource_=az};R.prototype.volume=function(){return this.element_.volume};R.prototype.setVolume=function(az){this.element_.volume=al(az)};R.prototype.progress=function(){return this.progress_};R.prototype.currentTime=function(){return this.currentTime_||this.element_.currentTime};R.prototype.setCurrentTime=function(az){if(this.element_.currentTime!=az){this.element_.currentTime=al(az,this.duration())}};R.prototype.play=function(aA){if(Q(aA)){var az;if(typeof aA==="object"){az=aA}else{if(typeof aA==="string"){az=P.getElementById(aA)}}if(az&&az.tagName.toLowerCase()=="audio"){this.load(az.currentSrc||az.src)}}this.element_.play()};R.prototype.pause=function(){this.element_.pause()};R.prototype.load=function(az){var aA=az||this.currentSource_;if(aA){this.setSrc(aA)}this.reset_();this.bindEvents_();this.element_.load()};R.prototype.unload=function(){this.isUnloading_=true;this.pause();this.setCurrentTime(0);this.unbindEvents_();this.reset_();this.element_.src="";this.element_.load()};R.prototype.startTimer_=function(){if(!this.hackTimerId_){this.hackTimerId_=setInterval(p(this.timerHandler_,this),this.hackTimerInterval_);this.timerHandler_()}};R.prototype.stopTimer_=function(){if(this.hackTimerId_){clearInterval(this.hackTimerId_);this.hackTimerId_=null}};R.prototype.timerHandler_=function(){this.timeupdateHandler__();this.progressHandler__();this.canplayHandler__();this.startedHandler__()};R.prototype.readyHandler__=function(){this.ready=true;this.dispatchEvent(N.READY)};R.prototype.progressHandler__=function(aJ){if(this.hasEventListener(N.PROGRESS)){var aC=this.element_.buffered;var aE=this.element_.duration;if(aC&&aE){var aB=aC.length;if(aB){var aK=aE;var aI=aB-1;var aF=this.element_.currentTime;for(var aH=0;aH<aB;aH++){var aG=aC.end(aH);if(aG>=aF&&aG<aK){aK=aG;aI=aH}}var az=parseInt(aC.end(aI)/aE*100,10);if(this.progress_!=az){this.progress_=az;this.dispatchEvent(N.PROGRESS)}}}else{if(aJ){var aA=aJ.originalEvent;var aL=aA.loaded;var aD=aA.total;if(aL&&aD){var az=parseInt(aL/aD*100,10);if(this.progress_!=az){this.progress_=az;this.dispatchEvent(N.PROGRESS)}}}}}};R.prototype.timeupdateHandler__=function(){var az=this.element_.currentTime;if(this.currentTime_!=az){this.currentTime_=az;this.dispatchEvent(N.TIME_UPDATE)}};R.prototype.durationchangeHandler__=function(){var az=this.element_.duration;if(this.duration_!=az){this.duration_=az;this.dispatchEvent(N.DURATION_CHANGE)}};R.prototype.volumechangeHandler__=function(){this.dispatchEvent(N.VOLUME_CHANGE)};R.prototype.canplayHandler__=function(az){if(this.hasEventListener(N.CAN_PLAY)){if(!this.canplay){if(Q(az)||!M(this.element_.duration)){this.canplay=true;this.dispatchEvent(N.CAN_PLAY)}}}};R.prototype.startedHandler__=function(az){if(!this.started){if(Q(az)||this.currentTime()>0){this.started=true;this.dispatchEvent(N.STARTED)}}};R.prototype.playingHandler__=function(){this.startTimer_();this.canplayHandler__();this.startedHandler__();this.dispatchEvent(N.PLAYING)};R.prototype.pauseHandler__=function(){this.stopTimer_();this.dispatchEvent(N.PAUSE)};R.prototype.endedHandler__=function(){this.stopTimer_();this.started=false;this.dispatchEvent(N.ENDED)};R.prototype.errorHandler__=function(){this.stopTimer_();if(this.isUnloading_){this.isUnloading_=false}else{this.dispatchEvent(N.ERROR)}};function J(aB,aD){R.call(this,aB,aD);if(this.available){return}this.flashMode_=true;this.flashId_="APV1ID_"+e;var aC=(D(aB,ah.DATA_FALLBACK)||ad[k][u]["defaultOptions"][ah.DATA_FALLBACK]);var aF=this.getPlayableFlashSource_();var aE=1;var az=D(aB,"loop")?true:false;var aG=D(aB,"autoplay")?true:false;var aA=D(aB,"preload")=="auto";if(V){console.log("loop: ",az);console.log("autoplay: ",aG);console.log("preload: ",aA);console.log("audio: ",aF)}this.swf_=null;I[this.flashId_]=this;if(ap()&&aF){this.available=true;v(this.flashId_,aB,aC,aF,aE,az,aG,aA)}}X(J,R);J.prototype.destroy=function(){J.superClass_.destroy.call(this);if(this.swf_){z(this.swf_)}I.splice(this.flashId_,1)};J.prototype.flashCall_=function(az){if(V){console.log(az)}if(this.available&&this.swf_&&Q(this.swf_[h+az])){return this.swf_[h+az]()}};J.prototype.flashCallWidth_=function(az,aA){if(V){console.log(az)}if(this.available&&this.swf_&&Q(this.swf_[h+az])){return this.swf_[h+az](aA)}};J.prototype.play=function(az){if(this.flashMode_){if(Q(az)){}else{this.flashCall_("play")}}else{J.superClass_.play.call(this,az)}};J.prototype.pause=function(){if(this.flashMode_){this.flashCall_("pause")}else{J.superClass_.pause.call(this)}};J.prototype.getPlayableFlashSource_=function(){if(this.flashSource_){return this.flashSource_}else{var aA=ax(this.object_,"source");var az=this;var aB;aw(aA,function(aC){var aE=D(ad(this),"src");var aD=a(aE);if(aD=="audio/mpeg"||aD=="audio/mp4"||aD=="audio/wav"){aB=aE;return false}});this.flashSource_=aB||false;return this.flashSource_}};J.prototype.hasPlayableSource_=function(){if(this.flashMode_){return this.getPlayableFlashSource_()?true:false}else{return J.superClass_.hasPlayableSource_.call(this)}};J.prototype.autoplay=function(){if(this.flashMode_){return this.flashCall_("autoplay")}else{return J.superClass_.autoplay.call(this)}};J.prototype.setAutoplay=function(az){if(this.flashMode_){this.flashCallWidth_("setAutoplay",az)}else{J.superClass_.setAutoplay.call(this,az)}};J.prototype.loop=function(){if(this.flashMode_){return this.flashCall_("loop")}else{return J.superClass_.loop.call(this)}};J.prototype.setLoop=function(az){if(this.flashMode_){this.flashCallWidth_("setLoop",az)}else{J.superClass_.setLoop.call(this,az)}};J.prototype.preload=function(){if(this.flashMode_){return this.flashCall_("preload")}else{return J.superClass_.preload.call(this)}};J.prototype.setPreload=function(az){if(this.flashMode_){az=az==false||az=="false"||az=="none"?false:true;this.flashCallWidth_("setPreload",az)}else{J.superClass_.setPreload.call(this,az)}};J.prototype.duration=function(){if(this.flashMode_){return this.duration_||this.flashCall_("duration")}else{return J.superClass_.duration.call(this)}};J.prototype.ended=function(){if(this.flashMode_){return this.flashCall_("ended")}else{return J.superClass_.ended.call(this)}};J.prototype.paused=function(){if(this.flashMode_){return this.flashCall_("paused")}else{return J.superClass_.paused.call(this)}};J.prototype.currentSrc=function(){if(this.flashMode_){return this.flashCall_("currentSrc")}else{return J.superClass_.currentSrc.call(this)}};J.prototype.src=function(){if(this.flashMode_){return this.flashCall_("src")}else{return J.superClass_.src.call(this)}};J.prototype.setSrc=function(az){if(this.flashMode_){this.flashCallWidth_("setSrc",az)}else{J.superClass_.setSrc.call(this,az)}};J.prototype.volume=function(){if(this.flashMode_){return this.flashCall_("volume")}else{return J.superClass_.volume.call(this)}};J.prototype.setVolume=function(az){if(this.flashMode_){this.flashCallWidth_("setVolume",az)}else{J.superClass_.setVolume.call(this,az)}};J.prototype.progress=function(){if(this.flashMode_){return this.progress_||this.flashCall_("progress")}else{return J.superClass_.progress.call(this)}};J.prototype.currentTime=function(){if(this.flashMode_){return this.currentTime_||this.flashCall_("currentTime")}else{return J.superClass_.currentTime.call(this)}};J.prototype.setCurrentTime=function(az){if(this.flashMode_){this.flashCallWidth_("setCurrentTime",az)}else{J.superClass_.setCurrentTime.call(this,az)}};J.prototype.load=function(az){if(this.flashMode_){this.flashCallWidth_("load",az)}else{J.superClass_.load.call(this,az)}};J.prototype.unload=function(){if(this.flashMode_){this.flashCall_("unload")}else{J.superClass_.unload.call(this)}};J.prototype.readyHandler__=function(){if(this.flashMode_){this.ready=true;this.dispatchEvent(N.READY)}else{J.superClass_.readyHandler__.call(this)}};J.prototype.timeupdateHandler__=function(){if(this.flashMode_){this.dispatchEvent(N.TIME_UPDATE)}else{J.superClass_.timeupdateHandler__.call(this)}};J.prototype.progressHandler__=function(){if(this.flashMode_){this.dispatchEvent(N.PROGRESS)}else{J.superClass_.progressHandler__.call(this)}};J.prototype.canplayHandler__=function(){if(this.flashMode_){this.dispatchEvent(N.CAN_PLAY)}else{J.superClass_.canplayHandler__.call(this)}};J.prototype.playingHandler__=function(){if(this.flashMode_){this.dispatchEvent(N.PLAYING)}else{J.superClass_.playingHandler__.call(this)}};J.prototype.startingHandler__=function(){if(this.flashMode_){this.dispatchEvent(N.STARTED)}else{J.superClass_.startingHandler__.call(this)}};J.prototype.playHandler__=function(){if(this.flashMode_){this.dispatchEvent(N.PLAY)}else{J.superClass_.playHandler__.call(this)}};J.prototype.pauseHandler__=function(){if(this.flashMode_){this.dispatchEvent(N.PAUSE)}else{J.superClass_.pauseHandler__.call(this)}};J.prototype.endedHandler__=function(){if(this.flashMode_){this.dispatchEvent(N.ENDED)}else{J.superClass_.endedHandler__.call(this)}};J.prototype.volumechangeHandler__=function(){if(this.flashMode_){this.dispatchEvent(N.VOLUME_CHANGE)}else{J.superClass_.volumechangeHandler__.call(this)}};J.prototype.durationchangeHandler__=function(){if(this.flashMode_){this.dispatchEvent(N.DURATION_CHANGE)}else{J.superClass_.durationchangeHandler__.call(this)}};J.prototype.errorHandler__=function(){if(this.flashMode_){this.dispatchEvent(N.ERROR)}else{J.superClass_.errorHandler__.call(this)}};function G(aB,aC){J.call(this,aB,aC);this.identifier_=e++;this.offset_=0;this.time_=0;this.isSeekingTimeline_=false;this.isSeekingVolume_=false;this.isMuted_=false;var aE=D(aB,ah.WIDTH);var az=D(aB,ah.HEIGHT);this.playerWidth_=aE||ad.fn[u]["defaultOptions"][ah.WIDTH];this.playerHeight_=az||ad.fn[u]["defaultOptions"][ah.HEIGHT];var aA=this.controlsDisplay_=ad(ag);this.playButton_=ax(aA,".APV1_play_button");this.timeTextDisplay_=ax(aA,".APV1_time_text");this.containerDisplay_=ax(aA,".APV1_container");this.progressContainerDisplay_=ax(aA,".APV1_progress_bar_container");this.progressWrapperDisplay_=ax(aA,".APV1_progress_bar_wrapper");this.seekBarDisplay_=ax(aA,".APV1_seek_bar");this.playBarDisplay_=ax(aA,".APV1_play_bar");this.durationTextDisplay_=ax(aA,".APV1_duration_text");this.volumeButton_=ax(aA,".APV1_volume_button");this.volumeContainerDisplay_=ax(aA,".APV1_volume_bar_container");this.volumeBarDisplay_=ax(aA,".APV1_volume_bar");ac(aA,this.playerWidth_);j(aA,this.playerHeight_);this.bindControllerEvents_();this.checkAttributes_();W(aB,aA);var aD={};aD[ah.HEIGHT]=o.ZERO;aD[ah.WIDTH]=o.ZERO;O(aB,aD);T(aB,ah.CONTROLS);if(!this.checkForAvailability_()){return}this.setContainerWidth_();this.bindAudioEvents_();if(this.ready){this.readyHandler_()}U[this.identifier_]=this}X(G,J);G.prototype.destroy=function(){this.unbindAudioEvents_();this.unbindControllerEvents_();this.unbindVolumeEvents_();this.unbindStartingEvents_();this.unbindPlayEvents_();z(this.controlsDisplay_);U.splice(this.identifier_,1);G.superClass_.destroy.call(this)};G.prototype.bindControllerEvents_=function(){an(this.controlsDisplay_,c.MOUSE_DOWN,false);an(this.controlsDisplay_,c.CONTEXT_MENU,false)};G.prototype.unbindControllerEvents_=function(){x(this.controlsDisplay_,c.MOUSE_DOWN);x(this.controlsDisplay_,c.CONTEXT_MENU)};G.prototype.bindPlayEvents_=function(){an(this.progressWrapperDisplay_,c.MOUSE_DOWN,p(this.onSeekDownHandler_,this));an(this.playButton_,c.CLICK,p(this.toggleAudio_,this))};G.prototype.unbindPlayEvents_=function(){x(this.progressWrapperDisplay_,c.MOUSE_DOWN,this.onSeekDownHandler_);x(this.playButton_,c.CLICK,this.toggleAudio_)};G.prototype.bindStartingEvents_=function(){if(V){console.log("bindStartingEvents_")}an(this.playButton_,c.CLICK,p(this.startAudio_,this))};G.prototype.unbindStartingEvents_=function(){if(V){console.log("unbindStartingEvents_")}x(this.playButton_,c.CLICK,this.startAudio_)};G.prototype.bindVolumeEvents_=function(){an(this.volumeContainerDisplay_,c.MOUSE_DOWN,p(this.onVolumeDownHandler_,this));an(this.volumeButton_,c.CLICK,p(this.toggleVolume_,this))};G.prototype.unbindVolumeEvents_=function(){x(this.volumeContainerDisplay_,c.MOUSE_DOWN,this.onVolumeDownHandler_);x(this.volumeButton_,c.CLICK,this.toggleVolume_)};G.prototype.bindAudioEvents_=function(){this.addEventListener(N.READY,this.readyHandler_);this.addEventListener(N.PROGRESS,this.progressHandler_);this.addEventListener(N.TIME_UPDATE,this.timeupdateHandler_);this.addEventListener(N.CAN_PLAY,this.canplayHandler_);this.addEventListener(N.DURATION_CHANGE,this.durationchangeHandler_);this.addEventListener(N.PLAYING,this.playHandler_);this.addEventListener(N.PLAY,this.playHandler_);this.addEventListener(N.PAUSE,this.pauseHandler_);this.addEventListener(N.ENDED,this.endedHandler_);this.addEventListener(N.ERROR,this.errorHandler_);this.addEventListener(N.VOLUME_CHANGE,this.volumechangeHandler_)};G.prototype.unbindAudioEvents_=function(){this.removeEventListener(N.READY,this.readyHandler_);this.removeEventListener(N.TIME_UPDATE,this.timeupdateHandler_);this.removeEventListener(N.CAN_PLAY,this.canplayHandler_);this.removeEventListener(N.DURATION_CHANGE,this.durationchangeHandler_);this.removeEventListener(N.PLAYING,this.playHandler_);this.removeEventListener(N.PLAY,this.playHandler_);this.removeEventListener(N.PAUSE,this.pauseHandler_);this.removeEventListener(N.ENDED,this.endedHandler_);this.removeEventListener(N.ERROR,this.errorHandler_);this.removeEventListener(N.VOLUME_CHANGE,this.volumechangeHandler_)};G.prototype.readyHandler_=function(){var aA=D(this.object_,ah.DATA_VOLUME);var az=((aA?(al(aA,100)/100):null)||y()||(ad.fn[u]["defaultOptions"][ah.DATA_VOLUME]/100));if(Q(az)){this.setVolume(az)}else{az=this.volume()}this.setVolumeView_(az);this.bindStartingEvents_();this.bindVolumeEvents_()};G.prototype.checkAttributes_=function(){if(!this.hasBooleanAttribute_(ah.DATA_CONTROLS_TIME)){D(this.timeTextDisplay_,o.STYLE,o.DISPLAY_NONE);var az=ax(this.controlsDisplay_,".APV1_for_time");D(az,o.STYLE,o.DISPLAY_NONE)}if(!this.hasBooleanAttribute_(ah.DATA_CONTROLS_DURATION)){D(this.durationTextDisplay_,o.STYLE,o.DISPLAY_NONE);var az=ax(this.controlsDisplay_,".APV1_for_duration");D(az,o.STYLE,o.DISPLAY_NONE)}if(!this.hasBooleanAttribute_(ah.DATA_CONTROLS_VOLUME)){D(this.volumeButton_,o.STYLE,o.DISPLAY_NONE);D(this.volumeContainerDisplay_,o.STYLE,o.DISPLAY_NONE);var az=ax(this.controlsDisplay_,".APV1_for_volume");D(az,o.STYLE,o.DISPLAY_NONE)}};G.prototype.hasBooleanAttribute_=function(az){var aA=D(this.object_,az);if(aA){if(aA=="false"||aA=="off"||aA=="no"){return false}else{if(aA=="true"||aA=="on"||aA=="yes"){return true}}}return ad[k][u]["defaultOptions"][az]};G.prototype.setContainerWidth_=function(){var aA=0;var az=ax(this.controlsDisplay_,"li:not(.APV1_container)");aw(az,function(){aA+=ac(ad(this))});if(aA>this.playerWidth_){L.load(p(this.setContainerWidth_,this));return}ac(this.containerDisplay_,this.playerWidth_-aA)};G.prototype.checkForAvailability_=function(){if(!this.available){this.reportError_("Audio file not found.");return}return true};G.prototype.canplayHandler_=function(){if(V){console.log("canplayHandler_")}this.unbindStartingEvents_();this.bindPlayEvents_()};G.prototype.startAudio_=function(){if(V){console.log("startAudio_")}if(!this.flashMode_){this.setPreload("auto")}this.play();this.unbindStartingEvents_()};G.prototype.toggleAudio_=function(){if(this.paused()||this.ended()){this.play();ao(this.controlsDisplay_,au.PLAYING)}else{this.pause();ar(this.controlsDisplay_,au.PLAYING)}};G.prototype.toggleVolume_=function(){if(this.volume()){this.setVolume(0)}else{this.setVolume(1)}};G.prototype.onVolumeDownHandler_=function(az){if(az.which!=1){return}az.preventDefault();az.stopPropagation();if(!aq()){this.isSeekingVolume_=true}this.offset_=Y(this.volumeContainerDisplay_);var aA=(az.pageX-this.offset_)/ac(this.volumeContainerDisplay_);this.setVolume(aA);this.setVolumeView_(aA);an(L,c.MOUSE_MOVE,p(this.onVolumeMoveHandler_,this));an(L,c.MOUSE_UP,p(this.onVolumeUpHandler_,this));return false};G.prototype.onVolumeUpHandler_=function(){this.isSeekingVolume_=false;s(this.volume());x(L,c.MOUSE_MOVE,this.onVolumeMoveHandler_);x(L,c.MOUSE_UP,this.onVolumeUpHandler_)};G.prototype.onVolumeMoveHandler_=function(az){var aA=al((az.pageX-this.offset_)/ac(this.volumeContainerDisplay_));this.setVolume(aA);this.setVolumeView_(aA)};G.prototype.setVolumeView_=function(az){ac(this.volumeBarDisplay_,az*100+"%");if(az){if(this.isMuted_){this.isMuted_=false;ar(this.controlsDisplay_,au.MUTE)}}else{if(!this.isMuted_){this.isMuted_=true;ao(this.controlsDisplay_,au.MUTE)}}};G.prototype.onSeekDownHandler_=function(aB){if(aB.which!=1){return}this.offset_=Y(this.seekBarDisplay_);var aC=al((aB.pageX-this.offset_)/ac(this.progressContainerDisplay_));var aA=this.duration();var az=aA*aC;this.time_=az;ar(this.playBarDisplay_,au.TRANSITION);ac(this.playBarDisplay_,aC*100+"%");Z(this.timeTextDisplay_,m(az,aA));an(L,c.MOUSE_MOVE,p(this.onSeekMoveHandler_,this));an(L,c.MOUSE_UP,p(this.onSeekUpHandler_,this));if(!aq()){this.isSeekingTimeline_=true;this.pause()}else{this.setCurrentTime(az);this.play()}return false};G.prototype.onSeekUpHandler_=function(){ao(this.playBarDisplay_,au.TRANSITION);x(L,c.MOUSE_MOVE,this.onSeekMoveHandler_);x(L,c.MOUSE_UP,this.onSeekUpHandler_);this.setCurrentTime(this.time_);this.isSeekingTimeline_=false;this.play()};G.prototype.onSeekMoveHandler_=function(aB){var aC=al((aB.pageX-this.offset_)/ac(this.progressContainerDisplay_));var aA=this.duration();var az=aA*aC;this.time_=az;ac(this.playBarDisplay_,aC*100+"%");Z(this.timeTextDisplay_,m(az,aA))};G.prototype.timeupdateHandler_=function(){var az=this;if(az.isSeekingTimeline_){return}var aB=az.duration();var aA=az.currentTime();var aC=al(aA/aB);ae(function(){ac(az.playBarDisplay_,aC*100+"%");Z(az.timeTextDisplay_,m(aA,aB))},"1")};G.prototype.progressHandler_=function(){var az=this;ae(function(){ac(az.seekBarDisplay_,az.progress()+"%")},"2")};G.prototype.volumechangeHandler_=function(){if(!this.isSeekingVolume_){var az=av(this.volume());s(az);this.setVolumeView_(az)}};G.prototype.durationchangeHandler_=function(){Z(this.durationTextDisplay_,m(this.duration()));if(this.duration()/3600>=1){Z(this.timeTextDisplay_,m(this.currentTime(),this.duration()));this.setContainerWidth_()}};G.prototype.playHandler_=function(){if(!this.isSeekingTimeline_){C(this);ao(this.controlsDisplay_,au.PLAYING)}};G.prototype.pauseHandler_=function(){if(!this.isSeekingTimeline_){ar(this.controlsDisplay_,au.PLAYING)}};G.prototype.endedHandler_=function(){if(!this.isSeekingTimeline_){ar(this.controlsDisplay_,au.PLAYING);if(this.loop()){this.setCurrentTime(0);this.play()}}};G.prototype.errorHandler_=function(){this.reportError_("An error occurred.")};G.prototype.reportError_=function(az){if(V){console.log("error: "+az)}this.unbindAudioEvents_();this.unbindControllerEvents_();this.unbindVolumeEvents_();this.unbindStartingEvents_();this.unbindPlayEvents_();D(this.timeTextDisplay_,o.STYLE,o.DISPLAY_BLOCK);Z(this.timeTextDisplay_,az);ao(this.controlsDisplay_,au.ERROR)};ad(function(){ad("."+u)[u]()});ad.widget("ui."+u,{widgetEventPrefix:"audioplayer.",_create:function(){var az=this;var aC=az.element;var aB=aC[0];var aA=ad(aB);if(t(aA,"audio")){aC.player_=new G(aA,aB);aC.dispatcher_=function(aD){az._trigger(aD)};aC.player_.addEventListener(N.STARTED,aC.dispatcher_);aC.player_.addEventListener(N.ENDED,aC.dispatcher_);aC.player_.addEventListener(N.READY,aC.dispatcher_)}},destroy:function(){var az=this["element"];az.player_.removeEventListener(N.STARTED,az.dispatcher_);az.player_.removeEventListener(N.ENDED,az.dispatcher_);az.player_.removeEventListener(N.READY,az.dispatcher_);delete az.dispatcher_;az.dispatcher_=null;az.player_.destroy();delete az.player_;az.player_=null},play:function(az){var aA=this["element"];aA.player_.play(az)},pause:function(){var az=this["element"];az.player_.pause()},volume:function(aB){var aA=this["element"];if(aB){var az=parseInt(aB,10)/100;aA.player_.setVolume(az)}else{return aA.player_.volume()}}});var S={};S[ah.WIDTH]=300;S[ah.HEIGHT]=29;S[ah.DATA_CONTROLS_TIME]=true;S[ah.DATA_CONTROLS_VOLUME]=true;S[ah.DATA_CONTROLS_DURATION]=true;S[ah.DATA_VOLUME]=100;S[ah.DATA_FALLBACK]="AudioPlayerV1.swf";ad[k][u]["defaultOptions"]=S;var ab={};ab[N.READY]=function(az){setTimeout(function(){if(V){console.log(az," ready")}var aA=I[az];aA.swf_=ai(az);aA.readyHandler__.call(aA)},1)};ab[N.TIME_UPDATE]=function(aB,aA){var az=I[aB];az.currentTime_=aA;az.timeupdateHandler__()};ab[N.PROGRESS]=function(aB,az){var aA=I[aB];aA.progress_=az;aA.progressHandler__()};ab[N.CAN_PLAY]=function(az){I[az].canplayHandler__()};ab[N.PLAYING]=function(az){I[az].playingHandler__()};ab[N.STARTED]=function(az){I[az].startingHandler__()};ab[N.PLAY]=function(az){I[az].playHandler__()};ab[N.PAUSE]=function(az){I[az].pauseHandler__()};ab[N.ENDED]=function(az){I[az].endedHandler__()};ab[N.VOLUME_CHANGE]=function(az){I[az].volumechangeHandler__()};ab[N.DURATION_CHANGE]=function(aB,aA){var az=I[aB];az.duration_=aA;az.durationchangeHandler__()};ab[N.ERROR]=function(aA,az){if(V){console.log("ERROR:",aA,az)}I[aA].errorHandler__()};if(V){ab.log=function(aA,az){console.log("FLASH:",aA,az)}}ad[k][u][F]=ab})(jQuery);