From 751198e3d8604c2cc29a22ccc663b3c6b43dba53 Mon Sep 17 00:00:00 2001 From: lzcykevin Date: Thu, 11 Jan 2018 23:55:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=A0=87=E9=A2=98=E6=BB=9A?= =?UTF-8?q?=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lzcykevin --- js/player.js | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/js/player.js b/js/player.js index ccf09ee..1925f56 100644 --- a/js/player.js +++ b/js/player.js @@ -75,7 +75,7 @@ function orderChange() { if ( 1 === rem.order ) { orderDiv.addClass("player-btn btn-order btn-order-single") orderDiv.attr("title","单曲循环") - } + } else if ( 2 === rem.order ) { orderDiv.addClass("player-btn btn-order btn-order-list") orderDiv.attr("title","列表循环") @@ -96,9 +96,27 @@ function audioPlay() { } var music = musicList[rem.playlist].item[rem.playid]; // 获取当前播放的歌曲信息 - document.title = music.name + " - " + music.artist + " | " + rem.webTitle; // 改变浏览器标题 + var msg = " 正在播放: " + music.name + " - " + music.artist; // 改变浏览器标题 + + // 清除定时器 + if (rem.titflash !== undefined ) + { + clearInterval(rem.titflash); + } + // 标题滚动 + titleFlash(msg); } +// 标题滚动 +function titleFlash(msg) { + // 截取字符 + var tit = function() { + msg = msg.substring(1,msg.length)+ msg.substring(0,1); + document.title = msg; + }; + // 设置定时间 300ms滚动 + rem.titflash = setInterval(function(){tit()}, 300); +} // 暂停 function audioPause() { rem.paused = true; // 更新状态(已暂停) @@ -108,7 +126,12 @@ function audioPause() { $(".btn-play").removeClass("btn-state-paused"); // 取消暂停 $("#music-progress .dot-move").removeClass("dot-move"); // 小点闪烁效果 - + + // 清楚定时器 + if (rem.titflash !== undefined ) + { + clearInterval(rem.titflash); + } document.title = rem.webTitle; // 改变浏览器标题 }