!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("APlayer",[],t):"object"==typeof exports?exports.APlayer=t():e.APlayer=t()}(this,function(){return function(e){function t(n){if(a[n])return a[n].exports;var i=a[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var a={};return t.m=e,t.c=a,t.i=function(e){return e},t.d=function(e,a,n){t.o(e,a)||Object.defineProperty(e,a,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var a=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(a,"a",a),a},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=1)}([function(e,t,a){var n=a(2);"string"==typeof n&&(n=[[e.i,n,""]]);var i={};i.transform=void 0;a(4)(n,i);n.locals&&(e.exports=n.locals)},function(e,t,a){"use strict";function n(e){if(Array.isArray(e)){for(var t=0,a=Array(e.length);t\n \n \n \n '},this.isMobile=/mobile/i.test(window.navigator.userAgent),this.isMobile&&(t.autoplay=!1);var s={element:document.getElementsByClassName("aplayer")[0],autoplay:!1,mutex:!0,theme:"#b7daff",mode:"circulation"};for(var p in s)s.hasOwnProperty(p)&&!t.hasOwnProperty(p)&&(t[p]=s[p]);this.option=t,this.audios=[],this.mode=t.mode,this.element=this.option.element,this.secondToTime=function(e){if(isNaN(e))return"00:00";var t=function(e){return e<10?"0"+e:""+e},a=parseInt(e/60),n=parseInt(e-60*a),i=parseInt(a/60),r=parseInt(e/60-60*parseInt(e/60/60));return e>=3600?t(i)+":"+t(r)+":"+t(n):t(a)+":"+t(n)},this.updateBar=function(e,t,a){t=t>0?t:0,t=t<1?t:1,m[e+"Bar"].style[a]=100*t+"%"};var u=["play","pause","canplay","playing","ended","error"];this.event={};for(var c=0;c1&&this.element.classList.add("aplayer-withlist"),this.multiple||"circulation"===this.mode||"order"===this.mode||(this.mode="circulation"),this.getRandomOrder();for(var d='\n
\n
\n \n
\n
\n
\n
\n \n \n
\n
\n
\n
\n
\n
\n \n
\n
\n
\n
\n \n 00:00 / 00:00\n \n
\n \n
\n
\n
\n
\n
\n
\n \n \n
\n
\n
\n
\n
    ',y=0;y\n \n '+(y+1)+'\n '+this.option.music[y].title+'\n '+this.option.music[y].author+"\n ";d+="\n
\n
",this.element.innerHTML=d,this.element.offsetWidth<300&&(this.element.getElementsByClassName("aplayer-icon-mode")[0].style.display="none"),this.ptime=this.element.getElementsByClassName("aplayer-ptime")[0],this.element.getElementsByClassName("aplayer-info")[0].offsetWidth<200&&this.element.getElementsByClassName("aplayer-time")[0].classList.add("aplayer-time-narrow");var m={};m.barWrap=this.element.getElementsByClassName("aplayer-bar-wrap")[0],this.button=this.element.getElementsByClassName("aplayer-button")[0],this.button.addEventListener("click",function(e){r.toggle()});var h=this.element.getElementsByClassName("aplayer-list")[0];h.addEventListener("click",function(e){var t=void 0;t="LI"===e.target.tagName.toUpperCase()?e.target:e.target.parentElement;var a=parseInt(t.getElementsByClassName("aplayer-list-index")[0].innerHTML)-1;a!==r.playIndex?(r.setMusic(a),r.play()):r.toggle()}),m.playedBar=this.element.getElementsByClassName("aplayer-played")[0],m.loadedBar=this.element.getElementsByClassName("aplayer-loaded")[0];var f=this.element.getElementsByClassName("aplayer-thumb")[0],g=void 0;m.barWrap.addEventListener("click",function(e){var t=e||window.event;g=m.barWrap.clientWidth;var n=(t.clientX-a(m.barWrap))/g;isNaN(r.audio.duration)?r.updateBar("played",0,"width"):(r.updateBar("played",n,"width"),r.element.getElementsByClassName("aplayer-ptime")[0].innerHTML=r.secondToTime(n*r.audio.duration),r.audio.currentTime=parseFloat(m.playedBar.style.width)/100*r.audio.duration)}),f.addEventListener("mouseover",function(){f.style.background=r.option.theme}),f.addEventListener("mouseout",function(){f.style.background="#fff"});var v=function(e){var t=e||window.event,n=(t.clientX-a(m.barWrap))/g;n=n>0?n:0,n=n<1?n:1,r.updateBar("played",n,"width"),r.element.getElementsByClassName("aplayer-ptime")[0].innerHTML=r.secondToTime(n*r.audio.duration)},b=function e(){document.removeEventListener("mouseup",e),document.removeEventListener("mousemove",v),isNaN(r.audio.duration)?r.updateBar("played",0,"width"):(r.audio.currentTime=parseFloat(m.playedBar.style.width)/100*r.audio.duration,r.playedTime=setInterval(function(){r.updateBar("played",r.audio.currentTime/r.audio.duration,"width"),r.element.getElementsByClassName("aplayer-ptime")[0].innerHTML=r.secondToTime(r.audio.currentTime),r.trigger("playing")},100))};f.addEventListener("mousedown",function(){g=m.barWrap.clientWidth,clearInterval(r.playedTime),document.addEventListener("mousemove",v),document.addEventListener("mouseup",b)}),m.volumeBar=this.element.getElementsByClassName("aplayer-volume")[0];var A=this.element.getElementsByClassName("aplayer-volume-bar")[0];this.volumeicon=this.element.getElementsByClassName("aplayer-time")[0].getElementsByTagName("button")[0];this.element.getElementsByClassName("aplayer-volume-bar-wrap")[0].addEventListener("click",function(e){var t=e||window.event,a=(35-t.clientY+n(A))/35;a=a>0?a:0,a=a<1?a:1,r.volume(a)}),this.volumeicon.addEventListener("click",function(){r.audio.muted?(r.audio.muted=!1,r.volumeicon.className=1===r.audio.volume?"aplayer-icon aplayer-icon-volume-up":"aplayer-icon aplayer-icon-volume-down",1===r.audio.volume?(r.volumeicon.className="aplayer-icon aplayer-icon-volume-up",r.volumeicon.innerHTML=r.getSVG("volume-up")):(r.volumeicon.className="aplayer-icon aplayer-icon-volume-down",r.volumeicon.innerHTML=r.getSVG("volume-down")),r.updateBar("volume",r.audio.volume,"height")):(r.audio.muted=!0,r.volumeicon.className="aplayer-icon aplayer-icon-volume-off",r.volumeicon.innerHTML=r.getSVG("volume-off"),r.updateBar("volume",0,"height"))});var x=this.element.getElementsByClassName("aplayer-icon-mode")[0];x.addEventListener("click",function(){r.multiple?"random"===r.mode?r.mode="single":"single"===r.mode?r.mode="order":"order"===r.mode?r.mode="circulation":"circulation"===r.mode&&(r.mode="random"):"circulation"===r.mode?r.mode="order":r.mode="circulation",x.innerHTML=r.getSVG(r.mode),r.audio.loop=!(r.multiple||"order"===r.mode)}),h.style.height=h.offsetHeight+"px",this.element.getElementsByClassName("aplayer-icon-menu")[0].addEventListener("click",function(){h.classList.contains("aplayer-list-hide")?h.classList.remove("aplayer-list-hide"):h.classList.add("aplayer-list-hide")}),"random"===this.mode?this.setMusic(this.randomOrder[0]):this.setMusic(0),l.push(this)}return r(e,[{key:"setMusic",value:function(e){var t=this;void 0!==e&&(this.playIndex=e);var a=this.playIndex;this.music=this.option.music[a],this.music.pic?this.element.getElementsByClassName("aplayer-pic")[0].style.backgroundImage="url('"+this.music.pic+"')":this.element.getElementsByClassName("aplayer-pic")[0].style.backgroundImage="",this.element.getElementsByClassName("aplayer-title")[0].innerHTML=this.music.title,this.element.getElementsByClassName("aplayer-author")[0].innerHTML=" - "+this.music.author,this.element.getElementsByClassName("aplayer-list-light")[0]&&this.element.getElementsByClassName("aplayer-list-light")[0].classList.remove("aplayer-list-light"),this.element.getElementsByClassName("aplayer-list")[0].getElementsByTagName("li")[a].classList.add("aplayer-list-light"),!this.isMobile&&this.audio&&(this.pause(),this.audio.currentTime=0),this.element.getElementsByClassName("aplayer-list")[0].scrollTop=33*a,this.isMobile&&this.audio?(this.audio.src=this.music.url,this.play()):!this.isMobile&&this.audios[a]?(this.audio=this.audios[a],this.audio.volume=parseInt(this.element.getElementsByClassName("aplayer-volume")[0].style.height)/100,this.audio.currentTime=0):(this.audio=document.createElement("audio"),this.audio.src=this.music.url,this.audio.preload=this.option.preload?this.option.preload:"auto",this.audio.addEventListener("play",function(){if(t.button.classList.contains("aplayer-play")){if(t.button.classList.remove("aplayer-play"),t.button.classList.add("aplayer-pause"),t.button.innerHTML="",setTimeout(function(){t.button.innerHTML='\n "},100),t.option.mutex)for(var e=0;e'+t.getSVG("play")+" "},100),clearInterval(t.playedTime),t.trigger("pause"))}),this.audio.addEventListener("durationchange",function(){1!==t.audio.duration&&(t.element.getElementsByClassName("aplayer-dtime")[0].innerHTML=t.secondToTime(t.audio.duration))}),this.audio.addEventListener("progress",function(){var e=t.audio.buffered.length?t.audio.buffered.end(t.audio.buffered.length-1)/t.audio.duration:0;t.updateBar("loaded",e,"width")}),this.audio.addEventListener("error",function(){t.element.getElementsByClassName("aplayer-author")[0].innerHTML=" - Error happens ╥﹏╥",t.trigger("pause")}),this.audio.addEventListener("canplay",function(){t.trigger("canplay")}),this.ended=!1,this.audio.addEventListener("ended",function(){t.multiple?0!==t.audio.currentTime&&("random"===t.mode?t.setMusic(t.nextRandomNum()):"single"===t.mode?t.setMusic(t.playIndex):"order"===t.mode?t.playIndex=0&&b.splice(t,1)}function o(e){var t=document.createElement("style");return e.attrs.type="text/css",p(t,e.attrs),r(e,t),t}function s(e){var t=document.createElement("link");return e.attrs.type="text/css",e.attrs.rel="stylesheet",p(t,e.attrs),r(e,t),t}function p(e,t){Object.keys(t).forEach(function(a){e.setAttribute(a,t[a])})}function u(e,t){var a,n,i,r;if(t.transform&&e.css){if(!(r=t.transform(e.css)))return function(){};e.css=r}if(t.singleton){var p=v++;a=g||(g=o(t)),n=c.bind(null,a,p,!1),i=c.bind(null,a,p,!0)}else e.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(a=s(t),n=y.bind(null,a,t),i=function(){l(a),a.href&&URL.revokeObjectURL(a.href)}):(a=o(t),n=d.bind(null,a),i=function(){l(a)});return n(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;n(e=t)}else i()}}function c(e,t,a,n){var i=a?"":n.css;if(e.styleSheet)e.styleSheet.cssText=x(t,i);else{var r=document.createTextNode(i),l=e.childNodes;l[t]&&e.removeChild(l[t]),l.length?e.insertBefore(r,l[t]):e.appendChild(r)}}function d(e,t){var a=t.css,n=t.media;if(n&&e.setAttribute("media",n),e.styleSheet)e.styleSheet.cssText=a;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(a))}}function y(e,t,a){var n=a.css,i=a.sourceMap,r=void 0===t.convertToAbsoluteUrls&&i;(t.convertToAbsoluteUrls||r)&&(n=A(n)),i&&(n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(i))))+" */");var l=new Blob([n],{type:"text/css"}),o=e.href;e.href=URL.createObjectURL(l),o&&URL.revokeObjectURL(o)}var m={},h=function(e){var t;return function(){return void 0===t&&(t=e.apply(this,arguments)),t}}(function(){return window&&document&&document.all&&!window.atob}),f=function(e){var t={};return function(a){return void 0===t[a]&&(t[a]=e.call(this,a)),t[a]}}(function(e){return document.querySelector(e)}),g=null,v=0,b=[],A=a(5);e.exports=function(e,t){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");t=t||{},t.attrs="object"==typeof t.attrs?t.attrs:{},t.singleton||(t.singleton=h()),t.insertInto||(t.insertInto="head"),t.insertAt||(t.insertAt="bottom");var a=i(e,t);return n(a,t),function(e){for(var r=[],l=0;l