newraina 9 years ago
parent
commit
e961e2d553
5 changed files with 16 additions and 15 deletions
  1. 8 8
      dist/meplayer.js
  2. 0 0
      dist/meplayer.min.js
  3. 4 3
      src/js/lyric.js
  4. 4 4
      src/js/main.js
  5. 0 0
      src/js/search.js

+ 8 - 8
dist/meplayer.js

@@ -75,9 +75,9 @@
 
 	    var musicConf = options.music,
 	        target = getTarget(options.target),
-	        theme = options.theme ? options.theme : _constants.THEME_DEFAULT,
+	        theme = options.theme || _constants.THEME_DEFAULT,
 	        hasLrc = musicConf.lrc ? true : false,
-	        coverSrc = musicConf.cover ? musicConf.cover : 'https://unsplash.it/78/?random',
+	        coverSrc = musicConf.cover || 'https://unsplash.it/78/?random',
 	        currentThemeClass = theme === _constants.THEME_DEFAULT ? 'meplayer-container' : 'meplayer-container-mini',
 	        containerClass = currentThemeClass + ' ' + (hasLrc ? 'meplayer-haslrc' : '') + ' meplayer-isloading',
 	        playerHTMLContent = '<div class="' + containerClass + '">\n                             <audio src=' + musicConf.src + '></audio>\n                             <div class="meplayer-info">\n                             <div class="meplayer-info-cover"><img src=' + coverSrc + ' alt="cd-cover"></div>\n                             <div class="meplayer-meta">\n                             <div class="meplayer-meta-title">' + musicConf.title + '</div>\n                             <div class="meplayer-meta-author">' + musicConf.author + '</div>\n                             <div class="meplayer-meta-time-tick"><span class="meplayer-meta-time-tick-text"></span></div>\n                             </div>\n                             </div>\n                             <canvas class="meplayer-spectrum"></canvas>\n                             <div class="meplayer-lyric"><div class="meplayer-lyric-area"></div></div>\n                             <div class="meplayer-control"><div class="meplayer-control-play"><i class="icon-play"></i><i class="icon-pause"></i></div></div>\n                             <div class="meplayer-volume-bg"><div class="meplayer-volume"><i class="icon-volume"></i><div class="meplayer-volume-progress"></div></div></div>\n                             <div class="meplayer-duration"><i class="icon-clock"></i><span class="meplayer-duration-text">loading</span></div>\n                             <div class="meplayer-loadingsign"><i class="icon-spin animate-spin"></i>loading</div>\n                             <div class="meplayer-timeline-bg"><div class="meplayer-timeline"><div class="meplayer-timeline-passed"></div></div></div>\n                             </div>';
@@ -101,8 +101,7 @@
 	    audio.preload = 'auto';
 
 	    if (hasLrc) {
-	        lyric.parse(musicConf.lrc);
-	        lyric.render(lyricArea);
+	        lyric.parse(musicConf.lrc).renderTo(lyricArea);
 	    } else {
 	        // 频谱动画初始化
 	        spectrum.init(canvas);
@@ -318,7 +317,7 @@
 	Object.defineProperty(exports, "__esModule", {
 	    value: true
 	});
-	exports.currentIndex = exports.render = exports.parse = undefined;
+	exports.currentIndex = exports.renderTo = exports.parse = undefined;
 
 	var _constants = __webpack_require__(1);
 
@@ -356,11 +355,11 @@
 	    });
 
 	    lyrics = lrc;
-	    return lrc;
+	    return this;
 	}
 
 	// 歌词文本解析成DOM结构
-	function render(target) {
+	function renderTo(target) {
 	    if (!lyrics) {
 	        console.error('未指定歌词文本!');
 	        return;
@@ -372,6 +371,7 @@
 	    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) {
@@ -385,7 +385,7 @@
 	}
 
 	exports.parse = parse;
-	exports.render = render;
+	exports.renderTo = renderTo;
 	exports.currentIndex = currentIndex;
 
 /***/ },

File diff suppressed because it is too large
+ 0 - 0
dist/meplayer.min.js


+ 4 - 3
src/js/lyric.js

@@ -34,11 +34,11 @@ function parse(text) {
     });
 
     lyrics = lrc;
-    return lrc;
+    return this;
 }
 
 // 歌词文本解析成DOM结构
-function render(target) {
+function renderTo(target) {
     if (!lyrics) {
         console.error('未指定歌词文本!');
         return;
@@ -50,6 +50,7 @@ function render(target) {
     target.innerHTML                        = lyricHTML;
     target.querySelector('p').className     = LYRIC_CURRENT_CLASS;
     target.querySelector('p + p').className = LYRIC_NEXT_CLASS;
+    return this;
 }
 
 function currentIndex(time) {
@@ -62,4 +63,4 @@ function currentIndex(time) {
     return i;
 }
 
-export {parse, render, currentIndex};
+export {parse, renderTo, currentIndex};

+ 4 - 4
src/js/main.js

@@ -15,9 +15,9 @@ root.mePlayer = function (options) {
 
     var musicConf         = options.music,
         target            = getTarget(options.target),
-        theme             = options.theme ? options.theme : THEME_DEFAULT,
+        theme             = options.theme || THEME_DEFAULT,
         hasLrc            = musicConf.lrc ? true : false,
-        coverSrc          = musicConf.cover ? musicConf.cover : 'https://unsplash.it/78/?random',
+        coverSrc          = musicConf.cover || 'https://unsplash.it/78/?random',
 
         currentThemeClass = theme === THEME_DEFAULT ? 'meplayer-container' : 'meplayer-container-mini',
         containerClass    = `${currentThemeClass} ${hasLrc ? 'meplayer-haslrc' : ''} meplayer-isloading`,
@@ -60,8 +60,8 @@ root.mePlayer = function (options) {
     audio.preload = 'auto';
 
     if (hasLrc) {
-        lyric.parse(musicConf.lrc);
-        lyric.render(lyricArea);
+        lyric.parse(musicConf.lrc)
+             .renderTo(lyricArea);
     } else {
         // 频谱动画初始化
         spectrum.init(canvas);

+ 0 - 0
src/js/search.js


Some files were not shown because too many files changed in this diff