(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["Lyric"] = factory();
else
root["Lyric"] = factory();
})(this, function() {
return /******/ (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] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = 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;
/******/
/******/ // identity function for calling harmony imports with the correct context
/******/ __webpack_require__.i = function(value) { return value; };
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 20);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
// Thank's IE8 for his funny defineProperty
module.exports = !__webpack_require__(3)(function(){
return Object.defineProperty({}, 'a', {get: function(){ return 7; }}).a != 7;
});
/***/ }),
/* 1 */
/***/ (function(module, exports) {
module.exports = function(it){
return typeof it === 'object' ? it !== null : typeof it === 'function';
};
/***/ }),
/* 2 */
/***/ (function(module, exports) {
var core = module.exports = {version: '2.4.0'};
if(typeof __e == 'number')__e = core; // eslint-disable-line no-undef
/***/ }),
/* 3 */
/***/ (function(module, exports) {
module.exports = function(exec){
try {
return !!exec();
} catch(e){
return true;
}
};
/***/ }),
/* 4 */
/***/ (function(module, exports) {
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
var global = module.exports = typeof window != 'undefined' && window.Math == Math
? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')();
if(typeof __g == 'number')__g = global; // eslint-disable-line no-undef
/***/ }),
/* 5 */
/***/ (function(module, exports, __webpack_require__) {
var anObject = __webpack_require__(11)
, IE8_DOM_DEFINE = __webpack_require__(16)
, toPrimitive = __webpack_require__(18)
, dP = Object.defineProperty;
exports.f = __webpack_require__(0) ? Object.defineProperty : function defineProperty(O, P, Attributes){
anObject(O);
P = toPrimitive(P, true);
anObject(Attributes);
if(IE8_DOM_DEFINE)try {
return dP(O, P, Attributes);
} catch(e){ /* empty */ }
if('get' in Attributes || 'set' in Attributes)throw TypeError('Accessors not supported!');
if('value' in Attributes)O[P] = Attributes.value;
return O;
};
/***/ }),
/* 6 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.default = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
/***/ }),
/* 7 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _defineProperty = __webpack_require__(8);
var _defineProperty2 = _interopRequireDefault(_defineProperty);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
(0, _defineProperty2.default)(target, descriptor.key, descriptor);
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
/***/ }),
/* 8 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = { "default": __webpack_require__(9), __esModule: true };
/***/ }),
/* 9 */
/***/ (function(module, exports, __webpack_require__) {
__webpack_require__(19);
var $Object = __webpack_require__(2).Object;
module.exports = function defineProperty(it, key, desc){
return $Object.defineProperty(it, key, desc);
};
/***/ }),
/* 10 */
/***/ (function(module, exports) {
module.exports = function(it){
if(typeof it != 'function')throw TypeError(it + ' is not a function!');
return it;
};
/***/ }),
/* 11 */
/***/ (function(module, exports, __webpack_require__) {
var isObject = __webpack_require__(1);
module.exports = function(it){
if(!isObject(it))throw TypeError(it + ' is not an object!');
return it;
};
/***/ }),
/* 12 */
/***/ (function(module, exports, __webpack_require__) {
// optional / simple context binding
var aFunction = __webpack_require__(10);
module.exports = function(fn, that, length){
aFunction(fn);
if(that === undefined)return fn;
switch(length){
case 1: return function(a){
return fn.call(that, a);
};
case 2: return function(a, b){
return fn.call(that, a, b);
};
case 3: return function(a, b, c){
return fn.call(that, a, b, c);
};
}
return function(/* ...args */){
return fn.apply(that, arguments);
};
};
/***/ }),
/* 13 */
/***/ (function(module, exports, __webpack_require__) {
var isObject = __webpack_require__(1)
, document = __webpack_require__(4).document
// in old IE typeof document.createElement is 'object'
, is = isObject(document) && isObject(document.createElement);
module.exports = function(it){
return is ? document.createElement(it) : {};
};
/***/ }),
/* 14 */
/***/ (function(module, exports, __webpack_require__) {
var global = __webpack_require__(4)
, core = __webpack_require__(2)
, ctx = __webpack_require__(12)
, hide = __webpack_require__(15)
, PROTOTYPE = 'prototype';
var $export = function(type, name, source){
var IS_FORCED = type & $export.F
, IS_GLOBAL = type & $export.G
, IS_STATIC = type & $export.S
, IS_PROTO = type & $export.P
, IS_BIND = type & $export.B
, IS_WRAP = type & $export.W
, exports = IS_GLOBAL ? core : core[name] || (core[name] = {})
, expProto = exports[PROTOTYPE]
, target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE]
, key, own, out;
if(IS_GLOBAL)source = name;
for(key in source){
// contains in native
own = !IS_FORCED && target && target[key] !== undefined;
if(own && key in exports)continue;
// export native or passed
out = own ? target[key] : source[key];
// prevent global pollution for namespaces
exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key]
// bind timers to global for call from export context
: IS_BIND && own ? ctx(out, global)
// wrap global constructors for prevent change them in library
: IS_WRAP && target[key] == out ? (function(C){
var F = function(a, b, c){
if(this instanceof C){
switch(arguments.length){
case 0: return new C;
case 1: return new C(a);
case 2: return new C(a, b);
} return new C(a, b, c);
} return C.apply(this, arguments);
};
F[PROTOTYPE] = C[PROTOTYPE];
return F;
// make static versions for prototype methods
})(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
// export proto methods to core.%CONSTRUCTOR%.methods.%NAME%
if(IS_PROTO){
(exports.virtual || (exports.virtual = {}))[key] = out;
// export proto methods to core.%CONSTRUCTOR%.prototype.%NAME%
if(type & $export.R && expProto && !expProto[key])hide(expProto, key, out);
}
}
};
// type bitmap
$export.F = 1; // forced
$export.G = 2; // global
$export.S = 4; // static
$export.P = 8; // proto
$export.B = 16; // bind
$export.W = 32; // wrap
$export.U = 64; // safe
$export.R = 128; // real proto method for `library`
module.exports = $export;
/***/ }),
/* 15 */
/***/ (function(module, exports, __webpack_require__) {
var dP = __webpack_require__(5)
, createDesc = __webpack_require__(17);
module.exports = __webpack_require__(0) ? function(object, key, value){
return dP.f(object, key, createDesc(1, value));
} : function(object, key, value){
object[key] = value;
return object;
};
/***/ }),
/* 16 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = !__webpack_require__(0) && !__webpack_require__(3)(function(){
return Object.defineProperty(__webpack_require__(13)('div'), 'a', {get: function(){ return 7; }}).a != 7;
});
/***/ }),
/* 17 */
/***/ (function(module, exports) {
module.exports = function(bitmap, value){
return {
enumerable : !(bitmap & 1),
configurable: !(bitmap & 2),
writable : !(bitmap & 4),
value : value
};
};
/***/ }),
/* 18 */
/***/ (function(module, exports, __webpack_require__) {
// 7.1.1 ToPrimitive(input [, PreferredType])
var isObject = __webpack_require__(1);
// instead of the ES6 spec version, we didn't implement @@toPrimitive case
// and the second argument - flag - preferred type is a string
module.exports = function(it, S){
if(!isObject(it))return it;
var fn, val;
if(S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val;
if(typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it)))return val;
if(!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val;
throw TypeError("Can't convert object to primitive value");
};
/***/ }),
/* 19 */
/***/ (function(module, exports, __webpack_require__) {
var $export = __webpack_require__(14);
// 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes)
$export($export.S + $export.F * !__webpack_require__(0), 'Object', {defineProperty: __webpack_require__(5).f});
/***/ }),
/* 20 */
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (global, factory) {
if (true) {
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [module, exports, __webpack_require__(6), __webpack_require__(7)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else if (typeof exports !== "undefined") {
factory(module, exports, require('babel-runtime/helpers/classCallCheck'), require('babel-runtime/helpers/createClass'));
} else {
var mod = {
exports: {}
};
factory(mod, mod.exports, global.classCallCheck, global.createClass);
global.index = mod.exports;
}
})(this, function (module, exports, _classCallCheck2, _createClass2) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass3 = _interopRequireDefault(_createClass2);
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
var timeExp = /\[(\d{2,}):(\d{2})(?:\.(\d{2,3}))?]/g;
var STATE_PAUSE = 0;
var STATE_PLAYING = 1;
var tagRegMap = {
title: 'ti',
artist: 'ar',
album: 'al',
offset: 'offset',
by: 'by'
};
function noop() {}
var Lyric = function () {
function Lyric(lrc) {
var hanlder = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
(0, _classCallCheck3.default)(this, Lyric);
this.lrc = lrc;
this.tags = {};
this.lines = [];
this.handler = hanlder;
this.state = STATE_PAUSE;
this.curLine = 0;
this._init();
}
(0, _createClass3.default)(Lyric, [{
key: '_init',
value: function _init() {
this._initTag();
this._initLines();
}
}, {
key: '_initTag',
value: function _initTag() {
for (var tag in tagRegMap) {
var matches = this.lrc.match(new RegExp('\\[' + tagRegMap[tag] + ':([^\\]]*)]', 'i'));
this.tags[tag] = matches && matches[1] || '';
}
}
}, {
key: '_initLines',
value: function _initLines() {
var lines = this.lrc.split('\n');
for (var i = 0; i < lines.length; i++) {
var line = lines[i];
var result = timeExp.exec(line);
if (result) {
var txt = line.replace(timeExp, '').trim();
if (txt) {
this.lines.push({
time: result[1] * 60 * 1000 + result[2] * 1000 + (result[3] || 0) * 10,
txt: txt
});
}
}
}
this.lines.sort(function (a, b) {
return a.time - b.time;
});
}
}, {
key: '_findCurNum',
value: function _findCurNum(time) {
for (var i = 0; i < this.lines.length; i++) {
if (time <= this.lines[i].time) {
return i;
}
}
return this.lines.length - 1;
}
}, {
key: '_callHandler',
value: function _callHandler(i) {
if (i < 0) {
return;
}
this.handler({
txt: this.lines[i].txt,
lineNum: i
});
}
}, {
key: '_playRest',
value: function _playRest() {
var _this = this;
var line = this.lines[this.curNum];
var delay = line.time - (+new Date() - this.startStamp);
this.timer = setTimeout(function () {
_this._callHandler(_this.curNum++);
if (_this.curNum < _this.lines.length && _this.state === STATE_PLAYING) {
_this._playRest();
}
}, delay);
}
}, {
key: 'play',
value: function play() {
var startTime = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var skipLast = arguments[1];
if (!this.lines.length) {
return;
}
this.state = STATE_PLAYING;
this.curNum = this._findCurNum(startTime);
this.startStamp = +new Date() - startTime;
if (!skipLast) {
this._callHandler(this.curNum - 1);
}
if (this.curNum < this.lines.length) {
clearTimeout(this.timer);
this._playRest();
}
}
}, {
key: 'togglePlay',
value: function togglePlay() {
var now = +new Date();
if (this.state === STATE_PLAYING) {
this.stop();
this.pauseStamp = now;
} else {
this.state = STATE_PLAYING;
this.play((this.pauseStamp || now) - (this.startStamp || now), true);
this.pauseStamp = 0;
}
}
}, {
key: 'stop',
value: function stop() {
this.state = STATE_PAUSE;
clearTimeout(this.timer);
}
}, {
key: 'seek',
value: function seek(offset) {
this.play(offset);
}
}]);
return Lyric;
}();
exports.default = Lyric;
module.exports = exports['default'];
});
/***/ })
/******/ ]);
});
$(function() {
var audio = document.getElementById("audio");
if (!audio) {
return;
}
var lyricObj;
var initLrc=function (lyric) {
var arrLyric = new Array(); //放存汉字的歌词
var arrTime = new Array(); //存放时间
var currentLine = 0; //当前活动的歌词行号
// 开始解析歌词
//将歌词解析成数组
var arrly = lyric.split('\n');
for (var i = 0; i < arrly.length; i++) {
var str = arrly[i];
str = str.substring(str.indexOf("[") + 1, str.indexOf("]"));
if (str.indexOf('ti:') > -1 || str.indexOf('ar:') > -1 || str.indexOf('al:') > -1 || str.indexOf('by:') > -1) {
// 歌曲特征字段
var tmp = str.substring(str.indexOf(':') + 1);
var text = tmp;
//tag=tag.replace(/([ti|ar|al|by])/g,'');
//arrLyric.push(tag+text);
//arrTime.push(toSeconds('00:00:00')); //
} else {
var text = arrly[i].substring(arrly[i].indexOf("]") + 1);
//if(text==''){text=' ';}
arrLyric.push(text); //放歌词
arrTime.push(toSeconds(str)); //放时间
}
}
// 所有歌词按时间顺序排列
for (var k = 0; k < arrTime.length; k++) {
for (var j = 0; j < arrTime.length - k; j++) {
if (arrTime[j] > arrTime[j + 1]) {
temp = arrTime[j];
arrTime[j] = arrTime[j + 1];
arrTime[j + 1] = temp;
temp = arrLyric[j];
arrLyric[j] = arrLyric[j + 1];
arrLyric[j + 1] = temp;
}
}
}
var lrc2textArr=document.querySelectorAll("lrc2text");
if(lrc2textArr&&lrc2textArr.length>0){
var loadLrcText=function(i){
if(i==lrc2textArr.length){
return;
}
var lrc2text=lrc2textArr[i];
var url="../lrc/"+lrc2text.attributes.lrcName.value;
$.ajax({url: url,
success:function (data) {
var startLine=lrc2text.attributes.startLine?parseInt(lrc2text.attributes.startLine.value):1;
var endLine=lrc2text.attributes.endLine?parseInt(lrc2text.attributes.endLine.value):arrLyric.length;
var lcHtml="";
for (var k = startLine-1; k <= endLine-1; k++) {
var lc = arrLyric[k].split("
");
lcHtml+=""+lc[0]+""+lc[1]+""+lc[2]+"";
}
lrc2text.innerHTML=lcHtml;
loadLrcText(++i);
},
error: function(XMLHttpRequest, textStatus, errorThrown){
console.error(textStatus);
loadLrcText(++i);
}});
};
loadLrcText(0);
}
// 显示歌词
var displayLine = function(lineID,num){
var lc = arrLyric[num].split("
");
$(lineID+" span:eq(0)").text(lc[0]);
if (lc.length > 1) {
$(lineID+" span:eq(1)").text(lc[1]);
}else{
$(lineID+" span:eq(1)").text("");
}
if (lc.length > 2) {
$(lineID+" span:eq(2)").text(lc[2]);
}else{
$(lineID+" span:eq(2)").text("");
}
};
var handler = function ({lineNum, txt}){
if(currentLine==lineNum){
return;
}
if (lineNum > 0) {
displayLine("#line-last",lineNum-1);
}
if (lineNum < arrTime.length - 1) {
displayLine("#line-next",lineNum+1);
}
displayLine("#line-current",lineNum);
currentLine = lineNum;
}
if(lyricObj){
lyricObj.stop();
}
lyricObj = new Lyric(lyric, handler);
var bugInterval=undefined;
audio.onplay=function(){
if(bugInterval){return;}
bugInterval=setInterval(function(){
audio.currentTime=audio.currentTime-0.001;
console.log("自动倒退:"+audio.currentTime);
},5*60*1000);
}
audio.onpause=function(){
lyricObj.stop();
clearInterval(bugInterval);
bugInterval=undefined;
}
audio.ontimeupdate=function(){
var ctime=audio.currentTime;
if(ctime==0){//lyricObj.seek(0)不会调用handler显示歌词,手动调用一次
handler({lineNum:1,txt:""});
}
lyricObj.seek(ctime * 1000);
lyricObj.stop();
};
}
var toSeconds=function (t) { //把形如:01:25的时间转化成秒;
var m = t.substring(0, t.indexOf(":"));
var s = t.substring(t.indexOf(":") + 1);
s = parseFloat(s.replace(/\b(0+)/gi, ""));
if (isNaN(s)) s = 0;
var totalt = parseInt(m) * 60 + s;
if (isNaN(totalt)) return 0;
return totalt;
}
var $container = $('#lyriccontainer');
var loadLrc=function(){
var url = audio.src;
var urlArr = url.split('?');
var k = urlArr[0],
appU = k.split('/');
var srcFileExt = appU[appU.length - 1].split('.')[1];
url = url.replace("." + srcFileExt, ".lrc");
var url = "../lrc/"+appU[appU.length - 1].replace("." + srcFileExt, ".lrc");
$.get(url,
function(data) {
var lrcContent = data;
if (!lrcContent || lrcContent == "") {
return;
}
initLrc(lrcContent);
});
};
var list=new Array();
var playIndex=0;
var doPlay=function(){
if(playIndex>list.length-1||playIndex<0){
return;
}
audio.src = list[playIndex];
loadLrc();
if(playIndex0){
$("#playPrev").prop("title",list[playIndex-1]);
}else{
$("#playPrev").prop("title","没有了");
}
audio.play();
};
if ($("#audio sourceList").length>0) {
list=$("#audio sourceList").attr("src").split(",");
audio.src=list[0];
loadLrc();
if(list.length>1){
var playEndedHandler=function (){
playIndex++;
doPlay();
};
$("#playNext").prop("title",list[1]);
audio.onended=playEndedHandler;
}
}
audio.onerror = audio.onabort = audio.onstalled = function(m) {
layer.msg('播放器发生错误:'+m.type,{
type: 1,
title: false,
shade:0,
offset:'b',
time:8000
});
};
var noSleep = new NoSleep();
var enableNoSleep = false;
var isFullScreen = false;
var layerIndex=0;
var btn_lyricFullscreen = document.getElementById("lyricFullscreen");
// 监听全屏事件触发
var fullScreenChangeListener = function() {
isFullScreen = !!(
document.fullscreen ||
document.mozFullScreen ||
document.webkitIsFullScreen ||
document.webkitFullScreen ||
document.msFullScreen
);
doChangeFullScreen(isFullScreen);
};
var doChangeFullScreen=function(isFullScreen){
if (isFullScreen) {
if(!enableNoSleep){noSleep.enable();}
$(btn_lyricFullscreen).html('退出全屏');
enableNoSleep = true;
$container.removeClass("def-lyric").addClass("fullscreen-lyric");
} else {
if(enableNoSleep){noSleep.disable();}
$(btn_lyricFullscreen).html('全屏播放');
enableNoSleep = false;
$container.removeClass("fullscreen-lyric").addClass("def-lyric");
}
$("#lyricSleep").prop("checked",enableNoSleep);
};
if (btn_lyricFullscreen) {
btn_lyricFullscreen.addEventListener('click',
function(event) {
var element = $container[0];
audio.play();
// 判断浏览器前缀
if (document.fullscreenEnabled) {
if($(btn_lyricFullscreen).html()=='全屏播放'){
if (element.requestFullscreen) {
element.requestFullscreen();
} else if (element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if (element.webkitRequestFullscreen) {
element.webkitRequestFullscreen();
} else if (element.msRequestFullscreen) {
element.msRequestFullscreen();
}
}else{
document.exitFullscreen();
}
}else{
if($(btn_lyricFullscreen).html()=='全屏播放'){
layerIndex=layer.open({
type: 1,
title: false,
content: $container,
end : function() {
isFullScreen=false;
doChangeFullScreen(false);
}
});
isFullScreen=true;
doChangeFullScreen(true);
layer.full(layerIndex);
}else{
isFullScreen=false;
doChangeFullScreen(false);
layer.close(layerIndex);
}
}
});
}
['fullscreenchange','webkitfullscreenchange','mozfullscreenchange'].forEach((item,index) => {
$container[0].addEventListener(item, () => fullScreenChangeListener());
});
var btn_lyricBigger = document.getElementById("lyricBigger");
//调节字体大小
var adjustFontSize = function (sizeOffset){
var size='',num=0;
if(isFullScreen){
var styleStr=($('#lyriccontainer').attr("style")+"");
var styleArr=$.map(styleStr.split(";"),function(node){
var returnNode=node;
if(node.indexOf("--full-font-size")>-1){
num = $.trim(node.split(":")[1]);
var unit = "vmin";
num = parseFloat(num.substring(0,num.indexOf(unit)));
num += sizeOffset;
size = num + unit;
returnNode="--full-font-size:"+size;
}
return returnNode;
});
$('#lyriccontainer').attr("style",styleArr.join(";"));
}else{
var styleStr=($('#lyriccontainer').attr("style")+"");
var styleArr=$.map(styleStr.split(";"),function(node){
var returnNode=node;
if(node.indexOf("--default-font-size")>-1){
num = $.trim(node.split(":")[1]);
var unit = "rem";
num = parseFloat(num.substring(0,num.indexOf(unit)));
num += sizeOffset;
size = num + unit;
returnNode="--default-font-size:"+size;
}
return returnNode;
});
$('#lyriccontainer').attr("style",styleArr.join(";"));
}
};
if (btn_lyricBigger) {
btn_lyricBigger.addEventListener('click',
function() {
adjustFontSize(1);
},
false);
}
var btn_lyricSmaller = document.getElementById("lyricSmaller");
if (btn_lyricSmaller) {
btn_lyricSmaller.addEventListener('click',
function() {
adjustFontSize(-1);
},
false);
}
var btn_playNext = document.getElementById("playNext");
if (btn_playNext) {
btn_playNext.addEventListener('click',
function() {
playIndex++;
doPlay();
},
false);
}
var btn_playPrev = document.getElementById("playPrev");
if (btn_playPrev) {
btn_playPrev.addEventListener('click',
function() {
playIndex--;
doPlay();
},
false);
}
var chk_lyricSleep = document.getElementById("lyricSleep");
if (chk_lyricSleep) {
chk_lyricSleep.addEventListener('change',
function(event) {
let isCheck = event.srcElement.checked;
if (isCheck) {
if(!enableNoSleep){noSleep.enable();}
enableNoSleep = true;
} else {
if(enableNoSleep){noSleep.disable();}
enableNoSleep = false;
}
});
}
});