/******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) /******/ return installedModules[moduleId].exports; /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ exports: {}, /******/ id: moduleId, /******/ loaded: false /******/ }; /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ // Flag the module as loaded /******/ module.loaded = true; /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ // Load entry module and return exports /******/ return __webpack_require__(0); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(global) {'use strict'; var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; var _constants = __webpack_require__(1); var _lyric = __webpack_require__(2); var lyric = _interopRequireWildcard(_lyric); var _utils = __webpack_require__(3); var utils = _interopRequireWildcard(_utils); var _spectrum = __webpack_require__(4); var spectrum = _interopRequireWildcard(_spectrum); var _selector = __webpack_require__(5); var selector = _interopRequireWildcard(_selector); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } var root = (typeof window === 'undefined' ? 'undefined' : _typeof(window)) == 'object' && window.window === window ? window : (typeof global === 'undefined' ? 'undefined' : _typeof(global)) == 'object' && global.global === global ? global : undefined; root.mePlayer = function (options) { // 检查必填选项 if (!(options.music && options.music.src)) { console.error('必须指定音乐地址哦~'); return; } var musicConf = options.music, target = selector.$(options.target) || document.querySelector('.meplayer'), theme = options.theme || _constants.THEME_DEFAULT, hasLrc = musicConf.lrc ? true : false, coverSrc = musicConf.cover || 'https://unsplash.it/78/?random', loop = musicConf.loop || false, autoplay = options.autoplay, currentThemeClass = theme === _constants.THEME_DEFAULT ? 'meplayer-container' : 'meplayer-container-mini', containerClass = currentThemeClass + ' ' + (hasLrc ? 'meplayer-haslrc' : '') + ' meplayer-isloading', playerHTMLContent = '
' + lyrics[i].text + '
'; } target.innerHTML = lyricHTML; target.querySelector('p').className = _constants.LYRIC_CURRENT_CLASS; target.querySelector('p + p').className = _constants.LYRIC_NEXT_CLASS; return this; } function currentIndex(time) { if (time < lyrics[0].time) return 0; for (var i = 0, l = lyrics.length; i < l; i++) { if (time >= lyrics[i].time && (!lyrics[i + 1] || time <= lyrics[i + 1].time)) { break; } } return i; } exports.parse = parse; exports.renderTo = renderTo; exports.currentIndex = currentIndex; /***/ }), /* 3 */ /***/ (function(module, exports) { 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); function toggleClass(el, className) { if (el.classList) { el.classList.toggle(className); } else { var classes = el.className.split(' '); var existingIndex = classes.indexOf(className); if (existingIndex >= 0) classes.splice(existingIndex, 1);else classes.push(className); el.className = classes.join(' '); } } function addClass(el, className) { if (el.classList) el.classList.add(className);else el.className += ' ' + className; } function removeClass(el, className) { if (el.classList) el.classList.remove(className);else el.className = el.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' '); } function getAbsLeft(el) { var left = el.offsetLeft; while (el.offsetParent) { el = el.offsetParent; left += el.offsetLeft; } return left; } function parseSec(sec) { var tempMin = sec / 60 | 0; var tempSec = sec % 60 | 0; var curMin = tempMin < 10 ? '0' + tempMin : tempMin; var curSec = tempSec < 10 ? '0' + tempSec : tempSec; return curMin + ':' + curSec; } exports.toggleClass = toggleClass; exports.addClass = addClass; exports.removeClass = removeClass; exports.getAbsLeft = getAbsLeft; exports.parseSec = parseSec; /***/ }), /* 4 */ /***/ (function(module, exports) { 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); /* * 频谱动画模拟 * */ var canvas, ctx, specItems = [], needStop = false, timer = null, random = Math.random; function randHeight() { if (random() > 0.8) { return random() * 8 + 11; } else { return random() * 6 + 2; } } var randHeightGenerator = function randHeightGenerator(base) { var max = base * 1.5 > 28 ? 28 : base * 1.5, min = 1, direction = random() > 0.5 ? 1 : -1, tempHeight = base, curStep; return function () { curStep = direction; tempHeight += curStep; if (tempHeight >= max) { direction *= -1; tempHeight = max; } else if (tempHeight <= min) { direction *= -1; tempHeight = min; } if (random() > 0.9) { direction *= -1; } return tempHeight; }; }; function loop() { ctx.clearRect(0, -canvas.height / 2, canvas.width, canvas.height); for (var i = 0; i < specItems.length; i++) { var item = specItems[i]; var height = item.getHeight(); ctx.fillRect(i + specItems[i].xSpace, -height / 2, specItems[i].width, height); } if (!needStop) { timer = requestAnimationFrame(loop); } } function init(canvasElem) { var width = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 220; var height = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 30; var color = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '#D94240'; canvas = canvasElem; canvas.width = width; canvas.height = height; ctx = canvas.getContext('2d'); ctx.fillStyle = color; ctx.translate(0, height / 2); for (var i = 0; i < 64; i++) { var xSpace = i == 0 ? 0 : 5 * i; var tempItem = { xSpace: xSpace, width: 1, getHeight: randHeightGenerator(randHeight()) }; specItems.push(tempItem); } } function draw() { needStop = false; loop(); } function stop() { needStop = true; } exports.init = init; exports.draw = draw; exports.stop = stop; /***/ }), /* 5 */ /***/ (function(module, exports) { 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); /** * 元素选择器辅助工具模块 * init : 设定容器 * select: 传入选择器则返回元素,传入选择器数组则返回对应的元素数组 * $ : 辅助功能,使得无论传入选择器字符串还是元素本身,都能返回正确的元素 */ var container; function init(element) { container = $(element); return this; } function select(element) { var result; if (Array.isArray(element)) { var tempResults = []; var _iteratorNormalCompletion = true; var _didIteratorError = false; var _iteratorError = undefined; try { for (var _iterator = element[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { var value = _step.value; tempResults.push($(value, container)); } } catch (err) { _didIteratorError = true; _iteratorError = err; } finally { try { if (!_iteratorNormalCompletion && _iterator.return) { _iterator.return(); } } finally { if (_didIteratorError) { throw _iteratorError; } } } result = tempResults; } else { result = $(element, container); } return result; } function $(element, context) { var result; context = context || document; if (typeof element === 'string') { result = context.querySelector(element); } else if (element.toString().includes('HTMLDivElement')) { result = element; } return result; } exports.init = init; exports.select = select; exports.$ = $; /***/ }) /******/ ]);