1 var musicPlayer = function() {2 return this.init.apply(this, arguments);3 };4
5 musicPlayer.prototype ={6 constructor: musicPlayer,7 init: function(options) {8 if (isEmptyObj(options) || typeof options !== 'object') return;9 this.player =options.player;10 this.lrc =options.lrc;11 this.lrcArea =options.lrcArea;12 //用于保存歌词
13 this.lrcArr =[];14 //用于保存时间戳
15 this.timestamp =[];16 //处理歌词
17 this.handleLrc(this.lrc);18 var that = this;19
20 this.player.addEventListener('play',21 function() {22 that.play();23 },24 false);25
26 this.player.addEventListener('pause',27 function() {28 that.pause();29 },30 false);31
32 //歌词索引
33 this.idx = 0;34 },35 //格式化歌词
36 handleLrc: function(lrc) {37 var re = /([.+])(.+)?/gm,38 ul = cEl('ul'),39 frag =document.createDocumentFragment(),40 tmpArr,41 i,42 len;43 this.lrcArea.innerHTML = '';44 frag.appendChild(ul);45 ul.id = 'c';46 this.lrcArea.appendChild