text: !function(a){a.Callbacks=function(b){b=a.extend({},b);var c,d,e,f,g,h,i=[],j=!b.once&&[],k=function(a){for(c=b.memory&&a,d=!0,h=f||0,f=0,g=i.length,e=!0;i&&g>h;++h)if(i[h].apply(a[0],a[1])===!1&&b.stopOnFalse){c=!1;break}e=!1,i&&(j?j.length&&k(j.shift()):c?i.length=0:l.disable())},l={add:function(){if(i){var d=i.length,h=function(c){a.each(c,function(a,c){"function"==typeof c?b.unique&&l.has(c)||i.push(c):c&&c.length&&"string"!=typeof c&&h(c)})};h(arguments),e?g=i.length:c&&(f=d,k(c))}return this},remove:function(){return i&&a.each(arguments,function(b,c){for(var d;(d=a.inArray(c,i,d))>-1;)i.splice(d,1),e&&(g>=d&&--g,h>=d&&--h)}),this},has:function(b){return!(!i||!(b?a.inArray(b,i)>-1:i.length))},empty:function(){return g=i.length=0,this},disable:function(){return i=j=c=void 0,this},disabled:function(){return!i},lock:function(){return j=void 0,c||l.disable(),this},locked:function(){return!j},fireWith:function(a,b){return!i||d&&!j||(b=b||[],b=[a,b.slice?b.slice():b],e?j.push(b):k(b)),this},fire:function(){return l.fireWith(this,arguments)},fired:function(){return!!d}};return l}}(Zepto),function(a){function b(c){var d=[["resolve","done",a.Callbacks({once:1,memory:1}),"resolved"],["reject","fail",a.Callbacks({once:1,memory:1}),"rejected"],["notify","progress",a.Callbacks({memory:1})]],e="pending",f={state:function(){return e},always:function(){return g.done(arguments).fail(arguments),this},then:function(){var c=arguments;return b(function(b){a.each(d,function(d,e){var h=a.isFunction(c[d])&&c[d];g[e[1]](function(){var c=h&&h.apply(this,arguments);if(c&&a.isFunction(c.promise))c.promise().done(b.resolve).fail(b.reject).progress(b.notify);else{var d=this===f?b.promise():this,g=h?[c]:arguments;b[e[0]+"With"](d,g)}})}),c=null}).promise()},promise:function(b){return null!=b?a.extend(b,f):f}},g={};return a.each(d,function(a,b){var c=b[2],h=b[3];f[b[1]]=c.add,h&&c.add(function(){e=h},d[1^a][2].disable,d[2][2].lock),g[b[0]]=function(){return g[b[0]+"With"](this===g?f:this,arguments),this},g[b[0]+"With"]=c.fireWith}),f.promise(g),c&&c.call(g,g),g}var c=Array.prototype.slice;a.when=function(d){var e,f,g,h=c.call(arguments),i=h.length,j=0,k=1!==i||d&&a.isFunction(d.promise)?i:0,l=1===k?d:b(),m=function(a,b,d){return function(f){b[a]=this,d[a]=arguments.length>1?c.call(arguments):f,d===e?l.notifyWith(b,d):--k||l.resolveWith(b,d)}};if(i>1)for(e=new Array(i),f=new Array(i),g=new Array(i);i>j;++j)h[j]&&a.isFunction(h[j].promise)?h[j].promise().done(m(j,g,h)).fail(l.reject).progress(m(j,f,e)):--k;return k||l.resolveWith(g,h),l.promise()},a.Deferred=b}(Zepto),function(a){var b=Object.prototype,c=b.toString;a.isString=function(a){return"[object String]"===c.call(a)},a.isNumeric=function(a){return"[object Number]"===c.call(a)},a.getScript=function(a,b){var c=document,d=c.createElement("script");d.async="async",b?isFunction(b)&&(b={callback:b}):b={},b.charset&&(d.charset=b.charset),d.src=a;var e=c.getElementsByTagName("head")[0];d.onload=d.onreadystatechange=function(a,c){(c||!d.readyState||/loaded|complete/.test(d.readyState))&&(d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=void 0,!c&&b.callback&&b.callback())},e.insertBefore(d,e.firstChild)}}(Zepto),/* @license
   * Baidu Music Player: 1.0.0
   * -------------------------
   * (c) 2014 FE Team of Baidu Music
   * Can be freely distributed under the MIT license.
   */
  function(a,b){return"undefined"==typeof a._mu&&(a._mu={}),"object"==typeof exports?module.exports=b():"function"==typeof define&&define.amd?define("muplayer/core/cfg",b):a._mu.cfg=b()}(this,function(){var a;return a=this,$.extend({namespace:a._mu,debug:!1,version:"0.9.0",timerResolution:25,emptyMP3:"../dist/mp3/empty.mp3",expressInstaller:"../dist/swf/expressInstall.swf",engine:{TYPES:{FLASH_MP3:"FlashMP3Core",AUDIO:"AudioCore"},EVENTS:{STATECHANGE:"engine:statechange",POSITIONCHANGE:"engine:postionchange",PROGRESS:"engine:progress",ERROR:"engine:error",INIT:"engine:init",INIT_FAIL:"engine:init_fail"},STATES:{NOT_INIT:"not_init",PREBUFFER:"prebuffer",BUFFERING:"buffering",PLAYING:"playing",PAUSE:"pause",STOP:"stop",END:"ended"},ERRCODE:{MEDIA_ERR_ABORTED:"1",MEDIA_ERR_NETWORK:"2",MEDIA_ERR_DECODE:"3",MEDIA_ERR_SRC_NOT_SUPPORTED:"4"}}},"undefined"==typeof a._mu?{}:a._mu.cfg)}),function(a,b){return"object"==typeof exports?module.exports=b():"function"==typeof define&&define.amd?define("muplayer/core/utils",["muplayer/core/cfg"],b):a._mu.utils=b(a._mu.cfg)}(this,function(a){var b,c,d,e,f,g,h,i,j,k,l,m;for(j={},e=String.prototype,c=Number.prototype,d=Object.prototype,b=Array.prototype,h=b.push,f=d.hasOwnProperty,i=d.toString,m=["Arguments","Function","String","Number","Date","RegExp"],k=0,l=m.length;l>k;k++)g=m[k],j["is"+g]=function(a){return function(b){return i.call(b)==="[object "+a+"]"}}(g);return $.isFunction(e.startsWith)||(e=function(a){return this.slice(0,a.length)===a}),$.isFunction(e.endsWith)||(e=function(a){return this.slice(-a.length)===a}),c.toFixed=function(a){var b,c,d;if(d=Math.pow(10,a),b=(Math.round(this*d)/d).toString(),0===a)return b;for(b.indexOf(".")<0&&(b+="."),c=a+1-(b.length-b.indexOf("."));c--;)b+="0";return b},$.extend(j,{isEmpty:function(a){var b,c,d;if(null==a)return!0;if($.isArray(a)||this.isString(a))return 0===a.length;for(c=0,d=a.length;d>c;c++)if(b=a[c],this.has(a,b))return!1;return!0},isBoolean:function(a){return a===!0||a===!1||"[object Boolean]"===i.call(a)},has:function(a,b){return f.call(a,b)},random:function(a,b){return b||(b=a,a=0),a+Math.floor(Math.random()*(b-a+1))},shuffle:function(a){var b,c,d,e,f,g;for(b=0,e=[],f=0,g=a.length;g>f;f++)c=a[f],d=this.random(b++),e[b-1]=e[d],e[d]=c;return e},clone:function(a){return!$.isPlainObject(a),$.isArray(a)?a.slice():$.extend({},a)},time2str:function(a){var b,c,d,e,f,g;return f=[],b=Math.floor,a=Math.round(a),c=b(a/3600),d=b((a-3600*c)/60),g=a%60,e=function(a,b){var c,d,e;return d="",c="",0>a&&(c="-"),e=String(Math.abs(a)),e.length<b&&(d=new Array(b-e.length+1).join("0")),c+d+e},c&&f.push(c),f.push(e(d,2)),f.push(e(g,2)),f.join(":")},namespace:function(){var b,c,d,e,f,g,h,i,j,k;for(b=arguments,h=".",i=0,j=b.length;j>i;i++)if(c=b[i],g=a.namespace,c.indexOf(h)>-1)for(d=c.split(h),k=[0,d.length],e=k[0],f=k[1];f>e;)g[d[e]]=g[d[e]]||{},g=g[d[e]],e++;else g[c]=g[c]={},g=g[c];return g},wrap:function(a,b){return function(){var c;return c=[a],h.apply(c,arguments),b.apply(this,c)}}}),j}),function(a,b){"object"==typeof exports?module.exports=b():"function"==typeof define&&define.amd?define("muplayer/lib/events",b):a._mu.Events=b()}(this,function(){function a(){}function b(a,b,c){if(a){var d=0,e=a.length,f=b[0],g=b[1],h=b[2],i=!0;switch(b.length){case 0:for(;e>d;d+=2)i=a[d].call(a[d+1]||c)!==!1&&i;break;case 1:for(;e>d;d+=2)i=a[d].call(a[d+1]||c,f)!==!1&&i;break;case 2:for(;e>d;d+=2)i=a[d].call(a[d+1]||c,f,g)!==!1&&i;break;case 3:for(;e>d;d+=2)i=a[d].call(a[d+1]||c,f,g,h)!==!1&&i;break;default:for(;e>d;d+=2)i=a[d].apply(a[d+1]||c,b)!==!1&&i}}return i}function c(a){return"[object Function]"===Object.prototype.toString.call(a)}var d=/\s+/;a.prototype.on=function(a,b,c){var e,f,g;if(!b)return this;for(e=this.__events||(this.__events={}),a=a.split(d);f=a.shift();)g=e[f]||(e[f]=[]),g.push(b,c);return this},a.prototype.once=function(a,b,c){var d=this,e=function(){d.off(a,e),b.apply(this,arguments)};this.on(a,e,c)},a.prototype.off=function(a,b,c){var f,g,h,i;if(!(f=this.__events))return this;if(!(a||b||c))return delete this.__events,this;for(a=a?a.split(d):e(f);g=a.shift();)if(h=f[g])if(b||c)for(i=h.length-2;i>=0;i-=2)b&&h[i]!==b||c&&h[i+1]!==c||h.splice(i,2);else delete f[g];return this},a.prototype.trigger=function(a){var c,e,f,g,h,i,j=[],k=!0;if(!(c=this.__events))return this;for(a=a.split(d),h=1,i=arguments.length;i>h;h++)j[h-1]=arguments[h];for(;e=a.shift();)(f=c.all)&&(f=f.slice()),(g=c[e])&&(g=g.slice()),k=b(g,j,this)&&k,k=b(f,[e].concat(j),this)&&k;return k},a.prototype.emit=a.prototype.trigger,a.mixTo=function(b){b=c(b)?b.prototype:b;var d=a.prototype;for(var e in d)d.hasOwnProperty(e)&&(b[e]=d[e])};var e=Object.keys;return e||(e=function(a){var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(c);return b}),a});var __indexOf=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};!function(a,b){return"object"==typeof exports?module.exports=b():"function"==typeof define&&define.amd?define("muplayer/core/playlist",["muplayer/core/utils","muplayer/lib/events"],b):a._mu.Playlist=b(_mu.cfg,_mu.Events)}(this,function(a,b){var c,d;return d=function(a){var b;return $.isArray(a)&&function(){var c,d,e;for(e=[],c=0,d=a.length;d>c;c++)b=a[c],b&&e.push(""+b);return e}()||""+a},c=function(){function b(){this.reset()}return b.prototype.reset=function(){return this.cur="",$.isArray(this.list)?this.list.length=0:this.list=[]},b.prototype._resetListRandom=function(b){var c;return"list-random"===this.mode?(b=b||0,this._listRandomIndex=b,this._listRandom=a.shuffle(function(){c=[];for(var a=0,b=this.list.length;b>=0?b>a:a>b;b>=0?a++:a--)c.push(a);return c}.apply(this)),this.cur=this.list[this._listRandom[b]]):void 0},b.prototype.setMode=function(a){return("single"===a||"random"===a||"list-random"===a||"list"===a||"loop"===a)&&(this.mode=a),this._resetListRandom()},b.prototype.add=function(a){return a=d(a),this.remove(a),$.isArray(a)&&a.length?this.list=a.concat(this.list):a&&this.list.unshift(a),this.trigger("playlist:add",a),this._resetListRandom()},b.prototype.remove=function(a){var b,c,e,f,g=this;if(c=function(a){var b;return b=$.inArray(a,g.list),-1!==b?g.list.splice(b,1):void 0},a=d(a),$.isArray(a))for(e=0,f=a.length;f>e;e++)b=a[e],c(b);else c(a);return this.trigger("playlist:remove",a),this._resetListRandom()},b.prototype.prev=function(){var b,c,d,e;switch(d=this.list,b=$.inArray(this.cur,d),c=d.length,e=b-1,this.mode){case"single":e=b;break;case"random":e=a.random(0,c-1);break;case"list":if(b=0)return this.cur=d[0],!1;break;case"list-random":return b=this._listRandomIndex--,e=b-1,0===b&&(e=c-1,this._resetListRandom(e)),this.cur=d[this._listRandom[e]];case"loop":0===b&&(e=c-1)}return this.cur=d[e]},b.prototype.next=function(){var b,c,d,e;switch(d=this.list,b=$.inArray(this.cur,d),c=d.length,e=b+1,this.mode){case"single":e=b;break;case"random":e=a.random(0,c-1);break;case"list":if(b===c-1)return this.cur=d[0],!1;break;case"list-random":return b=this._listRandomIndex++,e=b+1,b===c-1&&(e=0,this._resetListRandom(e)),this.cur=d[this._listRandom[e]];case"loop":b===c-1&&(e=0)}return this.cur=d[e]},b.prototype.setCur=function(a){return a+="",__indexOf.call(this.list,a)<0&&this.add(a),this.cur=""+a},b}(),b.mixTo(c),c});var __indexOf=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};!function(a,b){return"object"==typeof exports?module.exports=b():"function"==typeof define&&define.amd?define("muplayer/core/engines/engineCore",["muplayer/core/cfg","muplayer/core/utils","muplayer/lib/events"],b):a._mu.EngineCore=b(_mu.cfg,_mu.utils,_mu.Events)}(this,function(a,b,c){var d,e,f,g,h,i,j;return j=a.engine,d=j.EVENTS,f=j.STATES,g=function(){var a;a=[];for(h in f)i=f[h],a.push(i);return a}(),e=function(){function a(){}return a.prototype._supportedTypes=[],a.prototype.getSupportedTypes=function(){return this._supportedTypes},a.prototype.canPlayType=function(a){return-1!==$.inArray(a,this.getSupportedTypes())},a.prototype.reset=function(){return this.stop(),this.setUrl(),this.setState(f.END),this},a.prototype.play=function(){return this},a.prototype.pause=function(){return this},a.prototype.stop=function(){return this},a.prototype.setUrl=function(a){return null==a&&(a=""),this._url=a,this},a.prototype.getUrl=function(){return this._url},a.prototype.setState=function(a){var b;return __indexOf.call(g,a)>=0&&a!==this._state?(b=this._state,this._state=a,this.trigger(d.STATECHANGE,{oldState:b,newState:a})):void 0},a.prototype.getState=function(){return this._state},a.prototype.setVolume=function(a){return this._volume=a,this},a.prototype.getVolume=function(){return this._volume},a.prototype.setMute=function(a){return this._mute=a,this},a.prototype.getMute=function(){return this._mute},a.prototype.setCurrentPosition=function(){return this},a.prototype.getCurrentPosition=function(){return 0},a.prototype.getLoadedPercent=function(){return 0},a.prototype.getTotalTime=function(){return 0},a}(),c.mixTo(e),e}),function(a,b){"object"==typeof exports?module.exports=b():"function"==typeof define&&define.amd?define("muplayer/lib/modernizr.audio",b):a._mu.Modernizr=b()}(this,function(){return function(a,b,c){function d(a){n.cssText=a}function e(a,b){return typeof a===b}var f,g,h,i="2.7.1",j={},k=b.documentElement,l="modernizr",m=b.createElement(l),n=m.style,o=({}.toString,{}),p=[],q=p.slice,r={}.hasOwnProperty;h=e(r,"undefined")||e(r.call,"undefined")?function(a,b){return b in a&&e(a.constructor.prototype[b],"undefined")}:function(a,b){return r.call(a,b)},Function.prototype.bind||(Function.prototype.bind=function(a){var b=this;if("function"!=typeof b)throw new TypeError;var c=q.call(arguments,1),d=function(){if(this instanceof d){var e=function(){};e.prototype=b.prototype;var f=new e,g=b.apply(f,c.concat(q.call(arguments)));return Object(g)===g?g:f}return b.apply(a,c.concat(q.call(arguments)))};return d}),o.audio=function(){var a=b.createElement("audio"),c=!1;try{(c=!!a.canPlayType)&&(c=new Boolean(c),c.ogg=a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),c.mp3=a.canPlayType("audio/mpeg;").replace(/^no$/,""),c.wav=a.canPlayType('audio/wav; codecs="1"').replace(/^no$/,""),c.m4a=(a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;")).replace(/^no$/,""))}catch(d){}return c};for(var s in o)h(o,s)&&(g=s.toLowerCase(),j[g]=o[s](),p.push((j[g]?"":"no-")+g));return j.addTest=function(a,b){if("object"==typeof a)for(var d in a)h(a,d)&&j.addTest(d,a[d]);else{if(a=a.toLowerCase(),j[a]!==c)return j;b="function"==typeof b?b():b,"undefined"!=typeof enableClasses&&enableClasses&&(k.className+=" "+(b?"":"no-")+a),j[a]=b}return j},d(""),m=f=null,j._version=i,j}(this,this.document)});var __hasProp={}.hasOwnProperty,__extends=function(a,b){function c(){this.constructor=a}for(var d in b)__hasProp.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},__slice=[].slice;!function(a,b){return"object"==typeof exports?module.exports=b():"function"==typeof define&&define.amd?define("muplayer/core/engines/audioCore",["muplayer/core/cfg","muplayer/core/utils","muplayer/core/engines/engineCore","muplayer/lib/modernizr.audio"],b):a._mu.AudioCore=b(_mu.cfg,_mu.utils,_mu.EngineCore,_mu.Modernizr)}(this,function(a,b,c,d){var e,f,g,h,i,j,k;return j=window,k=a.engine,i=k.TYPES,g=k.EVENTS,h=k.STATES,f=k.ERRCODE,e=function(c){function e(a){var b,c,f,g,h,i,k,l=this;if(this.opts=h=$.extend(e.defaults,a),g={"":0,maybe:1,probably:2},f=g[h.confidence],b=d.audio,!b)return this;for(c in b)k=b[c],g[k]>=f&&this._supportedTypes.push(c);b=new Audio,b.preload=h.preload,b.autoplay=h.autoplay,b.loop=!1,b.on=function(a,c){return b.addEventListener(a,c,!1),b},b.off=function(a,c){return b.removeEventListener(a,c,!1),b},this.audio=b,this._needCanPlay(["play","setCurrentPosition"]),this._initEvents(),i=function(){return l.setUrl(h.emptyMP3).play(),j.removeEventListener("touchstart",i,!1)},j.addEventListener("touchstart",i,!1)}return __extends(e,c),e.defaults={confidence:"maybe",preload:!1,autoplay:!1,emptyMP3:a.emptyMP3},e.prototype._supportedTypes=[],e.prototype.engineType=i.AUDIO,e.prototype._test=function(a){return d.audio===!1||0===this._supportedTypes.length?!1:(a&&this.trigger(g.INIT_FAIL,this.engineType),!0)},e.prototype._initEvents=function(){var a,b,c,d=this;return c=this.trigger,this.trigger=function(a,b){return d.getUrl()!==d.opts.emptyMP3?c.call(d,a,b):void 0},a=function(a){return d.setState(h.BUFFERING),d.trigger(g.PROGRESS,a||d.getLoadedPercent())},b=null,this.audio.on("loadstart",function(){var c;return c=d.audio,b=setInterval(function(){return c.readyState>1?clearInterval(b):a()},50),d.setState(h.PREBUFFER)}).on("playing",function(){return d.setState(h.PLAYING)}).on("pause",function(){return d.setState(d.getCurrentPosition()&&h.PAUSE||h.STOP)}).on("ended",function(){return d.setState(h.END)}).on("error",function(){return d.setState(h.END),d.trigger(g.ERROR,f.MEDIA_ERR_NETWORK)}).on("waiting",function(){return d.setState(d.getCurrentPosition()&&h.BUFFERING||h.PREBUFFER)}).on("timeupdate",function(){return d.trigger(g.POSITIONCHANGE,d.getCurrentPosition())}).on("progress",function(c){var d,e;return clearInterval(b),d=c.loaded||0,e=c.total||1,a(d&&1*(d/e).toFixed(2))})},e.prototype._needCanPlay=function(a){var c,d,e,f,g,h=this;for(c=this.audio,g=[],e=0,f=a.length;f>e;e++)d=a[e],g.push(this[d]=b.wrap(this[d],function(){var a,b,d;return b=arguments[0],a=2<=arguments.length?__slice.call(arguments,1):[],c.readyState<3?(d=function(){return b.apply(h,a),c.off("canplay",d)},c.on("canplay",d)):b.apply(h,a),h}));return g},e.prototype.play=function(){return this.audio.play(),this},e.prototype.pause=function(){return this.audio.pause(),this},e.prototype.stop=function(){try{this.audio.currentTime=0}catch(a){}return this.pause()},e.prototype.setUrl=function(a){return null==a&&(a=""),this.audio.src=a,this.audio.load(),e.__super__.setUrl.call(this,a)},e.prototype.setVolume=function(a){return this.audio.volume=a/100,e.__super__.setVolume.call(this,a)},e.prototype.setMute=function(a){return a=!!a,this.audio.muted=a,e.__super__.setMute.call(this,a)},e.prototype.setCurrentPosition=function(a){var b;try{this.audio.currentTime=a/1e3}catch(c){b=c,"undefined"!=typeof console&&null!==console&&console.error(b)}return this.play(),this},e.prototype.getCurrentPosition=function(){return 1e3*this.audio.currentTime},e.prototype.getLoadedPercent=function(){var a,b,c,d,e,f;for(a=this.audio,e=a.duration,d=a.buffered,c=d.length,b=0;c--;)if(d.start(c)<=(f=a.currentTime)&&f<=d.end(c)){b=d.end(c);break}return b=b>e?e:b,e&&1*(b/e).toFixed(2)||0},e.prototype.getTotalTime=function(){var a;return a=this.audio.duration,a&&1e3*a||0},e}(c)}),function(a,b){return"object"==typeof exports?module.exports=b():"function"==typeof define&&define.amd?define("muplayer/core/engines/engine",["muplayer/core/cfg","muplayer/core/utils","muplayer/lib/events","muplayer/core/engines/engineCore","muplayer/core/engines/audioCore"],b):a._mu.Engine=b(_mu.cfg,_mu.utils,_mu.Events,_mu.EngineCore,_mu.AudioCore)}(this,function(cfg,utils,Events,EngineCore,AudioCore,FlashMP3Core){var EVENTS,Engine,STATES,extReg,timerResolution,_ref;return _ref=cfg.engine,EVENTS=_ref.EVENTS,STATES=_ref.STATES,timerResolution=cfg.timerResolution,extReg=/\.(.+)(\?|$)/,Engine=function(){function Engine(a){this.opts=$.extend(Engine.defaults,a),this._initEngines()}return Engine.defaults={type:"mp3",el:'<div id="muplayer_container_{{DATETIME}}" style="width: 1px; height: 1px; overflow: hidden"></div>',engines:[{constructor:AudioCore}]},Engine.prototype._initEngines=function(){var $el,args,constructor,el,engine,i,opts,_i,_len,_ref1;for(opts=this.opts,this.engines=[],el=opts.el.replace(/{{DATETIME}}/g,+new Date),$el=$(el).appendTo("body"),_ref1=opts.engines,i=_i=0,_len=_ref1.length;_len>_i;i=++_i){engine=_ref1[i],constructor=engine.constructor,args=engine.args||{},args.$el=$el;try{$.isFunction(constructor)||(constructor=eval(constructor)),engine=new constructor(args)}catch(_error){throw"Missing constructor: "+String(engine.constructor)}engine._test()&&this.engines.push(engine)}return this.setEngine(this.engines.length?this.engines[0]:new EngineCore)},Engine.prototype.setEngine=function(a){var b,c,d,e,f,g=this;return e=function(a){return g.trigger(EVENTS.STATECHANGE,a)},c=function(a){return g.trigger(EVENTS.POSITIONCHANGE,a)},d=function(a){return g.trigger(EVENTS.PROGRESS,a)},b=function(a){return a.on(EVENTS.STATECHANGE,e).on(EVENTS.POSITIONCHANGE,c).on(EVENTS.PROGRESS,d)},f=function(a){return a.off(EVENTS.STATECHANGE,e).off(EVENTS.POSITIONCHANGE,c).off(EVENTS.PROGRESS,d)},this.curEngine?this.curEngine!==a?(f(this.curEngine),this.curEngine=b(a).setVolume(this.curEngine.getVolume()).setMute(this.curEngine.getMute())):void 0:this.curEngine=b(a)},Engine.prototype.canPlayType=function(a){return-1!==$.inArray(a,this.getSupportedTypes())},Engine.prototype.getSupportedTypes=function(){var a,b,c,d,e;for(b=[],e=this.engines,c=0,d=e.length;d>c;c++)a=e[c],b=b.concat(a.getSupportedTypes());return b},Engine.prototype.switchEngineByType=function(a,b){var c,d,e,f,g;for(d=!1,g=this.engines,e=0,f=g.length;f>e;e++)if(c=g[e],c.canPlayType(a)){this.setEngine(c),d=!0;break}return d||b?void 0:this.switchEngineByType(this.opts.type,!0)},Engine.prototype.reset=function(){return this.curEngine.reset(),this},Engine.prototype.setUrl=function(a){var b,c;return extReg.test(a)&&(c=RegExp.$1),b=this.curEngine,this.canPlayType(c)||this.switchEngineByType(c),b.engineType!==this.curEngine.engineType&&b.stop(),this.curEngine.setUrl(a),this},Engine.prototype.getUrl=function(){return this.curEngine.getUrl()},Engine.prototype.play=function(){return this.curEngine.play(),this},Engine.prototype.pause=function(){return this.curEngine.pause(),this},Engine.prototype.stop=function(){return this.curEngine.stop(),this},Engine.prototype.setMute=function(a){return utils.isBoolean(a)&&this.curEngine.setMute(a),this},Engine.prototype.getMute=function(){return this.curEngine.getMute()},Engine.prototype.setVolume=function(a){return $.isNumeric(a)&&a>=0&&100>=a&&this.curEngine.setVolume(a),this},Engine.prototype.getVolume=function(){return this.curEngine.getVolume()},Engine.prototype.setCurrentPosition=function(a){return a=~~a,this.curEngine.setCurrentPosition(a),this},Engine.prototype.getCurrentPosition=function(){return this.curEngine.getCurrentPosition()},Engine.prototype.getLoadedPercent=function(){return this.curEngine.getLoadedPercent()},Engine.prototype.getTotalTime=function(){return this.curEngine.getTotalTime()},Engine.prototype.getEngineType=function(){return this.curEngine.engineType},Engine.prototype.getState=function(){return this.curEngine.getState()},Engine}(),Events.mixTo(Engine),Engine}),function(a,b){return"object"==typeof exports?module.exports=b():"function"==typeof define&&define.amd?define("muplayer/player",["muplayer/core/cfg","muplayer/core/utils","muplayer/lib/events","muplayer/core/playlist","muplayer/core/engines/engine"],b):a._mu.Player=b(a._mu.cfg,a._mu.utils,a._mu.Events,a._mu.Playlist,a._mu.Engine)}(this,function(a,b,c,d,e){var f,g,h,i,j;return j=a.engine,f=j.EVENTS,h=j.STATES,i=b.time2str,g=function(){function a(c){var f;return b?b:(b=this,this.opts=f=$.extend(a.defaults,c),this.playlist=new d,this.playlist.setMode(f.mode),this._initEngine(new e(f.engine)),this.setMute(f.mute),void this.setVolume(f.volume))}var b;return b=null,a.defaults={mode:"loop",mute:!1,volume:80},a.prototype._initEngine=function(a){var b=this;return this.engine=a.on(f.STATECHANGE,function(a){var c;return c=a.newState,b.trigger(c),c===h.END?b.next(!0):void 0}).on(f.POSITIONCHANGE,function(a){return b.trigger("timeupdate",a)}).on(f.PROGRESS,function(a){return b.trigger("progress",a)})},a.prototype.play=function(a){var b,c,d,e=this;return a=~~a,b=$.Deferred(),c=this.engine,d=function(){return a?c.setCurrentPosition(a):c.play(),e.trigger("player:play",a),b.resolve()},this._fetch().done(function(){return d()}),b.promise()},a.prototype.pause=function(){return this.engine.pause(),this.trigger("player:pause"),this},a.prototype.stop=function(){return this.engine.stop(),this.trigger("player:stop"),this},a.prototype.replay=function(){return this.stop().play()},a.prototype.prev=function(){var a;return a=this.getCur(),this.getSongsNum()&&this.playlist.prev()?(this.trigger("player:prev",{cur:a}),this.play()):this.stop()},a.prototype.next=function(a){var b;return b=this.getCur(),this.getSongsNum()&&this.playlist.next()?(this.trigger("player:next",{auto:a,cur:b}),this.play()):this.stop()},a.prototype.getCur=function(){var a,b;return b=this.playlist,a=b.cur,!a&&this.getSongsNum()&&(a=b.list[0],b.setCur(a)),a+""},a.prototype.setCur=function(a){var b;return b=this.playlist,a?b.setCur(a):this.getSongsNum()&&b.setCur(b.list[0]),this},a.prototype.curPos=function(a){var b;return b=this.engine.getCurrentPosition()/1e3,a?i(b):b},a.prototype.duration=function(a){var b;return b=this.engine.getTotalTime()/1e3,a?i(b):b},a.prototype.add=function(a){return a&&this.playlist.add(a),this.trigger("player:add",a),this},a.prototype.remove=function(a){return a&&this.playlist.remove(a),this.getSongsNum()||this.reset(),this.trigger("player:remove",a),this},a.prototype.reset=function(){return this.playlist.reset(),this.engine.reset(),this.trigger("player:reset"),this},a.prototype.getState=function(){return this.engine.getState()},a.prototype.setUrl=function(a){return this.engine.setUrl(a),this},a.prototype.getUrl=function(){return this.engine.getUrl()},a.prototype.setVolume=function(a){return this.engine.setVolume(a)},a.prototype.getVolume=function(){return this.engine.getVolume()},a.prototype.setMute=function(a){return this.engine.setMute(a),this},a.prototype.getMute=function(){return this.engine.getMute()},a.prototype.canPlayType=function(a){return this.engine.canPlayType(a)},a.prototype.getSongsNum=function(){return this.playlist.list.length},a.prototype.setMode=function(a){return this.playlist.setMode(a),this},a.prototype.getMode=function(){return this.playlist.mode},a.prototype._fetch=function(){var a,b=this;return a=$.Deferred(),this.getUrl()===this.getCur()?a.resolve():setTimeout(function(){return b.setUrl(b.getCur()),a.resolve()},0),a.promise()},a}(),c.mixTo(g),g});