diff --git a/Action.php b/Action.php index d90109d..12c666c 100644 --- a/Action.php +++ b/Action.php @@ -71,11 +71,11 @@ private function api() } // auth 验证 - $EID = $server.'/'.$type.'/'.$id; + $EID = $server.$type.$id; $salt = Typecho_Widget::widget('Widget_Options')->plugin('Meting')->salt; - if (!empty($salt) && in_array($type, array('lrc','pic','url'))) { - $auth1 = md5($salt.$type.$id.$salt); + if (!empty($salt)) { + $auth1 = md5($salt.$EID.$salt); $auth2 = $this->request->get('auth'); if (strcmp($auth1, $auth2)) { http_response_code(403); @@ -129,6 +129,10 @@ private function api() $url = str_replace('http://m10.', 'https://m10.', $url); } + if ($server == 'xiami') { + $url = str_replace('http://', 'https://', $url); + } + if ($server == 'baidu') { $url = str_replace('http://zhangmenshiting.qianqian.com', 'https://gss3.baidu.com/y0s1hSulBw92lNKgpU_Z2jR7b2w6buu', $url); } @@ -155,11 +159,11 @@ private function api() $music = array(); foreach ($data as $vo) { $music[] = array( - 'title' => $vo['name'], - 'author' => implode(' / ', $vo['artist']), - 'url' => $url.'?server='.$vo['source'].'&type=url&id='.$vo['url_id'].'&auth='.md5($salt.'url'.$vo['url_id'].$salt), - 'pic' => $url.'?server='.$vo['source'].'&type=pic&id='.$vo['pic_id'].'&auth='.md5($salt.'pic'.$vo['pic_id'].$salt), - 'lrc' => $url.'?server='.$vo['source'].'&type=lrc&id='.$vo['lyric_id'].'&auth='.md5($salt.'lrc'.$vo['lyric_id'].$salt), + 'name' => $vo['name'], + 'artist' => implode(' / ', $vo['artist']), + 'url' => $url.'?server='.$vo['source'].'&type=url&id='.$vo['url_id'].'&auth='.md5($salt.$vo['source'].'url'.$vo['url_id'].$salt), + 'cover' => $url.'?server='.$vo['source'].'&type=pic&id='.$vo['pic_id'].'&auth='.md5($salt.$vo['source'].'pic'.$vo['pic_id'].$salt), + 'lrc' => $url.'?server='.$vo['source'].'&type=lrc&id='.$vo['lyric_id'].'&auth='.md5($salt.$vo['source'].'lrc'.$vo['lyric_id'].$salt), ); } header("Content-Type: application/javascript"); diff --git a/Plugin.php b/Plugin.php index e6e100f..7ffb01f 100644 --- a/Plugin.php +++ b/Plugin.php @@ -8,13 +8,13 @@ * * @package APlayer for Typecho | Meting * @author METO - * @version 2.1.1 + * @version 2.1.2 * @dependence 14.10.10-* * @link https://github.com/MoePlayer/APlayer-Typecho * */ -define('METING_VERSION', '2.1.1'); +define('METING_VERSION', '2.1.2'); class Meting_Plugin extends Typecho_Widget implements Typecho_Plugin_Interface { @@ -84,9 +84,9 @@ public static function config(Typecho_Widget_Helper_Form $form) ); $form->addInput($t); $t = new Typecho_Widget_Helper_Form_Element_Radio( - 'mode', - array('circulation' => _t('循环'),'single' => _t('单曲'),'order' => _t('列表'),'random' => _t('随机')), - 'circulation', + 'order', + array('list' => _t('列表'), 'random' => _t('随机')), + 'list', _t('全局播放模式'), _t('') ); @@ -143,7 +143,7 @@ public static function config(Typecho_Widget_Helper_Form $form) $t = new Typecho_Widget_Helper_Form_Element_Text( 'api', null, - Typecho_Common::url('action/metingapi', Helper::options()->index)."?server=:server&type=:type&id=:id&r=:r", + Typecho_Common::url('action/metingapi', Helper::options()->index)."?server=:server&type=:type&id=:id&auth=:auth&r=:r", _t('* 云解析地址'), _t('示例:https://api.i-meto.com/meting/api?server=:server&type=:type&id=:id&r=:r') ); @@ -177,7 +177,7 @@ public static function configHandle($config, $is_init) { if (!$is_init) { if (empty($config['api'])) { - $config['api'] = Typecho_Common::url('action/metingapi', Helper::options()->index)."?server=:server&type=:type&id=:id&r=:r"; + $config['api'] = Typecho_Common::url('action/metingapi', Helper::options()->index)."?server=:server&type=:type&id=:id&auth=:auth&r=:r"; } if ($config['cachetype'] != 'none') { require_once 'driver/cache.interface.php'; @@ -215,6 +215,7 @@ public static function header() $api = Typecho_Widget::widget('Widget_Options')->plugin('Meting')->api; $dir = Helper::options()->pluginUrl.'/Meting/assets'; $ver = METING_VERSION; + echo "\n"; echo "\n"; echo ""; } @@ -258,8 +259,8 @@ public static function parseMusic($matches, $setting) 'theme' => Typecho_Widget::widget('Widget_Options')->plugin('Meting')->theme?:'red', 'preload' => Typecho_Widget::widget('Widget_Options')->plugin('Meting')->preload?:'auto', 'autoplay' => Typecho_Widget::widget('Widget_Options')->plugin('Meting')->autoplay?:'false', - 'listmaxheight' => Typecho_Widget::widget('Widget_Options')->plugin('Meting')->height?:'340px', - 'mode' => Typecho_Widget::widget('Widget_Options')->plugin('Meting')->mode?:'circulation', + 'listMaxHeight' => Typecho_Widget::widget('Widget_Options')->plugin('Meting')->height?:'340px', + 'order' => Typecho_Widget::widget('Widget_Options')->plugin('Meting')->order?:'list', ); if (isset($t['server'])) { if (!in_array($t['server'], array('netease','tencent','xiami','baidu','kugou'))) { @@ -270,7 +271,10 @@ public static function parseMusic($matches, $setting) } $data = $t; - $str .= "
';\n $$out += $escape($value[1]);\n $$out += '
\\n';\n });\n return $$out;\n};\n\n/***/ }),\n/* 32 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, '__esModule', { value: true });\nvar _createClass = function () {\n function defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if ('value' in descriptor)\n descriptor.writable = true;\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n }\n return function (Constructor, protoProps, staticProps) {\n if (protoProps)\n defineProperties(Constructor.prototype, protoProps);\n if (staticProps)\n defineProperties(Constructor, staticProps);\n return Constructor;\n };\n}();\nvar _utils = __webpack_require__(0);\nvar _utils2 = _interopRequireDefault(_utils);\nvar _icons = __webpack_require__(2);\nvar _icons2 = _interopRequireDefault(_icons);\nfunction _interopRequireDefault(obj) {\n return obj && obj.__esModule ? obj : { default: obj };\n}\nfunction _classCallCheck(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError('Cannot call a class as a function');\n }\n}\nvar Controller = function () {\n function Controller(player) {\n _classCallCheck(this, Controller);\n this.player = player;\n this.initPlayButton();\n this.initList();\n this.initPlayBar();\n if (this.player.isMultiple()) {\n this.initOrderButton();\n }\n this.initLoopButton();\n this.initMenuButton();\n if (!_utils2.default.isMobile) {\n this.initVolumeButton();\n }\n }\n _createClass(Controller, [\n {\n key: 'initPlayButton',\n value: function initPlayButton() {\n var _this = this;\n this.player.template.pic.addEventListener('click', function () {\n _this.player.toggle();\n });\n }\n },\n {\n key: 'initList',\n value: function initList() {\n var _this2 = this;\n this.player.template.list.addEventListener('click', function (e) {\n var target = void 0;\n if (e.target.tagName.toUpperCase() === 'LI') {\n target = e.target;\n } else {\n target = e.target.parentElement;\n }\n var audioIndex = parseInt(target.getElementsByClassName('aplayer-list-index')[0].innerHTML) - 1;\n if (audioIndex !== _this2.player.playIndex) {\n _this2.player.switchAudio(audioIndex);\n _this2.player.play();\n } else {\n _this2.player.toggle();\n }\n });\n }\n },\n {\n key: 'initPlayBar',\n value: function initPlayBar() {\n var _this3 = this;\n var thumbMove = function thumbMove(e) {\n var percentage = ((e.clientX || e.changedTouches[0].clientX) - _utils2.default.getElementViewLeft(_this3.player.template.barWrap)) / _this3.player.template.barWrap.clientWidth;\n percentage = Math.max(percentage, 0);\n percentage = Math.min(percentage, 1);\n _this3.player.bar.set('played', percentage, 'width');\n _this3.player.lrc && _this3.player.lrc.update(percentage * _this3.player.audio.duration);\n _this3.player.template.ptime.innerHTML = _utils2.default.secondToTime(percentage * _this3.player.audio.duration);\n };\n var thumbUp = function thumbUp(e) {\n document.removeEventListener(_utils2.default.nameMap.dragEnd, thumbUp);\n document.removeEventListener(_utils2.default.nameMap.dragMove, thumbMove);\n var percentage = ((e.clientX || e.changedTouches[0].clientX) - _utils2.default.getElementViewLeft(_this3.player.template.barWrap)) / _this3.player.template.barWrap.clientWidth;\n percentage = Math.max(percentage, 0);\n percentage = Math.min(percentage, 1);\n _this3.player.bar.set('played', percentage, 'width');\n _this3.player.seek(_this3.player.bar.get('played', 'width') * _this3.player.audio.duration);\n _this3.player.timer.enable('progress');\n };\n this.player.template.barWrap.addEventListener(_utils2.default.nameMap.dragStart, function () {\n _this3.player.timer.disable('progress');\n document.addEventListener(_utils2.default.nameMap.dragMove, thumbMove);\n document.addEventListener(_utils2.default.nameMap.dragEnd, thumbUp);\n });\n }\n },\n {\n key: 'initVolumeButton',\n value: function initVolumeButton() {\n var _this4 = this;\n this.player.template.volumeButton.addEventListener('click', function () {\n if (_this4.player.audio.muted) {\n _this4.player.audio.muted = false;\n _this4.player.switchVolumeIcon();\n _this4.player.bar.set('volume', _this4.player.volume(), 'height');\n } else {\n _this4.player.audio.muted = true;\n _this4.player.switchVolumeIcon();\n _this4.player.bar.set('volume', 0, 'height');\n }\n });\n var thumbMove = function thumbMove(e) {\n var percentage = 1 - ((e.clientY || e.changedTouches[0].clientY) - _utils2.default.getElementViewTop(_this4.player.template.volumeBar)) / _this4.player.template.volumeBar.clientHeight;\n percentage = Math.max(percentage, 0);\n percentage = Math.min(percentage, 1);\n _this4.player.volume(percentage);\n };\n var thumbUp = function thumbUp(e) {\n _this4.player.template.volumeBarWrap.classList.remove('aplayer-volume-bar-wrap-active');\n document.removeEventListener(_utils2.default.nameMap.dragEnd, thumbUp);\n document.removeEventListener(_utils2.default.nameMap.dragMove, thumbMove);\n var percentage = 1 - ((e.clientY || e.changedTouches[0].clientY) - _utils2.default.getElementViewTop(_this4.player.template.volumeBar)) / _this4.player.template.volumeBar.clientHeight;\n percentage = Math.max(percentage, 0);\n percentage = Math.min(percentage, 1);\n _this4.player.volume(percentage);\n };\n this.player.template.volumeBarWrap.addEventListener(_utils2.default.nameMap.dragStart, function () {\n _this4.player.template.volumeBarWrap.classList.add('aplayer-volume-bar-wrap-active');\n document.addEventListener(_utils2.default.nameMap.dragMove, thumbMove);\n document.addEventListener(_utils2.default.nameMap.dragEnd, thumbUp);\n });\n }\n },\n {\n key: 'initOrderButton',\n value: function initOrderButton() {\n var _this5 = this;\n this.player.template.order.addEventListener('click', function () {\n if (_this5.player.options.order === 'list') {\n _this5.player.options.order = 'random';\n _this5.player.template.order.innerHTML = _icons2.default.orderRandom;\n } else if (_this5.player.options.order === 'random') {\n _this5.player.options.order = 'list';\n _this5.player.template.order.innerHTML = _icons2.default.orderList;\n }\n });\n }\n },\n {\n key: 'initLoopButton',\n value: function initLoopButton() {\n var _this6 = this;\n this.player.template.loop.addEventListener('click', function () {\n if (_this6.player.isMultiple()) {\n if (_this6.player.options.loop === 'one') {\n _this6.player.options.loop = 'none';\n _this6.player.template.loop.innerHTML = _icons2.default.loopNone;\n } else if (_this6.player.options.loop === 'none') {\n _this6.player.options.loop = 'all';\n _this6.player.template.loop.innerHTML = _icons2.default.loopAll;\n } else if (_this6.player.options.loop === 'all') {\n _this6.player.options.loop = 'one';\n _this6.player.template.loop.innerHTML = _icons2.default.loopOne;\n }\n } else {\n if (_this6.player.options.loop === 'one' || _this6.player.options.loop === 'all') {\n _this6.player.options.loop = 'none';\n _this6.player.template.loop.innerHTML = _icons2.default.loopNone;\n } else if (_this6.player.options.loop === 'none') {\n _this6.player.options.loop = 'all';\n _this6.player.template.loop.innerHTML = _icons2.default.loopAll;\n }\n }\n });\n }\n },\n {\n key: 'initMenuButton',\n value: function initMenuButton() {\n var _this7 = this;\n this.player.template.list.style.height = 33 * this.player.options.audio.length - 1 + 'px';\n this.player.template.menu.addEventListener('click', function () {\n if (!_this7.player.template.list.classList.contains('aplayer-list-hide')) {\n _this7.player.template.list.classList.add('aplayer-list-hide');\n } else {\n _this7.player.template.list.classList.remove('aplayer-list-hide');\n }\n });\n }\n }\n ]);\n return Controller;\n}();\nexports.default = Controller;\n\n/***/ }),\n/* 33 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, '__esModule', { value: true });\nvar _createClass = function () {\n function defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if ('value' in descriptor)\n descriptor.writable = true;\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n }\n return function (Constructor, protoProps, staticProps) {\n if (protoProps)\n defineProperties(Constructor.prototype, protoProps);\n if (staticProps)\n defineProperties(Constructor, staticProps);\n return Constructor;\n };\n}();\nvar _utils = __webpack_require__(0);\nvar _utils2 = _interopRequireDefault(_utils);\nfunction _interopRequireDefault(obj) {\n return obj && obj.__esModule ? obj : { default: obj };\n}\nfunction _classCallCheck(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError('Cannot call a class as a function');\n }\n}\nvar Timer = function () {\n function Timer(player) {\n _classCallCheck(this, Timer);\n this.player = player;\n window.requestAnimationFrame = function () {\n return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (callback) {\n window.setTimeout(callback, 1000 / 60);\n };\n }();\n this.types = [\n 'loading',\n 'progress'\n ];\n this.init();\n }\n _createClass(Timer, [\n {\n key: 'init',\n value: function init() {\n var _this = this;\n this.types.map(function (item) {\n _this['init' + item + 'Checker']();\n return item;\n });\n }\n },\n {\n key: 'initprogressChecker',\n value: function initprogressChecker() {\n var _this2 = this;\n this.progressChecker = setInterval(function () {\n if (_this2.enableprogressChecker) {\n _this2.player.bar.set('played', _this2.player.audio.currentTime / _this2.player.audio.duration, 'width');\n _this2.player.lrc && _this2.player.lrc.update();\n var currentTime = _utils2.default.secondToTime(_this2.player.audio.currentTime);\n if (_this2.player.template.ptime.innerHTML !== currentTime) {\n _this2.player.template.ptime.innerHTML = currentTime;\n }\n }\n }, 100);\n }\n },\n {\n key: 'initloadingChecker',\n value: function initloadingChecker() {\n var _this3 = this;\n var lastPlayPos = 0;\n var currentPlayPos = 0;\n var bufferingDetected = false;\n this.loadingChecker = setInterval(function () {\n if (_this3.enableloadingChecker) {\n currentPlayPos = _this3.player.audio.currentTime;\n if (!bufferingDetected && currentPlayPos === lastPlayPos && !_this3.player.audio.paused) {\n _this3.player.container.classList.add('aplayer-loading');\n bufferingDetected = true;\n }\n if (bufferingDetected && currentPlayPos > lastPlayPos && !_this3.player.audio.paused) {\n _this3.player.container.classList.remove('aplayer-loading');\n bufferingDetected = false;\n }\n lastPlayPos = currentPlayPos;\n }\n }, 100);\n }\n },\n {\n key: 'enable',\n value: function enable(type) {\n this['enable' + type + 'Checker'] = true;\n if (type === 'fps') {\n this.initfpsChecker();\n }\n }\n },\n {\n key: 'disable',\n value: function disable(type) {\n this['enable' + type + 'Checker'] = false;\n }\n },\n {\n key: 'destroy',\n value: function destroy() {\n var _this4 = this;\n this.types.map(function (item) {\n _this4['enable' + item + 'Checker'] = false;\n _this4[item + 'Checker'] && clearInterval(_this4[item + 'Checker']);\n return item;\n });\n }\n }\n ]);\n return Timer;\n}();\nexports.default = Timer;\n\n/***/ }),\n/* 34 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, '__esModule', { value: true });\nvar _createClass = function () {\n function defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if ('value' in descriptor)\n descriptor.writable = true;\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n }\n return function (Constructor, protoProps, staticProps) {\n if (protoProps)\n defineProperties(Constructor.prototype, protoProps);\n if (staticProps)\n defineProperties(Constructor, staticProps);\n return Constructor;\n };\n}();\nfunction _classCallCheck(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError('Cannot call a class as a function');\n }\n}\nvar Events = function () {\n function Events() {\n _classCallCheck(this, Events);\n this.events = {};\n this.audioEvents = [\n 'abort',\n 'canplay',\n 'canplaythrough',\n 'durationchange',\n 'emptied',\n 'ended',\n 'error',\n 'loadeddata',\n 'loadedmetadata',\n 'loadstart',\n 'mozaudioavailable',\n 'pause',\n 'play',\n 'playing',\n 'progress',\n 'ratechange',\n 'seeked',\n 'seeking',\n 'stalled',\n 'suspend',\n 'timeupdate',\n 'volumechange',\n 'waiting'\n ];\n this.playerEvents = [\n 'destroy',\n 'switchaudio',\n 'addaudio',\n 'removeaudio'\n ];\n }\n _createClass(Events, [\n {\n key: 'on',\n value: function on(name, callback) {\n if (this.type(name) && typeof callback === 'function') {\n if (!this.events[name]) {\n this.events[name] = [];\n }\n this.events[name].push(callback);\n }\n }\n },\n {\n key: 'trigger',\n value: function trigger(name, info) {\n if (this.events[name] && this.events[name].length) {\n for (var i = 0; i < this.events[name].length; i++) {\n this.events[name][i](info);\n }\n }\n }\n },\n {\n key: 'type',\n value: function type(name) {\n if (this.playerEvents.indexOf(name) !== -1) {\n return 'player';\n } else if (this.audioEvents.indexOf(name) !== -1) {\n return 'audio';\n }\n console.error('Unknown event name: ' + name);\n return null;\n }\n }\n ]);\n return Events;\n}();\nexports.default = Events;\n\n/***/ })\n/******/ ])[\"default\"];\n});\n\n\n// WEBPACK FOOTER //\n// APlayer.min.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"/\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 4);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap e40d0520cf9b07d68ca4","'use strict';\nObject.defineProperty(exports, '__esModule', { value: true });\nfunction _toConsumableArray(arr) {\n if (Array.isArray(arr)) {\n for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {\n arr2[i] = arr[i];\n }\n return arr2;\n } else {\n return Array.from(arr);\n }\n}\nvar isMobile = /mobile/i.test(window.navigator.userAgent);\nvar utils = {\n secondToTime: function secondToTime(second) {\n var add0 = function add0(num) {\n return num < 10 ? '0' + num : '' + num;\n };\n var hour = Math.floor(second / 3600);\n var min = Math.floor((second - hour * 3600) / 60);\n var sec = Math.floor(second - hour * 3600 - min * 60);\n return (hour > 0 ? [\n hour,\n min,\n sec\n ] : [\n min,\n sec\n ]).map(add0).join(':');\n },\n getElementViewLeft: function getElementViewLeft(element) {\n var actualLeft = element.offsetLeft;\n var current = element.offsetParent;\n var elementScrollLeft = document.body.scrollLeft + document.documentElement.scrollLeft;\n if (!document.fullscreenElement && !document.mozFullScreenElement && !document.webkitFullscreenElement) {\n while (current !== null) {\n actualLeft += current.offsetLeft;\n current = current.offsetParent;\n }\n } else {\n while (current !== null && current !== element) {\n actualLeft += current.offsetLeft;\n current = current.offsetParent;\n }\n }\n return actualLeft - elementScrollLeft;\n },\n getElementViewTop: function getElementViewTop(element) {\n var actualTop = element.offsetTop;\n var current = element.offsetParent;\n var elementScrollTop = 0;\n while (current !== null) {\n actualTop += current.offsetTop;\n current = current.offsetParent;\n }\n elementScrollTop = document.body.scrollTop + document.documentElement.scrollTop;\n return actualTop - elementScrollTop;\n },\n isMobile: isMobile,\n storage: {\n set: function set(key, value) {\n localStorage.setItem(key, value);\n },\n get: function get(key) {\n return localStorage.getItem(key);\n }\n },\n nameMap: {\n dragStart: isMobile ? 'touchstart' : 'mousedown',\n dragMove: isMobile ? 'touchmove' : 'mousemove',\n dragEnd: isMobile ? 'touchend' : 'mouseup'\n },\n randomOrder: function randomOrder() {\n var length = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined.options.audio.length;\n function shuffle(arr) {\n for (var i = arr.length - 1; i >= 0; i--) {\n var randomIndex = Math.floor(Math.random() * (i + 1));\n var itemAtIndex = arr[randomIndex];\n arr[randomIndex] = arr[i];\n arr[i] = itemAtIndex;\n }\n return arr;\n }\n return shuffle([].concat(_toConsumableArray(Array(length))).map(function (item, i) {\n return i;\n }));\n }\n};\nexports.default = utils;\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/js/utils.js\n// module id = 0\n// module chunks = 0","'use strict';\nvar _typeof = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ? function (obj) {\n return typeof obj;\n} : function (obj) {\n return obj && typeof Symbol === 'function' && obj.constructor === Symbol && obj !== Symbol.prototype ? 'symbol' : typeof obj;\n};\nvar g;\ng = function () {\n return this;\n}();\ntry {\n g = g || Function('return this')() || (1, eval)('this');\n} catch (e) {\n if ((typeof window === 'undefined' ? 'undefined' : _typeof(window)) === 'object')\n g = window;\n}\nmodule.exports = g;\n\n\n//////////////////\n// WEBPACK FOOTER\n// (webpack)/buildin/global.js\n// module id = 1\n// module chunks = 0","'use strict';\nObject.defineProperty(exports, '__esModule', { value: true });\nvar _play = require('../assets/play.svg');\nvar _play2 = _interopRequireDefault(_play);\nvar _pause = require('../assets/pause.svg');\nvar _pause2 = _interopRequireDefault(_pause);\nvar _volumeUp = require('../assets/volume-up.svg');\nvar _volumeUp2 = _interopRequireDefault(_volumeUp);\nvar _volumeDown = require('../assets/volume-down.svg');\nvar _volumeDown2 = _interopRequireDefault(_volumeDown);\nvar _volumeOff = require('../assets/volume-off.svg');\nvar _volumeOff2 = _interopRequireDefault(_volumeOff);\nvar _orderRandom = require('../assets/order-random.svg');\nvar _orderRandom2 = _interopRequireDefault(_orderRandom);\nvar _orderList = require('../assets/order-list.svg');\nvar _orderList2 = _interopRequireDefault(_orderList);\nvar _menu = require('../assets/menu.svg');\nvar _menu2 = _interopRequireDefault(_menu);\nvar _loopAll = require('../assets/loop-all.svg');\nvar _loopAll2 = _interopRequireDefault(_loopAll);\nvar _loopOne = require('../assets/loop-one.svg');\nvar _loopOne2 = _interopRequireDefault(_loopOne);\nvar _loopNone = require('../assets/loop-none.svg');\nvar _loopNone2 = _interopRequireDefault(_loopNone);\nvar _loading = require('../assets/loading.svg');\nvar _loading2 = _interopRequireDefault(_loading);\nfunction _interopRequireDefault(obj) {\n return obj && obj.__esModule ? obj : { default: obj };\n}\nvar Icons = {\n play: _play2.default,\n pause: _pause2.default,\n volumeUp: _volumeUp2.default,\n volumeDown: _volumeDown2.default,\n volumeOff: _volumeOff2.default,\n orderRandom: _orderRandom2.default,\n orderList: _orderList2.default,\n menu: _menu2.default,\n loopAll: _loopAll2.default,\n loopOne: _loopOne2.default,\n loopNone: _loopNone2.default,\n loading: _loading2.default\n};\nexports.default = Icons;\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/js/icons.js\n// module id = 2\n// module chunks = 0","'use strict';\nmodule.exports = require('./compile/runtime');\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/art-template/lib/runtime.js\n// module id = 3\n// module chunks = 0","'use strict';\nObject.defineProperty(exports, '__esModule', { value: true });\nrequire('../css/index.scss');\nvar _player = require('./player');\nvar _player2 = _interopRequireDefault(_player);\nfunction _interopRequireDefault(obj) {\n return obj && obj.__esModule ? obj : { default: obj };\n}\nconsole.log('\\n' + ' %c APlayer v' + APLAYER_VERSION + ' ' + GIT_HASH + ' %c http://aplayer.js.org ' + '\\n' + '\\n', 'color: #fadfa3; background: #030307; padding:5px 0;', 'background: #fadfa3; padding:5px 0;');\nexports.default = _player2.default;\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/js/index.js\n// module id = 4\n// module chunks = 0","'use strict';\nObject.defineProperty(exports, '__esModule', { value: true });\nvar _createClass = function () {\n function defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if ('value' in descriptor)\n descriptor.writable = true;\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n }\n return function (Constructor, protoProps, staticProps) {\n if (protoProps)\n defineProperties(Constructor.prototype, protoProps);\n if (staticProps)\n defineProperties(Constructor, staticProps);\n return Constructor;\n };\n}();\nvar _promisePolyfill = require('promise-polyfill');\nvar _promisePolyfill2 = _interopRequireDefault(_promisePolyfill);\nvar _utils = require('./utils');\nvar _utils2 = _interopRequireDefault(_utils);\nvar _icons = require('./icons');\nvar _icons2 = _interopRequireDefault(_icons);\nvar _options = require('./options');\nvar _options2 = _interopRequireDefault(_options);\nvar _template = require('./template');\nvar _template2 = _interopRequireDefault(_template);\nvar _bar = require('./bar');\nvar _bar2 = _interopRequireDefault(_bar);\nvar _user = require('./user');\nvar _user2 = _interopRequireDefault(_user);\nvar _lrc = require('./lrc');\nvar _lrc2 = _interopRequireDefault(_lrc);\nvar _controller = require('./controller');\nvar _controller2 = _interopRequireDefault(_controller);\nvar _timer = require('./timer');\nvar _timer2 = _interopRequireDefault(_timer);\nvar _events = require('./events');\nvar _events2 = _interopRequireDefault(_events);\nfunction _interopRequireDefault(obj) {\n return obj && obj.__esModule ? obj : { default: obj };\n}\nfunction _classCallCheck(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError('Cannot call a class as a function');\n }\n}\nvar instances = [];\nvar APlayer = function () {\n function APlayer(options) {\n _classCallCheck(this, APlayer);\n this.options = (0, _options2.default)(options);\n this.container = this.options.container;\n this.playIndex = 0;\n this.paused = true;\n this.playedPromise = _promisePolyfill2.default.resolve();\n this.randomOrder = _utils2.default.randomOrder(this.options.audio.length);\n this.container.classList.add('aplayer');\n if (this.options.lrc) {\n this.container.classList.add('aplayer-withlrc');\n }\n if (this.options.audio.length > 1) {\n this.container.classList.add('aplayer-withlist');\n }\n if (_utils2.default.isMobile) {\n this.container.classList.add('aplayer-mobile');\n }\n this.arrow = this.container.offsetWidth <= 300;\n if (this.arrow) {\n this.container.classList.add('aplayer-arrow');\n }\n if (this.options.mini) {\n this.container.classList.add('aplayer-narrow');\n }\n this.container = this.options.container;\n if (this.options.lrc === 2 || this.options.lrc === true) {\n var lrcEle = this.container.getElementsByClassName('aplayer-lrc-content');\n for (var i = 0; i < lrcEle.length; i++) {\n if (this.options.audio[i]) {\n this.options.audio[i].lrc = lrcEle[i].innerHTML;\n }\n }\n }\n this.template = new _template2.default({\n container: this.container,\n options: this.options,\n randomOrder: this.randomOrder\n });\n if (this.template.info.offsetWidth < 200) {\n this.template.time.classList.add('aplayer-time-narrow');\n }\n if (this.options.lrc) {\n this.lrc = new _lrc2.default({\n container: this.template.lrc,\n async: this.options.lrc === 3,\n content: this.options.audio.map(function (item) {\n return item.lrc;\n }),\n player: this\n });\n }\n this.events = new _events2.default();\n this.user = new _user2.default(this);\n this.bar = new _bar2.default(this.template);\n this.controller = new _controller2.default(this);\n this.timer = new _timer2.default(this);\n this.initAudio();\n if (this.options.order === 'random') {\n this.switchAudio(this.randomOrder[0]);\n } else {\n this.switchAudio(0);\n }\n if (this.options.autoplay) {\n this.play();\n }\n instances.push(this);\n }\n _createClass(APlayer, [\n {\n key: 'initAudio',\n value: function initAudio() {\n var _this = this;\n this.audio = document.createElement('audio');\n this.audio.preload = this.options.preload;\n var _loop = function _loop(i) {\n _this.audio.addEventListener(_this.events.audioEvents[i], function () {\n _this.events.trigger(_this.events.audioEvents[i]);\n });\n };\n for (var i = 0; i < this.events.audioEvents.length; i++) {\n _loop(i);\n }\n this.on('play', function () {\n if (_this.paused) {\n _this.play();\n }\n });\n this.on('pause', function () {\n if (!_this.paused) {\n _this.pause();\n }\n });\n this.on('durationchange', function () {\n if (_this.audio.duration !== 1) {\n _this.template.dtime.innerHTML = _utils2.default.secondToTime(_this.audio.duration);\n }\n });\n this.on('progress', function () {\n var percentage = _this.audio.buffered.length ? _this.audio.buffered.end(_this.audio.buffered.length - 1) / _this.audio.duration : 0;\n _this.bar.set('loaded', percentage, 'width');\n });\n this.on('error', function () {\n _this.template.author.innerHTML = ' - Error happens \\u2565﹏\\u2565';\n });\n this.on('ended', function () {\n if (_this.options.loop === 'none') {\n if (_this.options.order === 'list') {\n if (_this.playIndex < _this.options.audio.length - 1) {\n _this.switchAudio((_this.playIndex + 1) % _this.options.audio.length);\n _this.play();\n } else {\n _this.switchAudio((_this.playIndex + 1) % _this.options.audio.length);\n _this.pause();\n }\n } else if (_this.options.order === 'random') {\n if (_this.randomOrder.indexOf(_this.playIndex) < _this.randomOrder.length - 1) {\n _this.switchAudio(_this.nextRandomNum());\n _this.play();\n } else {\n _this.switchAudio(_this.nextRandomNum());\n _this.pause();\n }\n }\n } else if (_this.options.loop === 'one') {\n _this.switchAudio(_this.playIndex);\n _this.play();\n } else if (_this.options.loop === 'all') {\n if (_this.options.order === 'list') {\n _this.switchAudio((_this.playIndex + 1) % _this.options.audio.length);\n } else if (_this.options.order === 'random') {\n _this.switchAudio(_this.nextRandomNum());\n }\n _this.play();\n }\n });\n this.volume(this.user.get('volume'), true);\n }\n },\n {\n key: 'switchAudio',\n value: function switchAudio(index) {\n var _this2 = this;\n this.handlePlayPromise(function () {\n _this2.events.trigger('switchaudio', index);\n if (typeof index !== 'undefined') {\n _this2.playIndex = index;\n }\n if (_this2.options.audio[_this2.playIndex].cover) {\n _this2.template.pic.style.backgroundImage = 'url(\\'' + _this2.options.audio[_this2.playIndex].cover + '\\')';\n } else {\n _this2.template.pic.style.backgroundImage = '';\n }\n _this2.template.title.innerHTML = _this2.options.audio[_this2.playIndex].name;\n _this2.template.author.innerHTML = _this2.options.audio[_this2.playIndex].artist ? ' - ' + _this2.options.audio[_this2.playIndex].artist : '';\n var light = _this2.container.getElementsByClassName('aplayer-list-light')[0];\n if (light) {\n light.classList.remove('aplayer-list-light');\n }\n _this2.container.querySelectorAll('.aplayer-list li')[_this2.playIndex].classList.add('aplayer-list-light');\n _this2.template.list.scrollTop = _this2.playIndex * 33;\n _this2.audio.src = _this2.options.audio[_this2.playIndex].url;\n _this2.seek(0);\n var playPromise = void 0;\n if (!_this2.paused) {\n playPromise = _promisePolyfill2.default.resolve(_this2.audio.play()).catch(function (err) {\n console.error(err);\n _this2.pause();\n });\n }\n _this2.lrc && _this2.lrc.switch(_this2.playIndex);\n if (_this2.audio.duration !== 1) {\n _this2.template.dtime.innerHTML = _this2.audio.duration ? _utils2.default.secondToTime(_this2.audio.duration) : '00:00';\n }\n return playPromise;\n });\n }\n },\n {\n key: 'seek',\n value: function seek(time) {\n time = Math.max(time, 0);\n if (this.audio.duration) {\n time = Math.min(time, this.audio.duration);\n }\n this.audio.currentTime = time;\n if (isNaN(this.audio.duration)) {\n this.bar.set('played', 0, 'width');\n } else {\n this.bar.set('played', time / this.audio.duration, 'width');\n }\n this.template.ptime.innerHTML = _utils2.default.secondToTime(time);\n }\n },\n {\n key: 'play',\n value: function play() {\n var _this3 = this;\n this.handlePlayPromise(function () {\n if (_this3.paused) {\n _this3.paused = false;\n _this3.template.button.classList.remove('aplayer-play');\n _this3.template.button.classList.add('aplayer-pause');\n _this3.template.button.innerHTML = '';\n setTimeout(function () {\n _this3.template.button.innerHTML = _icons2.default.pause;\n }, 100);\n }\n var playPromise = _promisePolyfill2.default.resolve(_this3.audio.play()).catch(function (err) {\n console.error(err);\n _this3.pause();\n });\n _this3.timer.enable('loading');\n _this3.timer.enable('progress');\n if (_this3.options.mutex) {\n for (var i = 0; i < instances.length; i++) {\n if (_this3 !== instances[i]) {\n instances[i].pause();\n }\n }\n }\n return playPromise;\n });\n }\n },\n {\n key: 'pause',\n value: function pause() {\n var _this4 = this;\n this.handlePlayPromise(function () {\n if (!_this4.paused) {\n _this4.paused = true;\n _this4.template.button.classList.remove('aplayer-pause');\n _this4.template.button.classList.add('aplayer-play');\n _this4.template.button.innerHTML = '';\n setTimeout(function () {\n _this4.template.button.innerHTML = _icons2.default.play;\n }, 100);\n }\n _this4.audio.pause();\n _this4.timer.disable('loading');\n _this4.timer.disable('progress');\n });\n }\n },\n {\n key: 'switchVolumeIcon',\n value: function switchVolumeIcon() {\n if (this.volume() >= 0.95) {\n this.template.volumeButton.innerHTML = _icons2.default.volumeUp;\n } else if (this.volume() > 0) {\n this.template.volumeButton.innerHTML = _icons2.default.volumeDown;\n } else {\n this.template.volumeButton.innerHTML = _icons2.default.volumeOff;\n }\n }\n },\n {\n key: 'volume',\n value: function volume(percentage, nostorage) {\n percentage = parseFloat(percentage);\n if (!isNaN(percentage)) {\n percentage = Math.max(percentage, 0);\n percentage = Math.min(percentage, 1);\n this.bar.set('volume', percentage, 'height');\n if (!nostorage) {\n this.user.set('volume', percentage);\n }\n this.audio.volume = percentage;\n if (this.audio.muted) {\n this.audio.muted = false;\n }\n this.switchVolumeIcon();\n }\n return this.audio.muted ? 0 : this.audio.volume;\n }\n },\n {\n key: 'on',\n value: function on(name, callback) {\n this.events.on(name, callback);\n }\n },\n {\n key: 'toggle',\n value: function toggle() {\n if (this.template.button.classList.contains('aplayer-play')) {\n this.play();\n } else if (this.template.button.classList.contains('aplayer-pause')) {\n this.pause();\n }\n }\n },\n {\n key: 'isMultiple',\n value: function isMultiple() {\n return this.options.audio.length > 1;\n }\n },\n {\n key: 'nextRandomNum',\n value: function nextRandomNum() {\n if (this.isMultiple()) {\n var index = this.randomOrder.indexOf(this.playIndex);\n if (index === this.randomOrder.length - 1) {\n return this.randomOrder[0];\n } else {\n return this.randomOrder[index + 1];\n }\n } else {\n return 0;\n }\n }\n },\n {\n key: 'addAudio',\n value: function addAudio(newMusic) {\n this.events.trigger('addaudio', newMusic);\n var wasSingle = !this.isMultiple();\n this.options.audio = this.options.audio.concat(newMusic);\n var newItemHTML = '';\n for (var i = 0; i < newMusic.length; i++) {\n newItemHTML += '{{$value[1]}}
\n{{/each}}\n\n\n// WEBPACK FOOTER //\n// ./src/template/lrc.art","'use strict';\nObject.defineProperty(exports, '__esModule', { value: true });\nvar _createClass = function () {\n function defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if ('value' in descriptor)\n descriptor.writable = true;\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n }\n return function (Constructor, protoProps, staticProps) {\n if (protoProps)\n defineProperties(Constructor.prototype, protoProps);\n if (staticProps)\n defineProperties(Constructor, staticProps);\n return Constructor;\n };\n}();\nvar _utils = require('./utils');\nvar _utils2 = _interopRequireDefault(_utils);\nvar _icons = require('./icons');\nvar _icons2 = _interopRequireDefault(_icons);\nfunction _interopRequireDefault(obj) {\n return obj && obj.__esModule ? obj : { default: obj };\n}\nfunction _classCallCheck(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError('Cannot call a class as a function');\n }\n}\nvar Controller = function () {\n function Controller(player) {\n _classCallCheck(this, Controller);\n this.player = player;\n this.initPlayButton();\n this.initList();\n this.initPlayBar();\n if (this.player.isMultiple()) {\n this.initOrderButton();\n }\n this.initLoopButton();\n this.initMenuButton();\n if (!_utils2.default.isMobile) {\n this.initVolumeButton();\n }\n }\n _createClass(Controller, [\n {\n key: 'initPlayButton',\n value: function initPlayButton() {\n var _this = this;\n this.player.template.pic.addEventListener('click', function () {\n _this.player.toggle();\n });\n }\n },\n {\n key: 'initList',\n value: function initList() {\n var _this2 = this;\n this.player.template.list.addEventListener('click', function (e) {\n var target = void 0;\n if (e.target.tagName.toUpperCase() === 'LI') {\n target = e.target;\n } else {\n target = e.target.parentElement;\n }\n var audioIndex = parseInt(target.getElementsByClassName('aplayer-list-index')[0].innerHTML) - 1;\n if (audioIndex !== _this2.player.playIndex) {\n _this2.player.switchAudio(audioIndex);\n _this2.player.play();\n } else {\n _this2.player.toggle();\n }\n });\n }\n },\n {\n key: 'initPlayBar',\n value: function initPlayBar() {\n var _this3 = this;\n var thumbMove = function thumbMove(e) {\n var percentage = ((e.clientX || e.changedTouches[0].clientX) - _utils2.default.getElementViewLeft(_this3.player.template.barWrap)) / _this3.player.template.barWrap.clientWidth;\n percentage = Math.max(percentage, 0);\n percentage = Math.min(percentage, 1);\n _this3.player.bar.set('played', percentage, 'width');\n _this3.player.lrc && _this3.player.lrc.update(percentage * _this3.player.audio.duration);\n _this3.player.template.ptime.innerHTML = _utils2.default.secondToTime(percentage * _this3.player.audio.duration);\n };\n var thumbUp = function thumbUp(e) {\n document.removeEventListener(_utils2.default.nameMap.dragEnd, thumbUp);\n document.removeEventListener(_utils2.default.nameMap.dragMove, thumbMove);\n var percentage = ((e.clientX || e.changedTouches[0].clientX) - _utils2.default.getElementViewLeft(_this3.player.template.barWrap)) / _this3.player.template.barWrap.clientWidth;\n percentage = Math.max(percentage, 0);\n percentage = Math.min(percentage, 1);\n _this3.player.bar.set('played', percentage, 'width');\n _this3.player.seek(_this3.player.bar.get('played', 'width') * _this3.player.audio.duration);\n _this3.player.timer.enable('progress');\n };\n this.player.template.barWrap.addEventListener(_utils2.default.nameMap.dragStart, function () {\n _this3.player.timer.disable('progress');\n document.addEventListener(_utils2.default.nameMap.dragMove, thumbMove);\n document.addEventListener(_utils2.default.nameMap.dragEnd, thumbUp);\n });\n }\n },\n {\n key: 'initVolumeButton',\n value: function initVolumeButton() {\n var _this4 = this;\n this.player.template.volumeButton.addEventListener('click', function () {\n if (_this4.player.audio.muted) {\n _this4.player.audio.muted = false;\n _this4.player.switchVolumeIcon();\n _this4.player.bar.set('volume', _this4.player.volume(), 'height');\n } else {\n _this4.player.audio.muted = true;\n _this4.player.switchVolumeIcon();\n _this4.player.bar.set('volume', 0, 'height');\n }\n });\n var thumbMove = function thumbMove(e) {\n var percentage = 1 - ((e.clientY || e.changedTouches[0].clientY) - _utils2.default.getElementViewTop(_this4.player.template.volumeBar)) / _this4.player.template.volumeBar.clientHeight;\n percentage = Math.max(percentage, 0);\n percentage = Math.min(percentage, 1);\n _this4.player.volume(percentage);\n };\n var thumbUp = function thumbUp(e) {\n _this4.player.template.volumeBarWrap.classList.remove('aplayer-volume-bar-wrap-active');\n document.removeEventListener(_utils2.default.nameMap.dragEnd, thumbUp);\n document.removeEventListener(_utils2.default.nameMap.dragMove, thumbMove);\n var percentage = 1 - ((e.clientY || e.changedTouches[0].clientY) - _utils2.default.getElementViewTop(_this4.player.template.volumeBar)) / _this4.player.template.volumeBar.clientHeight;\n percentage = Math.max(percentage, 0);\n percentage = Math.min(percentage, 1);\n _this4.player.volume(percentage);\n };\n this.player.template.volumeBarWrap.addEventListener(_utils2.default.nameMap.dragStart, function () {\n _this4.player.template.volumeBarWrap.classList.add('aplayer-volume-bar-wrap-active');\n document.addEventListener(_utils2.default.nameMap.dragMove, thumbMove);\n document.addEventListener(_utils2.default.nameMap.dragEnd, thumbUp);\n });\n }\n },\n {\n key: 'initOrderButton',\n value: function initOrderButton() {\n var _this5 = this;\n this.player.template.order.addEventListener('click', function () {\n if (_this5.player.options.order === 'list') {\n _this5.player.options.order = 'random';\n _this5.player.template.order.innerHTML = _icons2.default.orderRandom;\n } else if (_this5.player.options.order === 'random') {\n _this5.player.options.order = 'list';\n _this5.player.template.order.innerHTML = _icons2.default.orderList;\n }\n });\n }\n },\n {\n key: 'initLoopButton',\n value: function initLoopButton() {\n var _this6 = this;\n this.player.template.loop.addEventListener('click', function () {\n if (_this6.player.isMultiple()) {\n if (_this6.player.options.loop === 'one') {\n _this6.player.options.loop = 'none';\n _this6.player.template.loop.innerHTML = _icons2.default.loopNone;\n } else if (_this6.player.options.loop === 'none') {\n _this6.player.options.loop = 'all';\n _this6.player.template.loop.innerHTML = _icons2.default.loopAll;\n } else if (_this6.player.options.loop === 'all') {\n _this6.player.options.loop = 'one';\n _this6.player.template.loop.innerHTML = _icons2.default.loopOne;\n }\n } else {\n if (_this6.player.options.loop === 'one' || _this6.player.options.loop === 'all') {\n _this6.player.options.loop = 'none';\n _this6.player.template.loop.innerHTML = _icons2.default.loopNone;\n } else if (_this6.player.options.loop === 'none') {\n _this6.player.options.loop = 'all';\n _this6.player.template.loop.innerHTML = _icons2.default.loopAll;\n }\n }\n });\n }\n },\n {\n key: 'initMenuButton',\n value: function initMenuButton() {\n var _this7 = this;\n this.player.template.list.style.height = 33 * this.player.options.audio.length - 1 + 'px';\n this.player.template.menu.addEventListener('click', function () {\n if (!_this7.player.template.list.classList.contains('aplayer-list-hide')) {\n _this7.player.template.list.classList.add('aplayer-list-hide');\n } else {\n _this7.player.template.list.classList.remove('aplayer-list-hide');\n }\n });\n }\n }\n ]);\n return Controller;\n}();\nexports.default = Controller;\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/js/controller.js\n// module id = 32\n// module chunks = 0","'use strict';\nObject.defineProperty(exports, '__esModule', { value: true });\nvar _createClass = function () {\n function defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if ('value' in descriptor)\n descriptor.writable = true;\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n }\n return function (Constructor, protoProps, staticProps) {\n if (protoProps)\n defineProperties(Constructor.prototype, protoProps);\n if (staticProps)\n defineProperties(Constructor, staticProps);\n return Constructor;\n };\n}();\nvar _utils = require('./utils');\nvar _utils2 = _interopRequireDefault(_utils);\nfunction _interopRequireDefault(obj) {\n return obj && obj.__esModule ? obj : { default: obj };\n}\nfunction _classCallCheck(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError('Cannot call a class as a function');\n }\n}\nvar Timer = function () {\n function Timer(player) {\n _classCallCheck(this, Timer);\n this.player = player;\n window.requestAnimationFrame = function () {\n return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (callback) {\n window.setTimeout(callback, 1000 / 60);\n };\n }();\n this.types = [\n 'loading',\n 'progress'\n ];\n this.init();\n }\n _createClass(Timer, [\n {\n key: 'init',\n value: function init() {\n var _this = this;\n this.types.map(function (item) {\n _this['init' + item + 'Checker']();\n return item;\n });\n }\n },\n {\n key: 'initprogressChecker',\n value: function initprogressChecker() {\n var _this2 = this;\n this.progressChecker = setInterval(function () {\n if (_this2.enableprogressChecker) {\n _this2.player.bar.set('played', _this2.player.audio.currentTime / _this2.player.audio.duration, 'width');\n _this2.player.lrc && _this2.player.lrc.update();\n var currentTime = _utils2.default.secondToTime(_this2.player.audio.currentTime);\n if (_this2.player.template.ptime.innerHTML !== currentTime) {\n _this2.player.template.ptime.innerHTML = currentTime;\n }\n }\n }, 100);\n }\n },\n {\n key: 'initloadingChecker',\n value: function initloadingChecker() {\n var _this3 = this;\n var lastPlayPos = 0;\n var currentPlayPos = 0;\n var bufferingDetected = false;\n this.loadingChecker = setInterval(function () {\n if (_this3.enableloadingChecker) {\n currentPlayPos = _this3.player.audio.currentTime;\n if (!bufferingDetected && currentPlayPos === lastPlayPos && !_this3.player.audio.paused) {\n _this3.player.container.classList.add('aplayer-loading');\n bufferingDetected = true;\n }\n if (bufferingDetected && currentPlayPos > lastPlayPos && !_this3.player.audio.paused) {\n _this3.player.container.classList.remove('aplayer-loading');\n bufferingDetected = false;\n }\n lastPlayPos = currentPlayPos;\n }\n }, 100);\n }\n },\n {\n key: 'enable',\n value: function enable(type) {\n this['enable' + type + 'Checker'] = true;\n if (type === 'fps') {\n this.initfpsChecker();\n }\n }\n },\n {\n key: 'disable',\n value: function disable(type) {\n this['enable' + type + 'Checker'] = false;\n }\n },\n {\n key: 'destroy',\n value: function destroy() {\n var _this4 = this;\n this.types.map(function (item) {\n _this4['enable' + item + 'Checker'] = false;\n _this4[item + 'Checker'] && clearInterval(_this4[item + 'Checker']);\n return item;\n });\n }\n }\n ]);\n return Timer;\n}();\nexports.default = Timer;\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/js/timer.js\n// module id = 33\n// module chunks = 0","'use strict';\nObject.defineProperty(exports, '__esModule', { value: true });\nvar _createClass = function () {\n function defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if ('value' in descriptor)\n descriptor.writable = true;\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n }\n return function (Constructor, protoProps, staticProps) {\n if (protoProps)\n defineProperties(Constructor.prototype, protoProps);\n if (staticProps)\n defineProperties(Constructor, staticProps);\n return Constructor;\n };\n}();\nfunction _classCallCheck(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError('Cannot call a class as a function');\n }\n}\nvar Events = function () {\n function Events() {\n _classCallCheck(this, Events);\n this.events = {};\n this.audioEvents = [\n 'abort',\n 'canplay',\n 'canplaythrough',\n 'durationchange',\n 'emptied',\n 'ended',\n 'error',\n 'loadeddata',\n 'loadedmetadata',\n 'loadstart',\n 'mozaudioavailable',\n 'pause',\n 'play',\n 'playing',\n 'progress',\n 'ratechange',\n 'seeked',\n 'seeking',\n 'stalled',\n 'suspend',\n 'timeupdate',\n 'volumechange',\n 'waiting'\n ];\n this.playerEvents = [\n 'destroy',\n 'switchaudio',\n 'addaudio',\n 'removeaudio'\n ];\n }\n _createClass(Events, [\n {\n key: 'on',\n value: function on(name, callback) {\n if (this.type(name) && typeof callback === 'function') {\n if (!this.events[name]) {\n this.events[name] = [];\n }\n this.events[name].push(callback);\n }\n }\n },\n {\n key: 'trigger',\n value: function trigger(name, info) {\n if (this.events[name] && this.events[name].length) {\n for (var i = 0; i < this.events[name].length; i++) {\n this.events[name][i](info);\n }\n }\n }\n },\n {\n key: 'type',\n value: function type(name) {\n if (this.playerEvents.indexOf(name) !== -1) {\n return 'player';\n } else if (this.audioEvents.indexOf(name) !== -1) {\n return 'audio';\n }\n console.error('Unknown event name: ' + name);\n return null;\n }\n }\n ]);\n return Events;\n}();\nexports.default = Events;\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/js/events.js\n// module id = 34\n// module chunks = 0"],"sourceRoot":""} diff --git a/assets/Meting.min.js b/assets/Meting.min.js index e6b9984..9405db6 100644 --- a/assets/Meting.min.js +++ b/assets/Meting.min.js @@ -1 +1 @@ -"use strict";console.log("\n %c MetingJS 1.0.1 %c https://github.com/metowolf/MetingJS \n\n","color: #fff; background-image: linear-gradient(90deg, rgb(47, 172, 178) 0%, rgb(45, 190, 96) 100%); padding:5px 1px;","background-image: linear-gradient(90deg, rgb(45, 190, 96) 0%, rgb(255, 255, 255) 100%); padding:5px 0;");var aplayers=[];function loadMeting(){function a(a,b){var c=[],d=a.dataset;c.element=a,c.music=b,c.showlrc=c.music[0].lrc?3:0,c.narrow="true"===d.narrow,c.autoplay="true"===d.autoplay,c.mutex="false"!==d.mutex,c.mode=d.mode||"circulation",c.preload=d.preload||"auto",c.listmaxheight=d.listmaxheight||"340px",c.theme=d.theme||"#ad7a86",aplayers.push(new APlayer(c))}var b="https://api.i-meto.com/meting/api?server=:server&type=:type&id=:id&r=:r";"undefined"!=typeof meting_api&&(b=meting_api);var c=document.querySelectorAll(".aplayer"),d=!0,e=!1,f=void 0;try{for(var g,h=function(){var c=g.value,d=c.dataset.id;if(d){var e=b;e=e.replace(":server",c.dataset.server),e=e.replace(":type",c.dataset.type),e=e.replace(":id",c.dataset.id),e=e.replace(":r",Math.random());var f=new XMLHttpRequest;f.onreadystatechange=function(){if(4===f.readyState&&(200<=f.status&&300>f.status||304===f.status)){var b=JSON.parse(f.responseText);a(c,b)}},f.open("get",e,!0),f.send(null)}else{var h=[{title:c.dataset.title,author:c.dataset.author,url:c.dataset.url,pic:c.dataset.pic,lrc:c.dataset.lrc}];a(c,h)}},i=c[Symbol.iterator]();!(d=(g=i.next()).done);d=!0)h()}catch(a){e=!0,f=a}finally{try{!d&&i.return&&i.return()}finally{if(e)throw f}}}document.addEventListener("DOMContentLoaded",loadMeting,!1); \ No newline at end of file +'use strict';console.log('\n %c MetingJS 1.1.1 %c https://github.com/metowolf/MetingJS \n\n','color: #fadfa3; background: #030307; padding:5px 0;','background: #fadfa3; padding:5px 0;');var aplayers=[],loadMeting=function(){function a(a,b){var c={container:a,audio:b,mini:!1,autoplay:!1,mutex:!0,lrc:3,preload:'auto',theme:'#2980b9',loop:'all',order:'list',volume:0.7,listFolded:!1,listMaxHeight:'340px'};for(var d in c)c.hasOwnProperty(d)&&a.dataset.hasOwnProperty(d)&&(c[d]=a.dataset[d],('true'===c[d]||'false'===c[d])&&(c[d]='true'==c[d]));b.length&&(!0===c.mini&&(c.lrc=0,c.listFolded=!0),aplayers.push(new APlayer(c)))}var b='https://api.i-meto.com/meting/api?server=:server&type=:type&id=:id&r=:r';'undefined'!=typeof meting_api&&(b=meting_api);for(var f=0;f