diff --git a/Manifest b/Manifest index 0e36b43..8515541 100644 --- a/Manifest +++ b/Manifest @@ -1,5 +1,6 @@ audiojs/audio.min.js audiojs/audiojs.swf audiojs/player-graphics.gif +audiojs/player-graphics@2x.gif includes/index.css index.html \ No newline at end of file diff --git a/audiojs/audio.js b/audiojs/audio.js index 51f7d2a..ff246a4 100644 --- a/audiojs/audio.js +++ b/audiojs/audio.js @@ -188,6 +188,10 @@ var player = this.settings.createPlayer; container[audiojs].helpers.removeClass(this.wrapper, player.errorClass); container[audiojs].helpers.addClass(this.wrapper, player.playingClass); + this.settings.onAfterPlay(); + }, + onAfterPlay: function() { + // to be overridden }, pause: function() { var player = this.settings.createPlayer; @@ -229,10 +233,10 @@ instances = [] options = options || {}; for (var i = 0, ii = audioElements.length; i < ii; i++) { - + if ((" " + audioElements[i].parentNode.className + " ").replace(/[\n\t]/g, " ").indexOf(" audiojs ") > -1) continue; - + instances.push(this.newInstance(audioElements[i], options)); } return instances; @@ -628,12 +632,15 @@ this.element.currentTime = this.duration * percent; this.updatePlayhead(); }, - load: function(mp3) { + load: function(mp3, trackid) { + // trackid not required, default: "" + trackid = typeof trackid !== 'undefined' ? trackid : ""; this.loadStartedCalled = false; this.source.setAttribute('src', mp3); // The now outdated `load()` method is required for Safari 4 this.element.load(); this.mp3 = mp3; + this.trackid = trackid; container[audiojs].events.trackLoadProgress(this); }, loadError: function() { diff --git a/audiojs/audio.min.js b/audiojs/audio.min.js index 8b29666..7a45b44 100644 --- a/audiojs/audio.min.js +++ b/audiojs/audio.min.js @@ -1,24 +1 @@ -(function(f,k,g){var n=function(){for(var a=/audio(.min)?.js.*/,b=document.getElementsByTagName("script"),c=0,d=b.length;c ',settings:{autoplay:!1,loop:!1,preload:!0,imageLocation:n+"player-graphics.gif",retinaImageLocation:n+"player-graphics@2x.gif",swfLocation:n+"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!0;if(navigator.mimeTypes&& -navigator.mimeTypes.length){var a=navigator.mimeTypes["application/x-shockwave-flash"];return a&&a.enabledPlugin}try{return new ActiveXObject("ShockwaveFlash.ShockwaveFlash"),!0}catch(b){}return!1}(),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:' .audiojs audio { position: absolute; left: -1px; } .audiojs { width: 460px; height: 36px; background: #404040; overflow: hidden; font-family: monospace; font-size: 12px; 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); } .audiojs .play-pause { width: 25px; height: 40px; padding: 4px 6px; margin: 0px; float: left; overflow: hidden; border-right: 1px solid #000; } .audiojs p { display: none; width: 25px; height: 40px; margin: 0px; cursor: pointer; } .audiojs .play { display: block; } .audiojs .scrubber { position: relative; float: left; width: 280px; background: #5a5a5a; height: 14px; margin: 10px; border-top: 1px solid #3f3f3f; border-left: 0px; border-bottom: 0px; overflow: hidden; } .audiojs .progress { position: absolute; top: 0px; left: 0px; height: 14px; width: 0px; background: #ccc; z-index: 1; background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #ccc), color-stop(0.5, #ddd), color-stop(0.51, #ccc), color-stop(1, #ccc)); background-image: -moz-linear-gradient(center top, #ccc 0%, #ddd 50%, #ccc 51%, #ccc 100%); } .audiojs .loaded { position: absolute; top: 0px; left: 0px; height: 14px; width: 0px; 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%); } .audiojs .time { float: left; height: 36px; line-height: 36px; margin: 0px 0px 0px 6px; padding: 0px 6px 0px 12px; border-left: 1px solid #000; color: #ddd; text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.5); } .audiojs .time em { padding: 0px 2px 0px 0px; color: #f9f9f9; font-style: normal; } .audiojs .time strong { padding: 0px 0px 0px 2px; font-weight: normal; } .audiojs .error-message { float: left; display: none; margin: 0px 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; } .audiojs .error-message a { color: #eee; text-decoration: none; padding-bottom: 1px; border-bottom: 1px solid #999; white-space: wrap; } .audiojs .play { background: url("$1") -2px -1px no-repeat; } .audiojs .loading { background: url("$1") -2px -31px no-repeat; } .audiojs .error { background: url("$1") -2px -61px no-repeat; } .audiojs .pause { background: url("$1") -2px -91px no-repeat; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min--moz-device-pixel-ratio: 2), only screen and (min-moz-device-pixel-ratio: 2), only screen and (-o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2) { .audiojs .play, .audiojs .loading, .audiojs .error, .audiojs .pause { background-image: url("$2"); -webkit-background-size: 30px 120px; -moz-background-size: 30px 120px; -o-background-size: 30px 120px; background-size: 30px 120px; } } .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(a){},flashError:function(){var a=this.settings.createPlayer,b=h(a.errorMessageClass,this.wrapper),c='Missing flash player plugin.';this.mp3&&(c+=' Download audio file.');g[f].helpers.removeClass(this.wrapper,a.loadingClass);g[f].helpers.addClass(this.wrapper,a.errorClass);b.innerHTML=c},loadError:function(a){a=this.settings.createPlayer;var b=h(a.errorMessageClass,this.wrapper);g[f].helpers.removeClass(this.wrapper, -a.loadingClass);g[f].helpers.addClass(this.wrapper,a.errorClass);b.innerHTML='Error loading: "'+this.mp3+'"'},init:function(){g[f].helpers.addClass(this.wrapper,this.settings.createPlayer.loadingClass)},loadStarted:function(){var a=this.settings.createPlayer,b=h(a.durationClass,this.wrapper),c=Math.floor(this.duration/60),d=Math.floor(this.duration%60);g[f].helpers.removeClass(this.wrapper,a.loadingClass);b.innerHTML=(10>c?"0":"")+c+":"+(10>d?"0":"")+d},loadProgress:function(a){h(this.settings.createPlayer.loaderClass, -this.wrapper).style.width=Math.round(100*a)+"%"},playPause:function(){this.playing?this.settings.play():this.settings.pause()},play:function(){var a=this.settings.createPlayer;g[f].helpers.removeClass(this.wrapper,a.errorClass);g[f].helpers.addClass(this.wrapper,a.playingClass)},pause:function(){g[f].helpers.removeClass(this.wrapper,this.settings.createPlayer.playingClass)},updatePlayhead:function(a){var b=this.settings.createPlayer;h(b.progressClass,this.wrapper).style.width=Math.round(100*a)+"%"; -var b=h(b.playedClass,this.wrapper),c=this.duration*a;a=Math.floor(c/60);c=Math.floor(c%60);b.innerHTML=(10>a?"0":"")+a+":"+(10>c?"0":"")+c}},create:function(a,b){b=b||{};return a.length?this.createAll(b,a):this.newInstance(a,b)},createAll:function(a,b){var c=b||document.getElementsByTagName("audio"),d=[];a=a||{};for(var e=0,p=c.length;eb.loadedPercent||(b.updatePlayhead.call(b,[a]),b.element.skipTo(a))};b.updatePlayhead=function(a){b.settings.updatePlayhead.apply(b,[a])};b.play=function(){b.settings.preload||(b.settings.preload=!0,b.element.init(b.mp3));b.playing=!0;b.element.pplay();b.settings.play.apply(b)};b.pause=function(){b.playing=!1;b.element.ppause();b.settings.pause.apply(b)};b.setVolume=function(a){b.element.setVolume(a)};b.loadStarted=function(){b.swfReady=!0;b.settings.preload&&b.element.init(b.mp3); -b.settings.autoplay&&b.play.apply(b)}},injectFlash:function(a,b){var c=this.flashSource.replace(/\$1/g,b),c=c.replace(/\$2/g,a.settings.swfLocation),c=c.replace(/\$3/g,+new Date+Math.random()),d=a.wrapper.innerHTML,e=document.createElement("div");e.innerHTML=c+d;a.wrapper.innerHTML=e.innerHTML;a.element=this.helpers.getSwf(b)},helpers:{merge:function(a,b){for(attr in b)if(a.hasOwnProperty(attr)||b.hasOwnProperty(attr))a[attr]=b[attr]},clone:function(a){if(null==a||"object"!==typeof a)return a;var b= -new a.constructor,c;for(c in a)b[c]=arguments.callee(a[c]);return b},addClass:function(a,b){(new RegExp("(\\s|^)"+b+"(\\s|$)")).test(a.className)||(a.className+=" "+b)},removeClass:function(a,b){a.className=a.className.replace(new RegExp("(\\s|^)"+b+"(\\s|$)")," ")},injectCss:function(a,b){for(var c="",d=document.getElementsByTagName("style"),e=b.replace(/\$1/g,a.settings.imageLocation),e=e.replace(/\$2/g,a.settings.retinaImageLocation),g=0,f=d.length;gthis.loadedPercent||(this.element.currentTime=this.duration*a,this.updatePlayhead())},load:function(a){this.loadStartedCalled=!1;this.source.setAttribute("src",a);this.element.load();this.mp3=a;g[f].events.trackLoadProgress(this)},loadError:function(){this.settings.loadError.apply(this)},init:function(){this.settings.init.apply(this)}, -loadStarted:function(){if(!this.element.duration)return!1;this.duration=this.element.duration;this.updatePlayhead();this.settings.loadStarted.apply(this)},loadProgress:function(){null!=this.element.buffered&&this.element.buffered.length&&(this.loadStartedCalled||(this.loadStartedCalled=this.loadStarted()),this.loadedPercent=this.element.buffered.end(this.element.buffered.length-1)/this.duration,this.settings.loadProgress.apply(this,[this.loadedPercent]))},playPause:function(){this.playing?this.pause(): -this.play()},play:function(){/(ipod|iphone|ipad)/i.test(navigator.userAgent)&&0==this.element.readyState&&this.init.apply(this);this.settings.preload||(this.settings.preload=!0,this.element.setAttribute("preload","auto"),g[f].events.trackLoadProgress(this));this.playing=!0;this.element.play();this.settings.play.apply(this)},pause:function(){this.playing=!1;this.element.pause();this.settings.pause.apply(this)},setVolume:function(a){this.element.volume=a},trackEnded:function(a){this.skipTo.apply(this, -[0]);this.settings.loop||this.pause.apply(this);this.settings.trackEnded.apply(this)}};var h=function(a,b){var c=[];b=b||document;if(b.getElementsByClassName)c=b.getElementsByClassName(a);else{var d,e,f=b.getElementsByTagName("*"),g=new RegExp("(^|\\s)"+a+"(\\s|$)");d=0;for(e=f.length;d ',settings:{autoplay:!1,loop:!1,preload:!0,imageLocation:d+"player-graphics.gif",retinaImageLocation:d+"player-graphics@2x.gif",swfLocation:d+"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!0;if(navigator.mimeTypes&&navigator.mimeTypes.length){var a=navigator.mimeTypes["application/x-shockwave-flash"];return a&&a.enabledPlugin}try{new ActiveXObject("ShockwaveFlash.ShockwaveFlash");return!0}catch(a){}return!1}(),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:' .audiojs audio { position: absolute; left: -1px; } .audiojs { width: 460px; height: 36px; background: #404040; overflow: hidden; font-family: monospace; font-size: 12px; 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); } .audiojs .play-pause { width: 25px; height: 40px; padding: 4px 6px; margin: 0px; float: left; overflow: hidden; border-right: 1px solid #000; } .audiojs p { display: none; width: 25px; height: 40px; margin: 0px; cursor: pointer; } .audiojs .play { display: block; } .audiojs .scrubber { position: relative; float: left; width: 280px; background: #5a5a5a; height: 14px; margin: 10px; border-top: 1px solid #3f3f3f; border-left: 0px; border-bottom: 0px; overflow: hidden; } .audiojs .progress { position: absolute; top: 0px; left: 0px; height: 14px; width: 0px; background: #ccc; z-index: 1; background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #ccc), color-stop(0.5, #ddd), color-stop(0.51, #ccc), color-stop(1, #ccc)); background-image: -moz-linear-gradient(center top, #ccc 0%, #ddd 50%, #ccc 51%, #ccc 100%); } .audiojs .loaded { position: absolute; top: 0px; left: 0px; height: 14px; width: 0px; 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%); } .audiojs .time { float: left; height: 36px; line-height: 36px; margin: 0px 0px 0px 6px; padding: 0px 6px 0px 12px; border-left: 1px solid #000; color: #ddd; text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.5); } .audiojs .time em { padding: 0px 2px 0px 0px; color: #f9f9f9; font-style: normal; } .audiojs .time strong { padding: 0px 0px 0px 2px; font-weight: normal; } .audiojs .error-message { float: left; display: none; margin: 0px 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; } .audiojs .error-message a { color: #eee; text-decoration: none; padding-bottom: 1px; border-bottom: 1px solid #999; white-space: wrap; } .audiojs .play { background: url("$1") -2px -1px no-repeat; } .audiojs .loading { background: url("$1") -2px -31px no-repeat; } .audiojs .error { background: url("$1") -2px -61px no-repeat; } .audiojs .pause { background: url("$1") -2px -91px no-repeat; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min--moz-device-pixel-ratio: 2), only screen and (min-moz-device-pixel-ratio: 2), only screen and (-o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2) { .audiojs .play, .audiojs .loading, .audiojs .error, .audiojs .pause { background-image: url("$2"); -webkit-background-size: 30px 120px; -moz-background-size: 30px 120px; -o-background-size: 30px 120px; background-size: 30px 120px; } } .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(a){},flashError:function(){var b=this.settings.createPlayer,d=e(b.errorMessageClass,this.wrapper),f='Missing flash player plugin.';this.mp3&&(f+=' Download audio file.'),c[a].helpers.removeClass(this.wrapper,b.loadingClass),c[a].helpers.addClass(this.wrapper,b.errorClass),d.innerHTML=f},loadError:function(b){var d=this.settings.createPlayer,f=e(d.errorMessageClass,this.wrapper);c[a].helpers.removeClass(this.wrapper,d.loadingClass),c[a].helpers.addClass(this.wrapper,d.errorClass),f.innerHTML='Error loading: "'+this.mp3+'"'},init:function(){var b=this.settings.createPlayer;c[a].helpers.addClass(this.wrapper,b.loadingClass)},loadStarted:function(){var b=this.settings.createPlayer,d=e(b.durationClass,this.wrapper),f=Math.floor(this.duration/60),g=Math.floor(this.duration%60);c[a].helpers.removeClass(this.wrapper,b.loadingClass),d.innerHTML=(f<10?"0":"")+f+":"+(g<10?"0":"")+g},loadProgress:function(a){var b=this.settings.createPlayer,c=e(b.loaderClass,this.wrapper);c.style.width=Math.round(100*a)+"%"},playPause:function(){this.playing?this.settings.play():this.settings.pause()},play:function(){var b=this.settings.createPlayer;c[a].helpers.removeClass(this.wrapper,b.errorClass),c[a].helpers.addClass(this.wrapper,b.playingClass),this.settings.onAfterPlay()},onAfterPlay:function(){},pause:function(){var b=this.settings.createPlayer;c[a].helpers.removeClass(this.wrapper,b.playingClass)},updatePlayhead:function(a){var b=this.settings.createPlayer,c=e(b.progressClass,this.wrapper);c.style.width=Math.round(100*a)+"%";var d=e(b.playedClass,this.wrapper),f=this.duration*a,g=Math.floor(f/60),h=Math.floor(f%60);d.innerHTML=(g<10?"0":"")+g+":"+(h<10?"0":"")+h}},create:function(a,b){var b=b||{};return a.length?this.createAll(b,a):this.newInstance(a,b)},createAll:function(a,b){var c=b||document.getElementsByTagName("audio"),d=[];a=a||{};for(var e=0,f=c.length;e-1||d.push(this.newInstance(c[e],a));return d},newInstance:function(a,d){var a=a,e=this.helpers.clone(this.settings),f="audiojs"+this.instanceCount,g="audiojs_wrapper"+this.instanceCount;this.instanceCount++;null!=a.getAttribute("autoplay")&&(e.autoplay=!0),null!=a.getAttribute("loop")&&(e.loop=!0),"none"==a.getAttribute("preload")&&(e.preload=!1),d&&this.helpers.merge(e,d),e.createPlayer.markup?a=this.createPlayer(a,e.createPlayer,g):a.parentNode.setAttribute("id",g);var i=new c[b](a,e);return e.css&&this.helpers.injectCss(i,e.css),e.useFlash&&e.hasFlash?(this.injectFlash(i,f),this.attachFlashEvents(i.wrapper,i)):e.useFlash&&!e.hasFlash&&e.flashError.apply(i),(!e.useFlash||e.useFlash&&e.hasFlash)&&this.attachEvents(i.wrapper,i),this.instances[f]=i,i},createPlayer:function(a,b,c){var d=document.createElement("div"),e=a.cloneNode(!0);return d.setAttribute("class","audiojs"),d.setAttribute("className","audiojs"),d.setAttribute("id",c),e.outerHTML&&!document.createElement("audio").canPlayType?(e=this.helpers.cloneHtml5Node(a),d.innerHTML=b.markup,d.appendChild(e),a.outerHTML=d.outerHTML,d=document.getElementById(c)):(d.appendChild(e),d.innerHTML=d.innerHTML+b.markup,a.parentNode.replaceChild(d,a)),d.getElementsByTagName("audio")[0]},attachEvents:function(b,d){if(d.settings.createPlayer){var f=d.settings.createPlayer,g=e(f.playPauseClass,b),h=e(f.scrubberClass,b);c[a].events.addListener(g,"click",function(a){d.playPause.apply(d)}),c[a].events.addListener(h,"click",function(a){var b=a.clientX-this.getBoundingClientRect().left;d.skipTo(b/h.offsetWidth)}),d.settings.useFlash||(c[a].events.trackLoadProgress(d),c[a].events.addListener(d.element,"timeupdate",function(a){d.updatePlayhead.apply(d)}),c[a].events.addListener(d.element,"ended",function(a){d.trackEnded.apply(d)}),c[a].events.addListener(d.source,"error",function(a){clearInterval(d.readyTimer),clearInterval(d.loadTimer),d.settings.loadError.apply(d)}))}},attachFlashEvents:function(a,b){b.swfReady=!1,b.load=function(a){b.mp3=a,b.swfReady&&b.element.load(a)},b.loadProgress=function(a,c){b.loadedPercent=a,b.duration=c,b.settings.loadStarted.apply(b),b.settings.loadProgress.apply(b,[a])},b.skipTo=function(a){a>b.loadedPercent||(b.updatePlayhead.call(b,[a]),b.element.skipTo(a))},b.updatePlayhead=function(a){b.settings.updatePlayhead.apply(b,[a])},b.play=function(){b.settings.preload||(b.settings.preload=!0,b.element.init(b.mp3)),b.playing=!0,b.element.pplay(),b.settings.play.apply(b)},b.pause=function(){b.playing=!1,b.element.ppause(),b.settings.pause.apply(b)},b.setVolume=function(a){b.element.setVolume(a)},b.loadStarted=function(){b.swfReady=!0,b.settings.preload&&b.element.init(b.mp3),b.settings.autoplay&&b.play.apply(b)}},injectFlash:function(a,b){var c=this.flashSource.replace(/\$1/g,b);c=c.replace(/\$2/g,a.settings.swfLocation),c=c.replace(/\$3/g,+new Date+Math.random());var d=a.wrapper.innerHTML,e=document.createElement("div");e.innerHTML=c+d,a.wrapper.innerHTML=e.innerHTML,a.element=this.helpers.getSwf(b)},helpers:{merge:function(a,b){for(attr in b)(a.hasOwnProperty(attr)||b.hasOwnProperty(attr))&&(a[attr]=b[attr])},clone:function(a){if(null==a||"object"!=typeof a)return a;var b=new a.constructor;for(var c in a)b[c]=arguments.callee(a[c]);return b},addClass:function(a,b){var c=new RegExp("(\\s|^)"+b+"(\\s|$)");c.test(a.className)||(a.className+=" "+b)},removeClass:function(a,b){var c=new RegExp("(\\s|^)"+b+"(\\s|$)");a.className=a.className.replace(c," ")},injectCss:function(a,b){var c="",d=document.getElementsByTagName("style"),e=b.replace(/\$1/g,a.settings.imageLocation);e=e.replace(/\$2/g,a.settings.retinaImageLocation);for(var f=0,g=d.length;f1?b[b.length-1]:b}},events:{memoryLeaking:!1,listeners:[],addListener:function(b,d,e){b.addEventListener?b.addEventListener(d,e,!1):b.attachEvent&&(this.listeners.push(b),this.memoryLeaking||(window.attachEvent("onunload",function(){if(this.listeners)for(var b=0,d=this.listeners.length;b-1&&(d||a.init.apply(a)),a.element.readyState>1&&(a.settings.autoplay&&a.play.apply(a),clearInterval(b),c=setInterval(function(){a.loadProgress.apply(a),a.loadedPercent>=1&&clearInterval(c)},200))},200),a.readyTimer=b,a.loadTimer=c}},purge:function(a){var c,b=a.attributes;if(b)for(c=0;cthis.loadedPercent||(this.element.currentTime=this.duration*a,this.updatePlayhead())},load:function(b,d){d="undefined"!=typeof d?d:"",this.loadStartedCalled=!1,this.source.setAttribute("src",b),this.element.load(),this.mp3=b,this.trackid=d,c[a].events.trackLoadProgress(this)},loadError:function(){this.settings.loadError.apply(this)},init:function(){this.settings.init.apply(this)},loadStarted:function(){return!!this.element.duration&&(this.duration=this.element.duration,this.updatePlayhead(),void this.settings.loadStarted.apply(this))},loadProgress:function(){if(null!=this.element.buffered&&this.element.buffered.length){this.loadStartedCalled||(this.loadStartedCalled=this.loadStarted());var a=this.element.buffered.end(this.element.buffered.length-1);this.loadedPercent=a/this.duration,this.settings.loadProgress.apply(this,[this.loadedPercent])}},playPause:function(){this.playing?this.pause():this.play()},play:function(){var b=/(ipod|iphone|ipad)/i.test(navigator.userAgent);b&&0==this.element.readyState&&this.init.apply(this),this.settings.preload||(this.settings.preload=!0,this.element.setAttribute("preload","auto"),c[a].events.trackLoadProgress(this)),this.playing=!0,this.element.play(),this.settings.play.apply(this)},pause:function(){this.playing=!1,this.element.pause(),this.settings.pause.apply(this)},setVolume:function(a){this.element.volume=a},trackEnded:function(a){this.skipTo.apply(this,[0]),this.settings.loop||this.pause.apply(this),this.settings.trackEnded.apply(this)}};var e=function(a,b){var c=[];if(b=b||document,b.getElementsByClassName)c=b.getElementsByClassName(a);else{var d,e,f=b.getElementsByTagName("*"),g=new RegExp("(^|\\s)"+a+"(\\s|$)");for(d=0,e=f.length;d1?c:c[0]}}("audiojs","audiojsInstance",this); \ No newline at end of file diff --git a/audiojs/player-graphics@2x.gif b/audiojs/player-graphics@2x.gif new file mode 100644 index 0000000..3e4d9d4 Binary files /dev/null and b/audiojs/player-graphics@2x.gif differ diff --git a/demos/test7.html b/demos/test7.html new file mode 100644 index 0000000..fd71e15 --- /dev/null +++ b/demos/test7.html @@ -0,0 +1,215 @@ + + + + + + audio.js + + + + + + + +
+ + Bloodturn.dk - Live demo of trackinfo used for Lyrics +
+

Bensound Royalty Free Tracks

+ +
    +
  1. Dubstep
  2. +
  3. Cute
  4. +
  5. Buddy
  6. +
  7. Acoustic Breeze
  8. +
  9. Epic
  10. +
  11. Funny Song
  12. +
  13. Little Idea
  14. +
  15. Better Days
  16. +
+
+ +
+

Trackinfo

+
+ Select a song from the playlist. +
+
+

Dubstep

+ Lorem ipsum dolor sit amet,
+ consectetur adipiscing elit.
+ Nam auctor nunc ut
+ scelerisque commodo.
+ Cras eget tellus
+ id augue elementum accumsan.
+ Pellentesque dapibus aliquet
+ nibh sit amet elementum.
+
+
+

Cute

+ Donec consectetur malesuada tortor.
+ Proin elementum eleifend ligula.
+ Integer rhoncus vehicula arcu,
+ scelerisque hendrerit libero facilisis eu.
+ Nam vel dolor sit amet enim viverra
+ rhoncus nec et nulla.
+
+
+

Buddy

+ Cras laoreet pretium
+ lorem eget euismod.
+ Vivamus sed congue risus,
+ sit amet vehicula neque.
+ Aliquam vel tempus leo.
+ Pellentesque sit amet pretium leo
+
+
+

Acoustic Breeze

+ vulputate faucibus eros.
+ Proin elementum lorem libero,
+ quis maximus augue consectetur sed.
+ Nullam facilisis lectus vitae
+ sem ullamcorper euismod.
+ Aliquam interdum velit ligula.
+ Sed dictum libero tortor,
+ in pharetra leo euismod nec.
+ Duis in ex augue. +
+
+

Epic

+ Aenean varius convallis facilisis.
+ Orci varius natoque penatibus
+ et magnis dis parturient montes,
+ nascetur ridiculus mus.
+ Sed tempus dolor sagittis,
+ iaculis quam id, posuere ipsum.
+ Maecenas sed condimentum urna.
+ In hac habitasse platea dictumst.
+
+
+

Funny song

+ Sed ante purus, tempus ac euismod vitae,
+ volutpat in risus.
+ Maecenas volutpat ligula diam,
+ ut imperdiet elit posuere in.
+ Aliquam erat volutpat.
+ Quisque aliquam malesuada
+ nulla vel lobortis.
+
+
+

Little Idea

+ In malesuada arcu quam,
+ ac sollicitudin erat congue semper.
+ Phasellus vestibulum,
+ erat ac suscipit fringilla,
+ dui purus molestie lectus,
+ et fringilla velit tellus quis
+ ligula. In hac habitasse platea dictumst.
+
+
+

Better Days

+ vulputate faucibus eros.
+ Proin elementum lorem libero,
+ quis maximus augue consectetur sed.
+ Nullam facilisis lectus vitae
+ sem ullamcorper euismod.
+ Aliquam interdum velit ligula.
+ Sed dictum libero tortor,
+ in pharetra leo euismod nec.
+ Duis in ex augue. +
+
+
+ +

Royalty Free Music from Bensound

+ + diff --git a/index.html b/index.html index ba8b93a..256cdaf 100644 --- a/index.html +++ b/index.html @@ -1,4 +1,4 @@ - + @@ -48,7 +48,8 @@

Examples

Example 3 Multiple players, testing preload, loop & autoplay attributes

Example 4 Customised player

Example 5 Customised playlist player

-

Example 5 Volume Control

+

Example 6 Volume Control

+

Example 7 Customised playlist player + custom trackinfo

Source code

All efforts have been made to keep the source as clean and readable as possible. Until we release more detailed documentation, the annotated source is the best reference for usage.