UNPKG

cplayer

Version:

A beautiful and clean WEB Music Player by HTML5.

2 lines 28.8 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("cplayer-umd",[],t):"object"==typeof exports?exports["cplayer-umd"]=t():e["cplayer-umd"]=t()}(window,(function(){return function(e){var t={};function n(i){if(t[i])return t[i].exports;var o=t[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(i,o,function(t){return e[t]}.bind(null,o));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}Object.defineProperty(t,"__esModule",{value:!0});var r=n(8);function a(e,t,n,i){var o,a=!1;return t.forEach((function(t,n){r.default(t,e)&&(o=n)})),void 0!==o&&(t.splice(o,1),n>o?(n--,a=!1):n===o&&(n=i(n),a=!0)),{playlist:t,nowpoint:n,needupdate:a}}t.baseRemoveMusic=a;var s=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;i(this,e),this.__playlist=[],this.point=0,this.__playlist=t,this.to(n)}var t,n,r;return t=e,(n=[{key:"next",value:function(){return this.point=this.nextPoint(),this.playlist[this.point]}},{key:"prev",value:function(){return this.point=this.prevPoint(),this.playlist[this.point]}},{key:"now",value:function(){return this.playlist[this.point]}},{key:"nowpoint",value:function(){return this.point}},{key:"to",value:function(e){this.point=Math.max(0,Math.min(e,this.__playlist.length-1))}},{key:"addMusic",value:function(e){this.__playlist.push(e)}},{key:"nextPoint",value:function(){var e=this.point+1;return e>=this.__playlist.length&&(e=0),e}},{key:"prevPoint",value:function(){var e=this.point-1;return e<0&&(e=this.__playlist.length-1),e}},{key:"removeMusic",value:function(e){var t=this,n=a(e,this.__playlist,this.point,(function(e){return Math.max(0,Math.min(e,t.__playlist.length-1))})),i=n.playlist,o=n.nowpoint,r=n.needupdate;return this.__playlist=i,this.point=o,r}},{key:"playlist",get:function(){return this.__playlist}}])&&o(t.prototype,n),r&&o(t,r),e}();t.listloopPlaymode=s},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){e.exports=n(3)},function(e,t,n){"use strict";(function(e){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function r(e){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function a(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}Object.defineProperty(t,"__esModule",{value:!0}),n(7);var u=n(0),l=n(9),c=n(10),p=n(11),f=n(12),h=n(13);var d={playlist:[],point:0,volume:1,playmode:"listloop",autoplay:!1},y={listloop:u.listloopPlaymode,singlecycle:p.singlecyclePlaymode,listrandom:f.listrandomPlaymode};function m(e){return e.map((function(e,t){var n=Object.assign({},e);return"string"==typeof e.lyric&&e.lyric.replace(/\n+/gi,"\n").trim()&&(n.lyric=c.decodeLyricStr(e.lyric)),"string"==typeof e.sublyric&&e.sublyric.replace(/\n+/gi,"\n").trim()&&(n.sublyric=c.decodeLyricStr(e.sublyric)),n}))}var v=function(t){function n(t){var o;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),(o=function(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?a(e):t}(this,r(n).call(this))).__paused=!0,o.playmodeName="listloop",o._volume=0,o.eventHandlers={handlePlay:function(){o.__paused&&o.pause()},handlePlaying:function(){0===o.audioElement.currentTime&&o.emit("started")},handleTimeUpdate:function(){var e=o.audioElement.duration,t=o.audioElement.currentTime;o.emit("timeupdate",t,e)},handleCanPlayThrough:function(){for(var e,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];(e=o).emit.apply(e,["canplaythrough"].concat(n))},handlePause:function(){o.__paused||o.audioElement.ended||o.play(!0).catch((function(e){console.log(e),o.pause()}))},handleEnded:function(){for(var e,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];(e=o).emit.apply(e,["ended"].concat(n)),o.__paused||o.next()},handlePlayListChange:function(){for(var e,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];(e=o).emit.apply(e,["playlistchange"].concat(n))},handlePlaymodeChange:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:o.mode;o.emit("playmodechange",e)},handleLoadeddata:function(){var e=o.audioElement.duration,t=o.audioElement.currentTime;o.emit("timeupdate",t,e)}},t=Object.assign(Object.assign({},d),t),o.playmode=new y[t.playmode](m(t.playlist),t.point),h.cplayerMediaSessionPlugin(a(o)),e((function(){o.openAudio(),o.setVolume(t.volume),t.autoplay&&o.playlist.length>0&&o.play(!0).catch((function(e){console.log(e),o.pause()}))})),o}var u,l,c;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(n,t),u=n,(l=[{key:"initializeEventEmitter",value:function(e){var t=e.addEventListener.bind(e),n=this.eventHandlers;t("timeupdate",n.handleTimeUpdate),t("canplaythrough",n.handleCanPlayThrough),t("pause",n.handlePause),t("play",n.handlePlay),t("playing",n.handlePlaying),t("ended",n.handleEnded),t("loadeddata",n.handleLoadeddata)}},{key:"removeEventEmitter",value:function(e){var t=e.removeEventListener.bind(e),n=this.eventHandlers;t("timeupdate",n.handleTimeUpdate),t("canplaythrough",n.handleCanPlayThrough),t("pause",n.handlePause),t("play",n.handlePlay),t("playing",n.handlePlaying),t("ended",n.handleEnded),t("loadeddata",n.handleLoadeddata)}},{key:"setCurrentTime",value:function(e){if("string"==typeof e&&(e.trim(),"%"===e[e.length-1])){var t=parseFloat(e);e=this.duration*(t/100)}this.audioElement&&(this.audioElement.currentTime=parseFloat(e.toString()))}},{key:"isPlaying",value:function(){return!!this.audioElement&&this.audioElement.currentTime>0&&!this.audioElement.paused&&!this.audioElement.ended&&this.audioElement.readyState>2}},{key:"openAudio",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.nowplay;e&&("video"===e.type?"HTMLVideoElement"!==this.audioElementType&&(void 0!==this.audioElement&&(this.removeEventEmitter(this.audioElement),this.audioElement.src=""),this.audioElement=document.createElement("video"),this.audioElement instanceof HTMLVideoElement&&(this.audioElementType="HTMLVideoElement",this.audioElement.loop=!1,this.audioElement.autoplay=!1,this.audioElement.poster=e.poster,this.audioElement.setAttribute("playsinline","true"),this.audioElement.setAttribute("webkit-playsinline","true")),this.initializeEventEmitter(this.audioElement),this.emit("audioelementchange",this.audioElement)):"HTMLAudioElement"!==this.audioElementType&&(void 0!==this.audioElement&&(this.removeEventEmitter(this.audioElement),this.audioElement.src=""),this.audioElement=new Audio,this.audioElementType="HTMLAudioElement",this.audioElement.loop=!1,this.audioElement.autoplay=!1,this.initializeEventEmitter(this.audioElement),this.emit("audioelementchange",this.audioElement)),this.setVolume(this.volume),this.audioElement.src=this.nowplay.src,this.emit("openaudio",e),this.__paused||this.play())}},{key:"toggleMode",value:function(){switch(this.playmodeName){case"listloop":this.setMode("singlecycle");break;case"singlecycle":this.setMode("listrandom");break;case"listrandom":this.setMode("listloop")}}},{key:"setMode",value:function(e){"string"==typeof e&&this.playmodeName!==e&&y[e]&&(this.playmode=new y[e](this.playlist,this.nowplaypoint),this.playmodeName=e,this.eventHandlers.handlePlaymodeChange())}},{key:"getMode",value:function(){return this.mode}},{key:"play",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=this.isPlaying();return(!n&&this.playlist.length>0||t)&&(e=this.audioElement.play()),this.__paused&&(this.__paused=!1,this.emit("playstatechange",this.__paused),this.emit("play")),e}},{key:"pause",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.isPlaying();(t&&this.playlist.length>0||e)&&this.audioElement.pause(),this.__paused||(this.__paused=!0,this.emit("playstatechange",this.__paused),this.emit("pause"))}},{key:"to",value:function(e){this.playmode.to(e),this.openAudio()}},{key:"next",value:function(){this.playmode.next(),this.openAudio()}},{key:"prev",value:function(){this.playmode.prev(),this.openAudio()}},{key:"togglePlayState",value:function(){this.__paused?this.play():this.pause()}},{key:"add",value:function(e){e=m([e])[0],this.playmode.addMusic(e),this.eventHandlers.handlePlayListChange(),1===this.playlist.length&&this.to(0)}},{key:"remove",value:function(e){var t=this.playmode.removeMusic(e);this.eventHandlers.handlePlayListChange(),t&&this.openAudio()}},{key:"setVolume",value:function(e){this._volume=parseFloat(e),this.audioElement&&(this.audioElement.volume=Math.max(0,Math.min(1,this._volume))),this.emit("volumechange",this.volume)}},{key:"destroy",value:function(){var e=this;this.audioElement&&(this.audioElement.src=null,this.audioElement.removeEventListener("timeupdate",this.eventHandlers.handleTimeUpdate),this.removeAllListeners()),this.view&&this.view.destroy(),Object.getOwnPropertyNames(this).forEach((function(t){return delete e[t]})),this.__proto__=Object}},{key:"mode",set:function(e){this.setMode(e)},get:function(){return this.playmodeName}},{key:"volume",set:function(e){this.setVolume(e)},get:function(){return this._volume}},{key:"playlist",get:function(){return this.playmode.playlist}},{key:"nowplay",get:function(){return this.playmode&&this.playmode.now()}},{key:"nowplaypoint",get:function(){return this.playmode&&this.playmode.nowpoint()}},{key:"played",get:function(){return!this.__paused}},{key:"paused",get:function(){return this.__paused}},{key:"duration",get:function(){return this.audioElement?this.audioElement.duration:0}},{key:"currentTime",get:function(){return this.audioElement?this.audioElement.currentTime:0}}])&&o(u.prototype,l),c&&o(u,c),n}(l.EventEmitter);t.default=v,window.cplayer=v}).call(this,n(4).setImmediate)},function(e,t,n){(function(e){var i=void 0!==e&&e||"undefined"!=typeof self&&self||window,o=Function.prototype.apply;function r(e,t){this._id=e,this._clearFn=t}t.setTimeout=function(){return new r(o.call(setTimeout,i,arguments),clearTimeout)},t.setInterval=function(){return new r(o.call(setInterval,i,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},r.prototype.unref=r.prototype.ref=function(){},r.prototype.close=function(){this._clearFn.call(i,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout((function(){e._onTimeout&&e._onTimeout()}),t))},n(5),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,n(1))},function(e,t,n){(function(e,t){!function(e,n){"use strict";if(!e.setImmediate){var i,o,r,a,s,u=1,l={},c=!1,p=e.document,f=Object.getPrototypeOf&&Object.getPrototypeOf(e);f=f&&f.setTimeout?f:e,"[object process]"==={}.toString.call(e.process)?i=function(e){t.nextTick((function(){d(e)}))}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=n,t}}()?e.MessageChannel?((r=new MessageChannel).port1.onmessage=function(e){d(e.data)},i=function(e){r.port2.postMessage(e)}):p&&"onreadystatechange"in p.createElement("script")?(o=p.documentElement,i=function(e){var t=p.createElement("script");t.onreadystatechange=function(){d(e),t.onreadystatechange=null,o.removeChild(t),t=null},o.appendChild(t)}):i=function(e){setTimeout(d,0,e)}:(a="setImmediate$"+Math.random()+"$",s=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(a)&&d(+t.data.slice(a.length))},e.addEventListener?e.addEventListener("message",s,!1):e.attachEvent("onmessage",s),i=function(t){e.postMessage(a+t,"*")}),f.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),n=0;n<t.length;n++)t[n]=arguments[n+1];var o={callback:e,args:t};return l[u]=o,i(u),u++},f.clearImmediate=h}function h(e){delete l[e]}function d(e){if(c)setTimeout(d,0,e);else{var t=l[e];if(t){c=!0;try{!function(e){var t=e.callback,n=e.args;switch(n.length){case 0:t();break;case 1:t(n[0]);break;case 2:t(n[0],n[1]);break;case 3:t(n[0],n[1],n[2]);break;default:t.apply(void 0,n)}}(t)}finally{h(e),c=!1}}}}}("undefined"==typeof self?void 0===e?this:e:self)}).call(this,n(1),n(6))},function(e,t){var n,i,o=e.exports={};function r(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function s(e){if(n===setTimeout)return setTimeout(e,0);if((n===r||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:r}catch(e){n=r}try{i="function"==typeof clearTimeout?clearTimeout:a}catch(e){i=a}}();var u,l=[],c=!1,p=-1;function f(){c&&u&&(c=!1,u.length?l=u.concat(l):p=-1,l.length&&h())}function h(){if(!c){var e=s(f);c=!0;for(var t=l.length;t;){for(u=l,l=[];++p<t;)u&&u[p].run();p=-1,t=l.length}u=null,c=!1,function(e){if(i===clearTimeout)return clearTimeout(e);if((i===a||!i)&&clearTimeout)return i=clearTimeout,clearTimeout(e);try{i(e)}catch(t){try{return i.call(null,e)}catch(t){return i.call(this,e)}}}(e)}}function d(e,t){this.fun=e,this.array=t}function y(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];l.push(new d(e,t)),1!==l.length||c||s(h)},d.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=y,o.addListener=y,o.once=y,o.off=y,o.removeListener=y,o.removeAllListeners=y,o.emit=y,o.prependListener=y,o.prependOnceListener=y,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t){"function"!=typeof Object.assign&&Object.defineProperty(Object,"assign",{value:function(e,t){"use strict";if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var n=Object(e),i=1;i<arguments.length;i++){var o=arguments[i];if(null!=o)for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(n[r]=o[r])}return n},writable:!0,configurable:!0})},function(e,t,n){"use strict";function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0});var o=Object.prototype.hasOwnProperty;function r(e,t){return e==t?0!=e||0!=t||1/e==1/t:e!=e&&t!=t}t.default=function(e,t){if(r(e,t))return!0;if("object"!==i(e)||null===e||"object"!==i(t)||null===t)return!1;var n=Object.keys(e),a=Object.keys(t);if(n.length!==a.length)return!1;for(var s=0;s<n.length;s++)if(!o.call(t,n[s])||!r(e[n[s]],t[n[s]]))return!1;return!0}},function(e,t,n){"use strict";var i,o="object"==typeof Reflect?Reflect:null,r=o&&"function"==typeof o.apply?o.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};i=o&&"function"==typeof o.ownKeys?o.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var a=Number.isNaN||function(e){return e!=e};function s(){s.init.call(this)}e.exports=s,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var u=10;function l(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function c(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function p(e,t,n,i){var o,r,a,s;if(l(n),void 0===(r=e._events)?(r=e._events=Object.create(null),e._eventsCount=0):(void 0!==r.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),r=e._events),a=r[t]),void 0===a)a=r[t]=n,++e._eventsCount;else if("function"==typeof a?a=r[t]=i?[n,a]:[a,n]:i?a.unshift(n):a.push(n),(o=c(e))>0&&a.length>o&&!a.warned){a.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=a.length,s=u,console&&console.warn&&console.warn(s)}return e}function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(e,t,n){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},o=f.bind(i);return o.listener=n,i.wrapFn=o,o}function d(e,t,n){var i=e._events;if(void 0===i)return[];var o=i[t];return void 0===o?[]:"function"==typeof o?n?[o.listener||o]:[o]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(o):m(o,o.length)}function y(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function m(e,t){for(var n=new Array(t),i=0;i<t;++i)n[i]=e[i];return n}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return u},set:function(e){if("number"!=typeof e||e<0||a(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");u=e}}),s.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||a(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},s.prototype.getMaxListeners=function(){return c(this)},s.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var i="error"===e,o=this._events;if(void 0!==o)i=i&&void 0===o.error;else if(!i)return!1;if(i){var a;if(t.length>0&&(a=t[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var u=o[e];if(void 0===u)return!1;if("function"==typeof u)r(u,this,t);else{var l=u.length,c=m(u,l);for(n=0;n<l;++n)r(c[n],this,t)}return!0},s.prototype.addListener=function(e,t){return p(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return p(this,e,t,!0)},s.prototype.once=function(e,t){return l(t),this.on(e,h(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){return l(t),this.prependListener(e,h(this,e,t)),this},s.prototype.removeListener=function(e,t){var n,i,o,r,a;if(l(t),void 0===(i=this._events))return this;if(void 0===(n=i[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(o=-1,r=n.length-1;r>=0;r--)if(n[r]===t||n[r].listener===t){a=n[r].listener,o=r;break}if(o<0)return this;0===o?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,o),1===n.length&&(i[e]=n[0]),void 0!==i.removeListener&&this.emit("removeListener",e,a||t)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(e){var t,n,i;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var o,r=Object.keys(n);for(i=0;i<r.length;++i)"removeListener"!==(o=r[i])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},s.prototype.listeners=function(e){return d(this,e,!0)},s.prototype.rawListeners=function(e){return d(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):y.call(e,t)},s.prototype.listenerCount=y,s.prototype.eventNames=function(){return this._eventsCount>0?i(this._events):[]}},function(e,t,n){"use strict";function i(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.items=[],this.items=t,this.raw=n}var t,n,i;return t=e,(n=[{key:"getLyric",value:function(e){return this.items.reduce((function(t,n){return n.time<e&&(!t||t.time<n.time)?n:t}),void 0)}},{key:"getNextLyric",value:function(e){return this.items.reduce((function(t,n){return n.time>e&&(!t||t.time>n.time)?n:t}),void 0)}},{key:"toString",value:function(){return this.raw}}])&&o(t.prototype,n),i&&o(t,i),e}();function a(e){var t=[],n=e.match(/\[\d+\:[\.\d]+\]/gi),i=/(?:\[\d+\:[\.\d]+\])*(.*)/gi.exec(e)[1].trim();return n&&i&&n.forEach((function(e){var n=/\[(\d+)\:([\.\d]+)\]/gi.exec(e.trim()),o=60*parseInt(n[1])*1e3+1e3*parseFloat(n[2]);t.push({time:o,word:i})})),t}t.Lyric=r,t.decodeLyricStr=function(e,t){if("string"!=typeof e)return e;var n=[];return e.replace(/\n+/gi,"\n").trim().split("\n").forEach((function(e){n.push.apply(n,i(a(e)))})),0!=n.length?new r(n,e):void 0},t.decodeLyricStrItem=a},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),a=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;i(this,e),this.__playlist=[],this.__playlist=t,this.to(n)}var t,n,a;return t=e,(n=[{key:"next",value:function(){return this.__playlist[this.point]}},{key:"prev",value:function(){return this.__playlist[this.point]}},{key:"now",value:function(){return this.__playlist[this.point]}},{key:"nowpoint",value:function(){return this.point}},{key:"to",value:function(e){this.point=Math.max(0,Math.min(e,this.__playlist.length-1))}},{key:"addMusic",value:function(e){this.__playlist.push(e)}},{key:"removeMusic",value:function(e){var t=this,n=r.baseRemoveMusic(e,this.__playlist,this.point,(function(e){return Math.max(0,Math.min(e,t.__playlist.length-1))})),i=n.playlist,o=n.nowpoint,a=n.needupdate;return this.__playlist=i,this.point=o,a}},{key:"playlist",get:function(){return this.__playlist}}])&&o(t.prototype,n),a&&o(t,a),e}();t.singlecyclePlaymode=a},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),a=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;i(this,e),this.__playlist=[],this.point=0,this.__playlist=t,this.to(n)}var t,n,a;return t=e,(n=[{key:"next",value:function(){return this.point=this.randomPoint(),this.__playlist[this.point]}},{key:"prev",value:function(){return this.point=this.randomPoint(),this.__playlist[this.point]}},{key:"now",value:function(){return this.__playlist[this.point]}},{key:"nowpoint",value:function(){return this.point}},{key:"to",value:function(e){this.point=Math.max(0,Math.min(e,this.__playlist.length-1))}},{key:"addMusic",value:function(e){this.__playlist.push(e)}},{key:"randomPoint",value:function(){if(this.__playlist.length>1){var e=Math.floor(this.__playlist.length*Math.random());return e===this.point?this.randomPoint():e}return 0}},{key:"removeMusic",value:function(e){var t=this,n=r.baseRemoveMusic(e,this.__playlist,this.point,(function(e){return t.randomPoint()})),i=n.playlist,o=n.nowpoint,a=n.needupdate;return this.__playlist=i,this.point=o,a}},{key:"playlist",get:function(){return this.__playlist}}])&&o(t.prototype,n),a&&o(t,a),e}();t.listrandomPlaymode=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(14);function o(e){return new MediaMetadata({title:e.name,artist:e.artist,album:e.album,artwork:[{sizes:"720x720",src:e.poster||i}]})}t.cplayerMediaSessionPlugin=function(e){"mediaSession"in navigator&&(e.nowplay&&(navigator.mediaSession.metadata=o(e.nowplay)),navigator.mediaSession.setActionHandler("play",(function(){return e.play()})),navigator.mediaSession.setActionHandler("pause",(function(){return e.pause()})),navigator.mediaSession.setActionHandler("previoustrack",(function(){return e.prev()})),navigator.mediaSession.setActionHandler("nexttrack",(function(){return e.next()})),e.on("openaudio",(function(){navigator.mediaSession.metadata=o(e.nowplay)})))},t.mediaMetadata=o},function(e,t){e.exports="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAAiACIDASIAAhEBAxEB/8QAGQAAAgMBAAAAAAAAAAAAAAAAAAcDBAUG/8QALhAAAgEDAwIFAwMFAAAAAAAAAQIDAAQRBRIhE0EGIjFRkRQzYTI1cXOBocHR/8QAGAEAAwEBAAAAAAAAAAAAAAAAAQIDBAX/xAAiEQACAQMCBwAAAAAAAAAAAAAAAQIDETESFAQhIkFRYWL/2gAMAwEAAhEDEQA/AGBo7mOKMEBjgc4rqLaRWXG1fgUttA1qNbnpPdGV5mIRRhkiKgeTjkE5J5/1W9pniH6jVbuPdiO2gJwHG13B5wcc44+a5tPpNM4N3OwlC45RfgVlXMA2t5E/nFVZ/EEaWVlcmJmjuDHnDAdIP6MR3GSBx71Fe37LbSSKylVIyNwyM002IotGc2N7cr6+1FYTXu5iepKcnP66KzF9AoBfQ2LmzgWWJp3L72A8rNt2kY5x/wBrtfD+oSXkQ6k8iQSRuJVjwr78DcATx6YyfYehNcbsttTkayGoiGcPuh3REo2FG0bt2R6e3fvVW2vulYSSMPND9vk46jcA/Ab/ABXTlBSXsCnpvfAydb8TR3eg7bMrGrStB1c8r0wTsP4PDKe/OeRUXiPxFLBojump6fFcTtGFeCTDHaoJyMe5A70uYte+n097Z7eK6EjA4mJCptXAK7SOcE1S1a9jvbqNoYzFCkSIiFtxGBzk9znvQXD81cV1kkMSAWDQRt9bMuVB272OOPTOKKVu4+5+aKO2+gbleC5bfusf9U1ctlB1RYiAYy/Kn0P9qKKtLIkMGfeKBdkAADjgVFcffYdgcD8UUU6JPuR0UUURT//Z"}])})); //# sourceMappingURL=cplayer-noview.js.map