audio jss

(function(b,e,a){var d=(function(){var k=new RegExp("audio(.min)?.js.*"),g=document.getElementsByTagName("script");for(var h=0,j=g.length;h',settings:{autoplay:false,loop:false,preload:true,imageLocation:d+"audio.gif",retinaImageLocation:d+"audio.gif",swfLocation:d+"audio.swf",useFlash:(function(){var f=document.createElement("audio");return !(f.canPlayType&&f.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 h=navigator.mimeTypes["application/x-shockwave-flash"];return h&&h.enabledPlugin}else{try{var f=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");return true}catch(g){}}}return false})(),createPlayer:{markup:'

00:00-00: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"},css:'.elahmad_play audio{position:absolute;left:-1px}.elahmad_play{width:100%;height:36px;background:#404040;overflow:hidden;background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0,#444),color-stop(0.5,#555),color-stop(0.51,#444),color-stop(1,#444));background-image:-moz-linear-gradient(center top,#444 0,#555 50%,#444 51%,#444 100%);-webkit-box-shadow:1px 1px 8px rgba(0,0,0,0.3);-moz-box-shadow:1px 1px 8px rgba(0,0,0,0.3);-o-box-shadow:1px 1px 8px rgba(0,0,0,0.3);box-shadow:1px 1px 8px rgba(0,0,0,0.3)}.elahmad_play .play_pause{width:25px;height:40px;padding:4px 6px;margin:0 5px 0 0;float:left;overflow:hidden;border-right:1px solid #000}.elahmad_play p{display:none;width:25px;height:40px;margin:0;cursor:pointer}.elahmad_play .play{display:block}.elahmad_play .scrubber{cursor:pointer;position:relative;background:#5a5a5a;height:14px;margin:10px;border-top:1px solid #3f3f3f;border-left:0;border-bottom:0;overflow:hidden}.elahmad_play .progress{position:absolute;top:0;left:0;height:14px;width:0;background:#FC7404;z-index:1;background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0,#FC7404),color-stop(0.5,#ddd),color-stop(0.51,#ccc),color-stop(1,#FC7404));background-image:-moz-linear-gradient(center top,#ccc 0,#ddd 50%,#ccc 51%,#ccc 100%)}.elahmad_play .loaded{position:absolute;top:0;left:0;height:14px;width:0;background:#000;background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0,#222),color-stop(0.5,#333),color-stop(0.51,#222),color-stop(1,#222));background-image:-moz-linear-gradient(center top,#222 0,#333 50%,#222 51%,#222 100%)}.elahmad_play .time{float:right;height:36px;line-height:36px;margin:0 0 0 6px;padding:0 4px 0 4px;border-left:1px solid #000;color:#FFFF00;text-shadow:1px 1px 0 rgba(0,0,0,0.5)}.elahmad_play .time SPAN{font-weight:bold;padding: 5px 2px}.elahmad_play .error-message{float:left;display:none;margin:0 10px;height:36px;width:400px;overflow:hidden;line-height:36px;white-space:nowrap;color:#fff;text-overflow:ellipsis;-o-text-overflow:ellipsis;-icab-text-overflow:ellipsis;-khtml-text-overflow:ellipsis;-moz-text-overflow:ellipsis;-webkit-text-overflow:ellipsis}.elahmad_play .error-message a{color:#eee;text-decoration:none;padding-bottom:1px;border-bottom:1px solid #999;white-space:wrap}.elahmad_play .play{background:url("$1") -2px -1px no-repeat}.elahmad_play .loading{background:url("$1") -2px -31px no-repeat}.elahmad_play .error{background:url("$1") -2px -61px no-repeat}.elahmad_play .pause{background:url("$1") -2px -91px no-repeat}.playing .play,.playing .loading,.playing .error{display:none}.playing .pause{display:block}.loading .play,.loading .pause,.loading .error{display:none}.loading .loading{display:block}.error .time,.error .play,.error .pause,.error .scrubber,.error .loading{display:none}.error .error{display:block}.error .play_pause p{cursor:auto}.error .error-message{display:block}',trackEnded:function(f){},flashError:function(){var h=this.settings.createPlayer,f=c(h.errorMessageClass,this.wrapper),g='Missing flash player plugin.';if(this.mp3){g+=' Download audio file.'}a[b].helpers.removeClass(this.wrapper,h.loadingClass);a[b].helpers.addClass(this.wrapper,h.errorClass);f.innerHTML=g},loadError:function(h){var g=this.settings.createPlayer,f=c(g.errorMessageClass,this.wrapper);a[b].helpers.removeClass(this.wrapper,g.loadingClass);a[b].helpers.addClass(this.wrapper,g.errorClass);f.innerHTML='Error loading: "'+this.mp3+'"'},init:function(){var f=this.settings.createPlayer;a[b].helpers.addClass(this.wrapper,f.loadingClass)},loadStarted:function(){var g=this.settings.createPlayer,i=c(g.durationClass,this.wrapper),f=Math.floor(this.duration/60),h=Math.floor(this.duration%60);a[b].helpers.removeClass(this.wrapper,g.loadingClass);i.innerHTML=((f<10?"0":"")+f+":"+(h<10?"0":"")+h)},loadProgress:function(h){var g=this.settings.createPlayer,f=c(g.loaderClass,this.wrapper);f.style.width=Math.round(100*h)+"%"},playPause:function(){if(this.playing){this.settings.play()}else{this.settings.pause()}},play:function(){var f=this.settings.createPlayer;a[b].helpers.removeClass(this.wrapper,f.errorClass);a[b].helpers.addClass(this.wrapper,f.playingClass)},pause:function(){var f=this.settings.createPlayer;a[b].helpers.removeClass(this.wrapper,f.playingClass)},updatePlayhead:function(j){var h=this.settings.createPlayer,g=c(h.progressClass,this.wrapper);g.style.width=Math.round(100*j)+"%";var k=c(h.playedClass,this.wrapper),l=this.duration*j,f=Math.floor(l/60),i=Math.floor(l%60);k.innerHTML=((f<10?"0":"")+f+":"+(i<10?"0":"")+i)}},create:function(g,f){var f=f||{};if(g.length){return this.createAll(f,g)}else{return this.newInstance(g,f)}},createAll:function(g,k){var f=k||document.getElementsByTagName("audio"),l=[];g=g||{};for(var h=0,j=f.length;h-1){continue}l.push(this.newInstance(f[h],g))}return l},newInstance:function(g,f){var g=g,h=this.helpers.clone(this.settings),l="elahmad_play"+this.instanceCount,k="elahmad_play_wrapper"+this.instanceCount,j=this.instanceCount++;if(g.getAttribute("autoplay")!=null){h.autoplay=true}if(g.getAttribute("loop")!=null){h.loop=true}if(g.getAttribute("preload")=="none"){h.preload=false}if(f){this.helpers.merge(h,f)}if(h.createPlayer.markup){g=this.createPlayer(g,h.createPlayer,k)}else{g.parentNode.setAttribute("id",k)}var i=new a[e](g,h);if(h.css){this.helpers.injectCss(i,h.css)}if(h.useFlash&&h.hasFlash){this.injectFlash(i,l);this.attachFlashEvents(i.wrapper,i)}else{if(h.useFlash&&!h.hasFlash){h.flashError.apply(i)}}if(!h.useFlash||(h.useFlash&&h.hasFlash)){this.attachEvents(i.wrapper,i)}this.instances[l]=i;return i},createPlayer:function(g,f,j){var i=document.createElement("div"),h=g.cloneNode(true);i.setAttribute("class","elahmad_play");i.setAttribute("className","elahmad_play");i.setAttribute("id",j);if(h.outerHTML&&!document.createElement("audio").canPlayType){h=this.helpers.cloneHtml5Node(g);i.innerHTML=f.markup;i.appendChild(h);g.outerHTML=i.outerHTML;i=document.getElementById(j)}else{i.appendChild(h);i.innerHTML=i.innerHTML+f.markup;g.parentNode.replaceChild(i,g)}return i.getElementsByTagName("audio")[0]},attachEvents:function(k,h){if(!h.settings.createPlayer){return}var g=h.settings.createPlayer,j=c(g.playPauseClass,k),i=c(g.scrubberClass,k),f=function(l){var m=0;if(l.offsetParent){do{m+=l.offsetLeft}while(l=l.offsetParent)}return m};a[b].events.addListener(j,"click",function(l){h.playPause.apply(h)});a[b].events.addListener(i,"click",function(m){var l=m.clientX-f(this);h.skipTo(l/i.offsetWidth)});if(h.settings.useFlash){return}a[b].events.trackLoadProgress(h);a[b].events.addListener(h.element,"timeupdate",function(l){h.updatePlayhead.apply(h)});a[b].events.addListener(h.element,"ended",function(l){h.trackEnded.apply(h)});a[b].events.addListener(h.source,"error",function(l){clearInterval(h.readyTimer);clearInterval(h.loadTimer);h.settings.loadError.apply(h)})},attachFlashEvents:function(f,g){g.swfReady=false;g.load=function(h){g.mp3=h;if(g.swfReady){g.element.load(h)}};g.loadProgress=function(h,i){g.loadedPercent=h;g.duration=i;g.settings.loadStarted.apply(g);g.settings.loadProgress.apply(g,[h])};g.skipTo=function(h){if(h>g.loadedPercent){return}g.updatePlayhead.call(g,[h]);g.element.skipTo(h)};g.updatePlayhead=function(h){g.settings.updatePlayhead.apply(g,[h])};g.play=function(){if(!g.settings.preload){g.settings.preload=true;g.element.init(g.mp3)}g.playing=true;g.element.pplay();g.settings.play.apply(g)};g.pause=function(){g.playing=false;g.element.ppause();g.settings.pause.apply(g)};g.setVolume=function(h){g.element.setVolume(h)};g.loadStarted=function(){g.swfReady=true;if(g.settings.preload){g.element.init(g.mp3)}if(g.settings.autoplay){g.play.apply(g)}}},injectFlash:function(h,j){var f=this.flashSource.replace(/\$1/g,j);f=f.replace(/\$2/g,h.settings.swfLocation);f=f.replace(/\$3/g,(+new Date+Math.random()));var g=h.wrapper.innerHTML,i=document.createElement("div");i.innerHTML=f+g;h.wrapper.innerHTML=i.innerHTML;h.element=this.helpers.getSwf(j)},helpers:{merge:function(g,f){for(attr in f){if(g.hasOwnProperty(attr)||f.hasOwnProperty(attr)){g[attr]=f[attr]}}},clone:function(h){if(h==null||typeof(h)!=="object"){return h}var f=new h.constructor();for(var g in h){f[g]=arguments.callee(h[g])}return f},addClass:function(f,h){var g=new RegExp("(\\s|^)"+h+"(\\s|$)");if(g.test(f.className)){return}f.className+=" "+h},removeClass:function(f,h){var g=new RegExp("(\\s|^)"+h+"(\\s|$)");f.className=f.className.replace(g," ")},injectCss:function(g,k){var q="",p=document.getElementsByTagName("style"),j=k.replace(/\$1/g,g.settings.imageLocation);j=j.replace(/\$2/g,g.settings.retinaImageLocation);for(var h=0,o=p.length;h1?g[g.length-1]:g}},events:{memoryLeaking:false,listeners:[],addListener:function(g,f,h){if(g.addEventListener){g.addEventListener(f,h,false)}else{if(g.attachEvent){this.listeners.push(g);if(!this.memoryLeaking){window.attachEvent("onunload",function(){if(this.listeners){for(var j=0,k=this.listeners.length;j-1){if(!g){h.init.apply(h)}}if(h.element.readyState>1){if(h.settings.autoplay){h.play.apply(h)}clearInterval(f);i=setInterval(function(){h.loadProgress.apply(h);if(h.loadedPercent>=1){clearInterval(i)}},200)}},200);h.readyTimer=f;h.loadTimer=i},purge:function(h){var f=h.attributes,g;if(f){for(g=0;gthis.loadedPercent){return}this.element.currentTime=this.duration*f;this.updatePlayhead()},load:function(f){this.loadStartedCalled=false;this.source.setAttribute("src",f);this.element.load();this.mp3=f;a[b].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 f=this.element.buffered.end(this.element.buffered.length-1);this.loadedPercent=f/this.duration;this.settings.loadProgress.apply(this,[this.loadedPercent])}},playPause:function(){if(this.playing){this.pause()}else{this.play()}},play:function(){var f=(/(ipod|iphone|ipad)/i).test(navigator.userAgent);if(f&&this.element.readyState==0){this.init.apply(this)}if(!this.settings.preload){this.settings.preload=true;this.element.setAttribute("preload","auto");a[b].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(f){this.element.volume=f},trackEnded:function(f){this.skipTo.apply(this,[0]);if(!this.settings.loop){this.pause.apply(this)}this.settings.trackEnded.apply(this)}};var c=function(n,j){var m=[];j=j||document;if(j.getElementsByClassName){m=j.getElementsByClassName(n)}else{var h,f,g=j.getElementsByTagName("*"),k=new RegExp("(^|\\s)"+n+"(\\s|$)");for(h=0,f=g.length;h1?m:m[0]}})("elahmad_play","e",this); $(function(){var b=elahmad_play.createAll({trackEnded:function(){var a=$("ul li.playing").next();$("html, body").animate({scrollTop:$("ul li.playing").offset().top-30},"slow");if(!a.length){jQuery("html, body").animate({scrollTop:54},"slow");a=$("ul li").first()}a.addClass("playing").siblings().removeClass("playing");c.load($("a",a).attr("href"));c.play()}});var c=b[0];first=$("ul a").attr("href");$("ul li").first().addClass("playing");c.load(first);$("ul li").click(function(a){a.preventDefault();$(this).addClass("playing").siblings().removeClass("playing");$("html, body").animate({scrollTop:$("ul li.playing").offset().top-70},"slow");c.load($("a",this).attr("href"));c.play()});$(document).keydown(function(g){var a=g.charCode?g.charCode:g.keyCode;if(a==39){var d=$("li.playing").next();if(!d.length){d=$("ul li").first()}d.click()}else{if(a==37){var f=$("li.playing").prev();if(!f.length){f=$("ul li").last()}f.click()}else{if(a==32){c.playPause()}}}})});