用到的代码
---------------
function getLrc(reload)
{//pi配歌词
if (typeof(currentPlaying) != "object")
{
return 0;
}
var lrcName = fso.getbasename(currentPlaying.outerText);
var title = mplayer.currentMedia.getItemInfo("title");
var Artist = mplayer.currentMedia.getItemInfo("Artist");
var lrcPath = lrcFolder.value + "\\" + lrcName + ".lrc";
if ( (!reload) && topLrc.children.length
&& (topLrc.children[0].fileName == lrcName) )
{
showLrc1();
}else if ( fso.fileexists(lrcPath)
|| fso.fileexists(lrcPath = lrcFolder.value + "\\" + title + ".lrc" )
|| fso.fileexists(lrcPath = lrcFolder.value + "\\" + Artist + "_" + title + ".lrc" )
|| fso.fileexists(lrcPath = lrcFolder.value + "\\" + Artist + "-" + title + ".lrc" )
|| fso.fileexists(lrcPath = lrcFolder.value + "\\" + Artist + " - " + title + ".lrc")
|| fso.fileexists(lrcPath = lrcFolder.value + "\\" + Artist + " " + title + ".lrc" )
|| fso.fileexists(lrcPath = lrcFolder.value + "\\" + title + "_" + Artist + ".lrc" )
|| fso.fileexists(lrcPath = lrcFolder.value + "\\" + title + "-" + Artist + ".lrc" )
|| fso.fileexists(lrcPath = lrcFolder.value + "\\" + title + " - " + Artist + ".lrc")
|| fso.fileexists(lrcPath = lrcFolder.value + "\\" + title + " " + Artist + ".lrc" )
|| fso.fileexists(lrcPath = lrcFolder.value + "\\" + lrcName.split("_")[0] + ".lrc" )
|| fso.fileexists(lrcPath = lrcFolder.value + "\\" + lrcName.split("_")[1] + ".lrc" )
)
{
var lrcArray = new Array();
lrcArray[0] = new Array('<span t="0" fileName="' + lrcName + '"><span>歌词文件名:' + lrcName, " </span></span>");
lrcToText(lrcArray, lrcPath);
}else
{
bottomLrc.style.left = "0px";
topLrc.style.left = "0px";
bottomLrc.innerText = "";
topLrc.innerText = "硬盘中没有歌词";
}
}function lrcToText(lrcArray, lrcPath)
{//把lrc提取成可以滚动用的歌词
var fp = fso.openTextFile(lrcPath);
var lrcLine;
var lrcText = "";
var matchTime;
var lrcTime;
var offset = 0;
while (!fp.AtEndOfStream)
{
lrcLine = fp.readLine();
if (lrcLine.match(/\[ti:([^\[:\]]+)\]/gi))
{
lrcArray[0][1] = "歌曲名:" + RegExp.$1 + lrcArray[0][1] + " ";
}else if (lrcLine.match(/\[ar:([^\[:\]]+)\]/gi))
{
lrcArray[0][1] = "演唱者:" + RegExp.$1 + lrcArray[0][1] + " ";
}else if (lrcLine.match(/\[offset:([^\[:\]]+)\]/gi))
{
offset = RegExp.$1;
}else if ((matchTime = lrcLine.match(/\[\d+:\d+\.?\d+\]/g)))
{
lrcText = lrcLine.replace(/\[\d+:\d+\.?\d+\]/g,"");
while (matchTime.length)
{
lrcTime = matchTime.shift().replace(/[\[\]]/gi,"").toString().split(":");
lrcTime = lrcTime[0] * 60 + parseFloat(lrcTime[1]) + offset / 1000;
lrcArray[lrcArray.length] = new Array('<span t="' + lrcTime + '"><span>', lrcText + " </span></span>");
}
}
} fp.close();
fp = null;
if (lrcArray.length < 3)
{
return lrcArray = null;
}
lrcArray.sort(timeSort);
lrcText = lrcArray.join("").replace(/,/g, " ");
lrcArray = null;
bottomLrc.innerHTML = topLrc.innerHTML = lrcText;
setLrcWidth();
}function setLrcWidth()
{//设置歌词外框宽度
for (var ii=0; ii < topLrc.children.length; ++ii)
{
bottomLrc.children[ii].style.width = topLrc.children[ii].style.width = topLrc.children[ii].offsetWidth;
bottomLrc.children[ii].children[0].style.display = topLrc.children[ii].children[0].style.display = "none";
}
showLrc1();
}function timeSort(timeA, timeB)
{//把乱xi的歌词按时间大小排序
return parseFloat(timeA[0].split('t="')[1]) - parseFloat(timeB[0].split('t="')[1]);
}function lrcDisplay(i)
{//显示右边的歌词
bottomLrc.children[i].children[0].style.display = topLrc.children[i].children[0].style.display = "inline";
}function lrcHidden(i)
{//隐匿已过左边的歌词
try{
bottomLrc.children[i].children[0].style.display = topLrc.children[i].children[0].style.display = "none";
}catch(e){}
}function setLrcLeft(px)
{//设置歌词左边距达到滚动效果
lrcLeft -= px;
topLrc.style.left = bottomLrc.style.left = lrcLeft;
}
function lrcScroll()
{//定时设置歌词左边距达到滚动效果 if (lastLrcWidth < 1)
{
clearInterval(lrcScrollTimer);
}
--lrcLeft;
topLrc.style.left = bottomLrc.style.left = lrcLeft;
--lastLrcWidth;
}function chanleLrc()
{//取消歌词滚动
clearTimeout(showLrcTimer);
clearInterval(lrcScrollTimer);
clearTimeout(scrollTimer);
}function showLrc1()
{//调用showLRc2,lrc滚动入口,初始化
lastLrcWidth = 0;
bottomLrc.style.left = "0px";
topLrc.style.left = "0px";
lrcLeft = 0;
showLrc2(0);
}function showLrc2(childI)
{//像素级变色滚动
lrcDisplay(childI);
var timeA = topLrc.children[childI].t * 1;
var lrcWidth = topLrc.children[childI].offsetWidth;
//document.title = topLrc.children[childI].innerText;
try{
lrcDisplay(childI + 1); //将会导致出错的一句
var timeB = topLrc.children[childI + 1].t * 1;
var tLen = parseInt((timeB - mplayer.controls.currentPosition) * 1000);
chanleLrc();
if (tLen < 1)
{
lrcHidden(childI - 2);
setLrcLeft(lrcWidth);
showLrc2(childI + 1);
}else
{
clearInterval(lrcScrollTimer);
setLrcLeft(lastLrcWidth);
lastLrcWidth = lrcWidth;
lrcScrollTimer = setInterval("lrcScroll();", tLen / lrcWidth );
showLrcTimer = setTimeout("lrcHidden(" + (childI - 2) + "); showLrc2(" + (childI + 1) + ")", tLen);
}
}catch(e)
{//出错了,最后没有对象了
scrollTimer = setInterval("setLrcLeft(1)", 85);
showLrcTimer = setTimeout("chanleLrc();"
+ "lrcHidden(" + (childI - 2) + ");"
+ "lrcHidden(" + (childI - 1) + ");"
+ "lrcHidden(" + childI + ");", 200 + lrcWidth * 85);
}
}
---------------
function getLrc(reload)
{//pi配歌词
if (typeof(currentPlaying) != "object")
{
return 0;
}
var lrcName = fso.getbasename(currentPlaying.outerText);
var title = mplayer.currentMedia.getItemInfo("title");
var Artist = mplayer.currentMedia.getItemInfo("Artist");
var lrcPath = lrcFolder.value + "\\" + lrcName + ".lrc";
if ( (!reload) && topLrc.children.length
&& (topLrc.children[0].fileName == lrcName) )
{
showLrc1();
}else if ( fso.fileexists(lrcPath)
|| fso.fileexists(lrcPath = lrcFolder.value + "\\" + title + ".lrc" )
|| fso.fileexists(lrcPath = lrcFolder.value + "\\" + Artist + "_" + title + ".lrc" )
|| fso.fileexists(lrcPath = lrcFolder.value + "\\" + Artist + "-" + title + ".lrc" )
|| fso.fileexists(lrcPath = lrcFolder.value + "\\" + Artist + " - " + title + ".lrc")
|| fso.fileexists(lrcPath = lrcFolder.value + "\\" + Artist + " " + title + ".lrc" )
|| fso.fileexists(lrcPath = lrcFolder.value + "\\" + title + "_" + Artist + ".lrc" )
|| fso.fileexists(lrcPath = lrcFolder.value + "\\" + title + "-" + Artist + ".lrc" )
|| fso.fileexists(lrcPath = lrcFolder.value + "\\" + title + " - " + Artist + ".lrc")
|| fso.fileexists(lrcPath = lrcFolder.value + "\\" + title + " " + Artist + ".lrc" )
|| fso.fileexists(lrcPath = lrcFolder.value + "\\" + lrcName.split("_")[0] + ".lrc" )
|| fso.fileexists(lrcPath = lrcFolder.value + "\\" + lrcName.split("_")[1] + ".lrc" )
)
{
var lrcArray = new Array();
lrcArray[0] = new Array('<span t="0" fileName="' + lrcName + '"><span>歌词文件名:' + lrcName, " </span></span>");
lrcToText(lrcArray, lrcPath);
}else
{
bottomLrc.style.left = "0px";
topLrc.style.left = "0px";
bottomLrc.innerText = "";
topLrc.innerText = "硬盘中没有歌词";
}
}function lrcToText(lrcArray, lrcPath)
{//把lrc提取成可以滚动用的歌词
var fp = fso.openTextFile(lrcPath);
var lrcLine;
var lrcText = "";
var matchTime;
var lrcTime;
var offset = 0;
while (!fp.AtEndOfStream)
{
lrcLine = fp.readLine();
if (lrcLine.match(/\[ti:([^\[:\]]+)\]/gi))
{
lrcArray[0][1] = "歌曲名:" + RegExp.$1 + lrcArray[0][1] + " ";
}else if (lrcLine.match(/\[ar:([^\[:\]]+)\]/gi))
{
lrcArray[0][1] = "演唱者:" + RegExp.$1 + lrcArray[0][1] + " ";
}else if (lrcLine.match(/\[offset:([^\[:\]]+)\]/gi))
{
offset = RegExp.$1;
}else if ((matchTime = lrcLine.match(/\[\d+:\d+\.?\d+\]/g)))
{
lrcText = lrcLine.replace(/\[\d+:\d+\.?\d+\]/g,"");
while (matchTime.length)
{
lrcTime = matchTime.shift().replace(/[\[\]]/gi,"").toString().split(":");
lrcTime = lrcTime[0] * 60 + parseFloat(lrcTime[1]) + offset / 1000;
lrcArray[lrcArray.length] = new Array('<span t="' + lrcTime + '"><span>', lrcText + " </span></span>");
}
}
} fp.close();
fp = null;
if (lrcArray.length < 3)
{
return lrcArray = null;
}
lrcArray.sort(timeSort);
lrcText = lrcArray.join("").replace(/,/g, " ");
lrcArray = null;
bottomLrc.innerHTML = topLrc.innerHTML = lrcText;
setLrcWidth();
}function setLrcWidth()
{//设置歌词外框宽度
for (var ii=0; ii < topLrc.children.length; ++ii)
{
bottomLrc.children[ii].style.width = topLrc.children[ii].style.width = topLrc.children[ii].offsetWidth;
bottomLrc.children[ii].children[0].style.display = topLrc.children[ii].children[0].style.display = "none";
}
showLrc1();
}function timeSort(timeA, timeB)
{//把乱xi的歌词按时间大小排序
return parseFloat(timeA[0].split('t="')[1]) - parseFloat(timeB[0].split('t="')[1]);
}function lrcDisplay(i)
{//显示右边的歌词
bottomLrc.children[i].children[0].style.display = topLrc.children[i].children[0].style.display = "inline";
}function lrcHidden(i)
{//隐匿已过左边的歌词
try{
bottomLrc.children[i].children[0].style.display = topLrc.children[i].children[0].style.display = "none";
}catch(e){}
}function setLrcLeft(px)
{//设置歌词左边距达到滚动效果
lrcLeft -= px;
topLrc.style.left = bottomLrc.style.left = lrcLeft;
}
function lrcScroll()
{//定时设置歌词左边距达到滚动效果 if (lastLrcWidth < 1)
{
clearInterval(lrcScrollTimer);
}
--lrcLeft;
topLrc.style.left = bottomLrc.style.left = lrcLeft;
--lastLrcWidth;
}function chanleLrc()
{//取消歌词滚动
clearTimeout(showLrcTimer);
clearInterval(lrcScrollTimer);
clearTimeout(scrollTimer);
}function showLrc1()
{//调用showLRc2,lrc滚动入口,初始化
lastLrcWidth = 0;
bottomLrc.style.left = "0px";
topLrc.style.left = "0px";
lrcLeft = 0;
showLrc2(0);
}function showLrc2(childI)
{//像素级变色滚动
lrcDisplay(childI);
var timeA = topLrc.children[childI].t * 1;
var lrcWidth = topLrc.children[childI].offsetWidth;
//document.title = topLrc.children[childI].innerText;
try{
lrcDisplay(childI + 1); //将会导致出错的一句
var timeB = topLrc.children[childI + 1].t * 1;
var tLen = parseInt((timeB - mplayer.controls.currentPosition) * 1000);
chanleLrc();
if (tLen < 1)
{
lrcHidden(childI - 2);
setLrcLeft(lrcWidth);
showLrc2(childI + 1);
}else
{
clearInterval(lrcScrollTimer);
setLrcLeft(lastLrcWidth);
lastLrcWidth = lrcWidth;
lrcScrollTimer = setInterval("lrcScroll();", tLen / lrcWidth );
showLrcTimer = setTimeout("lrcHidden(" + (childI - 2) + "); showLrc2(" + (childI + 1) + ")", tLen);
}
}catch(e)
{//出错了,最后没有对象了
scrollTimer = setInterval("setLrcLeft(1)", 85);
showLrcTimer = setTimeout("chanleLrc();"
+ "lrcHidden(" + (childI - 2) + ");"
+ "lrcHidden(" + (childI - 1) + ");"
+ "lrcHidden(" + childI + ");", 200 + lrcWidth * 85);
}
}
支持下!