<span id=menu onblur="hideListMenu()" onclick="hideListMenu()" style="padding:4px; color:orange; border:1px dashed white; height:200px; width:200px; white-space:nowrap; overflow:auto; position:absolute; display:none; background:green;" type="disc">
<li onclick="if (typeof(currentPlaying) == 'object'){currentPlaying.scrollIntoView(1)}">显示播放歌曲
<li onclick="delList(listMenuSrc);">删除选中歌曲
<li onclick="delList(currentPlaying);">删除播放中歌曲
<li onclick="getfile(getFilePath());">添加单首歌曲
<li onclick="showDrivers('getallfolder(folderSpan.path)');">添加歌曲文件夹
<li onclick="openWeb(prompt('输入音乐网址(不是音乐文件下载地址)',''));">添加网络歌曲
<li onclick="clearList()">清空播放列表
<li onclick="delDeadList()">删除本地不存在列表
<li onclick="saveList()">保存播放列表
<li onclick="loadList(getFilePath())">载入播放列表
<li onclick="showDrivers('downMusic(folderSpan.path)');">下载正播放中的文件
<li onclick="showRenameBar(listMenuSrc);">重命名选中歌曲
<li onclick="showFolder(listMenuSrc.filePath)">浏览选中文件
<li onclick="showDrivers('sendTo(listMenuSrc.filePath,folderSpan.path)');">发送到...
<li onclick="showSearch()">查找
<li onclick="showSettingSpan()">播放器设置
<li onclick="showFolder(lrcFolder.value)">打开歌词目录
<li onclick="showFolder(htaPath)">打开程序目录
<li onclick="viewSource()">查看源代码
<li onclick="showTestWin()">打开测试窗口
</span></div></body>
</html>
<script>function reportError(msg,url,line)
{
alert("当前页的脚本发生错误: \n\n信息: " + msg + "\n\n行:" + line);
return true;
}
window.onerror = reportError;function show(html)
{
alertSpan.style.display = "";
alertSpan.innerHTML = '<input type=button value=隐藏提示信息 onclick="alertSpan.style.display = \'none\';"><br>' + html;
}</script><script>var fso = new ActiveXObject("Scripting.FileSystemObject");
var runtime = 100;
var foldersarray;
var fsotime;
var fp = null;
var currentFolder;//文件夹数组的下标
var playTimer;
var htaPath = fso.getparentfoldername(unescape(location.pathname).match(/[a-z]\:[^\:\.]+\.hta$/gi)) + "\\";//根目录
var defaultList = htaPath + "QplayerList";//默认播放列表
var lrcTimer;//定时显示歌词
var webTimer;//测试网页载入状态
var listMenuSrc = undefined;//列表点左键对象
var showList = 0; //显示当前歌曲列表
var scrollTimer;//定时滚动句柄
var showLrcTimer;//换歌词句柄
var lrcLeft;
var positioner; //position 定时句柄
var moveObj = null;//移动对象
var winWidth = 0;//窗口横向边框宽度
var winHeight = 0; //窗口坚向边框宽度
var thisLrcWidth = 0;//当前lrcfunction getFilePath()
{
filePath.click();
return filePath.value;
}function showFolders(obj, click)
{
if (obj.tagName != "LI")
{
return 0;
}
if (click)
{//点击,选择
if (obj.disabled == false)
{
if (typeof(selectedPath) == "object")
{
selectedPath.removeAttribute("id");
}
obj.id = "selectedPath";
folderSpan.path = obj.path;
}
}else if (obj.type == "disc")
{
if ( (obj.nextSibling == null) || (obj.nextSibling.tagName == "LI"))
{//展开
var drvs = new Enumerator(fso.getfolder(obj.path).SubFolders);
var drvsText = '<dir>';
var drv;
var liType;
var folderL;
for (; !drvs.atEnd(); drvs.moveNext())
{
drv = drvs.item();
liType = "circle";
try
{
folderL = fso.getfolder(drv).SubFolders.count;
}catch(e)
{
folderL = 0;
}
if (folderL)
{//有文件夹
liType = "disc";
}
drvsText += '<li type="' + liType + '" path="' + drv.path + '">' + drv.name;
}
drvsText += '</dir>';
obj.insertAdjacentHTML("afterEnd",drvsText);
}else
{
obj.nextSibling.outerHTML = "";
}
}
}function showDrivers(functionH)
{
folderSpan.evalText = functionH;
folderSpan.style.display = "";
var drvs = new Enumerator(fso.Drives);
var drvsText = '<input type=button value="取消" onclick="folderSpan.style.display =\'none\'; folderSpan.evalText = \'\'; folderSpan.path = \'\';">';
drvsText += '<input type=button value="确定" onclick="folderSpan.style.display =\'none\'; eval(folderSpan.evalText);">';
drvsText += '<dir id=myDrivers ondblclick="showFolders(event.srcElement, 0)" onclick="showFolders(event.srcElement, 1)" style="width:255px; height:310px; overflow:auto;">';
var drv;
var liType;
var disabled;
var typeText;
var folderL;
for (; !drvs.atEnd(); drvs.moveNext())
{
drv = drvs.item();
liType = "circle";
disabled = " disabled";
typeText = "本地磁盘"; if (drv.IsReady)
{//可用
disabled = "";
try
{
folderL = fso.getfolder(drv.rootfolder).SubFolders.count;
}catch(e)
{
folderL = 0;
}
if (folderL)
{//有文件夹
liType = "disc";
}
drvsText += '<li type="' + liType + '" path="' + drv.rootfolder + '"' + disabled + '>' + typeText + drv.VolumeName + "(" + drv.DriveLetter + ")";
}else
{
switch (drv.DriveType)
{
case 0: typeText = "未知设置"; break;
case 1: typeText = "移动磁盘"; break;
case 2: typeText = "软盘"; break;
case 3: typeText = "网络磁盘"; break;
case 4: typeText = "光驱"; break;
case 5: typeText = "闪存磁盘"; break;
} drvsText += '<li type="' + liType + '" path="' + drv + '"' + disabled + '>' + typeText + "(" + drv.DriveLetter + ")";
}
}
drvsText += '</dir>';
folderSpan.innerHTML = drvsText;
}
{
if (url == null)
{
return 0;
}else if (url.match(/^http\:\/\/.*\..+\..+/gi) == null)
{
return show("网页地址格式不对");
}
winSpan.style.display = "";
winSpan.innerHTML = '<iframe id=win style="scrollbar-face-color: black;width:100%;height:280px;"'
+ ' src="' + url + '">'
+ '</iframe>'
+ '<input type=button value=关闭网页'
+ ' onclick="winSpan.innerHTML =\'\'; winSpan.style.display = \'none\';" style="width:55px;'
+ 'border:1px solid red;background:orange;">'
+ '<input type=button value=添加剪贴板音乐链接'
+ ' onclick="addlist(window.clipboardData.getData(\'Text\'));" style="width:119px;'
+ ' border:1px solid red;background:orange;">'
+ '<input type=button value=自动提取音乐链接'
+ ' onclick="addMusicLinks(0);" style="width:107px;'
+ ' border:1px solid red;background:orange;">';
}function addMusicLinks(linkI)
{//添加打开的网页中所有的音乐链接
try
{
var theLinks = win.document.links;
if (linkI < theLinks.length)
{
if ( theLinks[linkI].href.match(/^.+\.(midi?)|(mp3)$/gi) != null)
{
list.insertAdjacentHTML("beforeEnd",'<li filePath="'
+ theLinks[linkI].href + '">' + theLinks[linkI].outerText );
}
clearTimeout(fsotime);
fsotime = setTimeout("addMusicLinks(" + (linkI + 1) + ");", runtime);
}else
{
show("自动查找网页音乐链接并添加完成");
}
}catch(e)
{
win = null;
return show("网页对象win不可用,可能是没打开音乐网页,或已关闭了");
}
}function getfile(path)
{
if ( fso.fileExists(path))
{
addlist(path);
}else if (path != "")
{
show("出错啦!\n[" + path + "] 文件不存在!");
}
} function getallfolder(path)
{
if ( fso.fileExists(path) || fso.folderExists(path))
{
fsotime = null;
mygetfolder(path);
}else
{
show("出错啦!\n[" + path + "] 文件夹不存在!");
}
}function mygetfolder(path){//自己递归时没参数 if(path != undefined)
{
clearTimeout(fsotime);
fp = null;
currentFolder = 0;
foldersarray = new Array(fso.getFolder(path).path);
} try
{
if(fp == null)
{
var folderObj = fso.getFolder(foldersarray[currentFolder++]);
//show('正在获取后面文件夹下的文件夹...<br>' + folderObj);
fp = new Enumerator(folderObj.subFolders);
}
}catch(e)
{
//show("已把所有文件夹读取完成");
fp = null;
clearTimeout(fsotime);
return doallfile();
} if(!fp.atEnd())
{
foldersarray[foldersarray.length] = fp.item().path;
fp.moveNext();
}
else
{
fp = null;
}
clearTimeout(fsotime);
if (fsotime == "abort")
{
show("文件夹读取的操作已被取消");
}else
{
fsotime = setTimeout("mygetfolder()",runtime);
}
}function doallfile(start){
try
{
foldersarray.length < 1;
}catch(e)
{
return show("请先点[获取全部文件夹]获取要处理的文件夹对象");
} if(fp == null)
{
try
{
fp = new Enumerator(fso.getfolder(foldersarray.shift()).files);
}catch(e)
{
show("已完成音乐文件添加");
theno = fp = nowi = null;
return clearTimeout(fsotime);
}
} if(!fp.atEnd())
{
try
{
addlist( fp.item().path );
}catch(E)
{
show("执行自定义处理文件方法时出错:" + E.description);
}
fp.moveNext();
}
else
{
fp = null;
} clearTimeout(fsotime);
if (fsotime == "abort")
{
show("文件读取的操作已被取消");
}else
{
fsotime = setTimeout("doallfile(1)",runtime);
}}function addlist(filePath, fileName)
{
if ( (filePath.indexOf(":") == 1)
&& (/^[a-z]:[\\\/][^:]+\.(?:mp3)|(?:mid)|(?:midi)|(?:wma)|(?:asf)|(?:wmv)|(?:avi)|(?:wav)|(?:au)|(?:ape)$/gi.test(filePath) == false) )
{//非以上格式文件 不加
return 0;
} if (fileName == undefined)
{
fileName = filePath;
}
//show('添加:<br>' + filePath);
switch (musicTitle.value)
{
case "文件名.格式":
fileName = fso.getfile(fileName).name;
break;
case "文件名":
fileName = fso.getbasename(fileName);
break;
case "完整路径":
;
break;
}
list.insertAdjacentHTML("beforeEnd",'<li filePath="' + filePath + '">' + fileName );
}function changePlayMode()
{
switch(playMode.innerText)
{
case "`"://顺序
playMode.alt = "随机选择";
playMode.innerText = "-";//随机
break;
case "-":
playMode.innerText = "q";//单曲连播
playMode.alt = "单曲循环";
break;
case "q":
playMode.innerText = "`";
playMode.alt = "顺序和循环";
break;
}
}function playPause(obj)
{
if (mplayer.controls.isAvailable('pause'))
{
mplayer.controls.pause();
}else if (mplayer.controls.isAvailable('play'))
{
mplayer.controls.play();
}
}function stopPlayer()
{
mplayer.controls.stop();
}function changeVol()
{
if (moveObj != null)
{
var theNum = event.x - moveObj.offsetLeft;
if ((theNum > -1) && (theNum < 51))
{
volNumber.innerText = "音量" + theNum * 2 + "%";
volBar.style.width = theNum;
mplayer.settings.volume = theNum * 2;
}
}
}
function positionStart(obj)
{
if (mplayer.controls.isAvailable("currentPosition"))
{
moveObj = obj;
obj.setCapture(true);
clearInterval(positioner);
changePosition();
}
}function changePosition()
{
if (moveObj != null)
{
var theNum = event.x - moveObj.offsetLeft;
if ((theNum > -1) && (theNum < 101))
{
positionBar.style.width = theNum;
var len = mplayer.currentMedia.duration * theNum / 100
positionNum.innerText = Math.floor(len / 3600) + ":" + Math.floor((len % 3600) / 60) + ":" + Math.floor(len % 60);
}
}
}function positionEnd()
{
if (moveObj != null)
{
moveObj.releaseCapture();
moveObj=null;
mplayer.controls.currentPosition = parseInt(positionBar.style.width) * mplayer.currentMedia.duration / 100;
}
}function setPosition()
{
try
{
positionNum.innerText = mplayer.controls.currentPositionString;
positionBar.style.width = mplayer.controls.currentPosition * 100 / mplayer.currentMedia.duration;
}catch(e){}
}function playNewMusic(how)
{
if (list.children.length == 0)
{
return 0;
}
if (typeof(currentPlaying) != "object")
{
list.firstChild.id = "currentPlaying";
}
switch(playMode.innerText)
{
case "`"://顺序重复列表
if (how > 0)
{
if (currentPlaying == list.lastChild)
{
playthis(list.firstChild);
}else
{
playthis(currentPlaying.nextSibling);
}
}else
{
if (currentPlaying == list.firstChild)
{
playthis(list.lastChild);
}else
{
playthis(currentPlaying.previousSibling);
}
}
break;
case "-"://随机列表歌曲
if (list.length == 1)
{
playthis(currentPlaying.fistChild);
}else
{
var newLi = list.children[Math.ceil(list.children.length * Math.random())];
playthis(newLi);
}
break;
case "q"://单曲重复播放
playthis(currentPlaying);
break;
}
}function clickPlay(obj)
{
if (obj.tagName != "LI")
{
return 0;
}
if(typeof(currentPlaying) != "object")
{
obj.id = "currentPlaying";
}
playthis(obj);
}function playthis(srcObj, state, position)
{
if (typeof(currentPlaying) == "object")
{
playingAttribute(currentPlaying, 0);
}
playingAttribute(srcObj, 1);
mplayer.url = currentPlaying.filePath;
if ( (position = parseInt(position)) > 0)
{
mplayer.controls.currentPosition = position;
}
document.title = currentPlaying.outerText;
if (state != 1)
{//1,stop; other,playing
mplayer.controls.play();
}
if (showList && (showPlaying.value * 1))
{
currentPlaying.scrollIntoView(1);
}
}function playingAttribute(srcObj, how)
{
if (how)
{
srcObj.id = "currentPlaying";
srcObj.style.color = listPlayColor.value;
}else
{
currentPlaying.removeAttribute("style");
currentPlaying.removeAttribute("id");
}
}function showListMenu(obj)
{
menu.style.display = '';
menu.focus();
menu.style.top = event.clientY;
menu.style.left = event.clientX;
listMenuSrc = obj;
if (obj.tagName == "LI")
{
listMenuSrc.style.background = "yellow";
}
}function hideListMenu()
{
listMenuSrc.style.background = "";
menu.style.display = "none";
}function delList(EObj, auto)
{
if (
(typeof(EObj) == "object") && (EObj.tagName == "LI")
&& ( (auto == "yes") || confirm(EObj.outerHTML + "\n\n确定要删除这条列表?") ) )
{
var filePath = EObj.filePath;
var nextLi;
if (EObj.id == "currentPlaying")
{
if ( ((nextLi = EObj.nextSibling) != null)
|| ((nextLi = EObj.previousSibling) != null) )
{
currentPlaying.removeAttribute("id");
EObj.outerHTML = "";
playthis(nextLi);
}else
{
mplayer.close();
currentPlaying.removeAttribute("id");
EObj.outerHTML = "";
}
}else
{
EObj.outerHTML = "";
}
if (fso.fileexists(filePath) && confirm("同时删除硬盘中的文件?"))
{
try
{
fso.DeleteFile (filePath, 1);
if (alertDel.value == "提示")
{
show(filePath + "删除成功");
}
}catch(e)
{
show("未明原因,无法删除" + filePath + "\n\n" + e.description);
}
}
filePath = lrcFolder.value + "\\ " + fso.getbasename(filePath) + ".lrc";
if ( fso.fileexists(filePath) && (delLrc.value == "立刻删除")
|| ((delLrc.value == "提示删除") && confirm("同时删除硬盘中同名的歌词文件?"))
)
{
try
{
fso.DeleteFile (filePath, 1);
if (alertDel.value == "提示")
{
show(filePath + "删除成功");
}
}catch(e)
{
show("未明原因,无法删除" + filePath + "\n\n" + e.description);
}
}
}
}function showSearch()
{
show('输入要查找文字后回车<br>'
+ '<input onkeydown="searchStart(this);" style="width:100%;" index=0>'
+ '<BR><span id=found></span>');
}function searchStart(obj)
{
var index = obj.index * 1;
var text;
if ((event.keyCode == 13) && (obj.value.match(/^ *$/g) == null))
{
for (; index < list.children.length; ++index)
{
text = list.children[index].innerText;
if (text.indexOf(obj.value) > -1)
{
found.innerHTML = '<input type=button value="点击播放[' + text + ']"'
+ ' onclick="clickPlay(list.children[' + index + '])">';
return obj.index = index + 1;
}
}
obj.index = 0;
found.innerHTML = '查找结束';
}
}function showRenameBar(obj)
{
if ( (typeof(obj) == "object") && (obj.tagName == "LI"))
{
if (!fso.fileExists(obj.filePath))
{//找不到文件了
show("找不到[" + obj.filePath + "]文件.<br>可能已被删除或移动!");
}else
{
show("请更改文件名后按回车键<br><span id=reNameAlert style='color:red;'></span><BR>"
+ '<input value="' + fso.getBaseName(obj.filePath) + '" '
+ 'onkeyDown="if(event.keyCode == 13){renameList(this.value)}" >.'
+ fso.GetExtensionName(obj.filePath));
}
}
}
{
try
{
if (mplayer.url == listMenuSrc.filePath)
{
playNewMusic(1);
}
var newPath = fso.GetParentFolderName(listMenuSrc.filePath) + "\\"
+ newName + '.' + fso.GetExtensionName(listMenuSrc.filePath);
fso.MoveFile(listMenuSrc.filePath, newPath);
var lrcOld = lrcFolder.value + "\\" + fso.getBaseName(listMenuSrc.filePath) + '.lrc';
if (fso.fileExists(lrcOld))
{//更改同名歌词名
fso.MoveFile(lrcOld, lrcFolder.value + "\\" + newName + '.lrc');
}
listMenuSrc.filePath = newPath;
listMenuSrc.innerText = newName;
reNameAlert.innerText = '重命名成功';
setTimeout("alertSpan.style.display = 'none';", 1000);
}catch(e){
reNameAlert.innerText = '重命名出错:' + e.description;
}
}function clearList()
{
if (typeof(currentPlaying) == "object")
{
currentPlaying.removeAttribute("id");
}
list.innerHTML = "";
currentFolder = undefined;
}function delDeadList()
{
for (var listI = 0; listI < list.children.length; ++listI)
{
if (
(fso.GetDriveName(list.children[listI].filePath) != "")
&& ( !fso.fileExists(list.children[listI].filePath) ) )
{
delList(list.children[listI], "yes");
}
}
show("清除无用列表完成");
}function getLrc(reload)
{
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 style="display:none;">歌词文件名:' + lrcName, " </span></span>");
lrcToText(lrcArray, lrcPath);
}else
{
bottomLrc.style.left = "0px";
topLrc.style.left = "0px";
bottomLrc.innerText = "";
topLrc.innerText = "硬盘中没有歌词";
}
}function lrcToText(lrcArray, lrcPath)
{
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 style="display:none;">', 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;
showLrc1();
}function timeSort(timeA, timeB)
{
var a = parseFloat(timeA[0].split('t="')[1]);
var b = parseFloat(timeB[0].split('t="')[1]);
if ( a < b)
{
return -1;
}else if (a == b)
{
return 0;
}else
{
return 1;
}
}function lrcDisplay(i)
{
bottomLrc.children[i].children[0].style.display = topLrc.children[i].children[0].style.display = "inline";
bottomLrc.children[i].style.width = topLrc.children[i].style.width = topLrc.children[i].offsetWidth;
}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 moveLrcLeft(endT, lrcWidth)
{
clearTimeout(lrcTimer);
setLrcLeft(1);
--lrcWidth;
var evalText = 'moveLrcLeft(' + endT + ',' + lrcWidth + ')';
if ( (lrcWidth < 2) || ( (endT - new Date().getTime()) < 10 ) )
{
setLrcLeft(lrcWidth);
}else
{
lrcTimer = setTimeout(evalText, parseInt((endT - new Date().getTime())/ lrcWidth) );
}
}function chanleLrc()
{
clearTimeout(showLrcTimer);
clearTimeout(lrcTimer);
clearTimeout(scrollTimer);
}function showLrc1()
{
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);
}catch(e)
{//出错了,最后没有对象了
scrollTimer = setInterval("setLrcLeft(1)", 85);
showLrcTimer = setTimeout("chanleLrc();"
+ "lrcHidden(" + (childI - 2) + ");"
+ "lrcHidden(" + (childI - 1) + ");"
+ "lrcHidden(" + childI + ");", 200 + lrcWidth * 85);
return 0;
}
var timeB = topLrc.children[childI + 1].t * 1;
var tLen = parseInt((timeB - mplayer.controls.currentPosition) * 1000);
chanleLrc();
lrcHidden(childI - 2);
if (tLen < 1)
{
setLrcLeft(lrcWidth);
showLrc2(childI + 1);
}else
{
showLrcTimer = setTimeout("showLrc2(" + (childI + 1) + ")", tLen);
moveLrcLeft(new Date().getTime()+tLen, lrcWidth);
}
}
function showLrcButton(yes)
{
if (yes)
{
lrcButton.style.display = "";
}else
{
lrcButton.style.display = "none";
}
}function searchLrc()
{
if (typeof(currentPlaying) != "object")
{
return 0;
}
if (!showList)
{
winState.click();
}
var lrcName = fso.getbasename(currentPlaying.outerText);
try
{
searchWin.location;
}catch(e)
{
winSpan.innerHTML = '<iframe id=searchWin style="width:299px;height:350px;"'
+ 'src="http://lrc.aspxp.net">'
+ '</iframe>'
+ '<input type=button value=点此关闭搜索窗口'
+ ' onclick="closeSearchWin()" style="width:45%;'
+ ' border:1px solid red;background:orange;">'
+ ' | <input id=downButton type=button value=点此下载剪贴板的链接 lrcName=""'
+ ' onclick="downLrc(this.lrcName);" style="width:45%;'
+ ' border:1px solid red;background:orange;">';
}
winSpan.style.display = "";
downButton.lrcName = lrcName;
typeLrcName(lrcName);
}
function closeSearchWin()
{
winSpan.style.display = 'none';
}function typeLrcName(lrcName)
{
if(searchWin.document.readyState == "complete")
{
var typeObj = searchWin.document.getElementById("ti");
typeObj.value = lrcName;
typeObj.scrollIntoView(true);
searchWin.document.getElementsByName("f")[1].checked = true;
}else
{
clearTimeout(webTimer);
webTimer = setTimeout("typeLrcName('" + lrcName + "')",500);
}
}function downLrc(lrcName)
{
var url = window.clipboardData.getData('Text');
var lrcPath = lrcFolder.value + "\\" + lrcName + ".lrc";
if (url.match(/http:\/\/.+/gi))
{
downFile(url, lrcPath, 0);
}
}function downMusic(theFolder)
{
if( (mplayer.url != "") && (typeof(currentPlaying) == "object") )
{
if (currentPlaying.filePath.indexOf(":") == 1)
{
return show("现在播放中的是磁盘文件,不需再下载!");
}
if (fso.folderExists(theFolder) == false)
{
return show("找不到" + theFolder + "文件夹\n\n请选择保存路径");
}
var fileType = mplayer.url.match(/\.[^\.]+$/gi);
var thePath = theFolder + "\\" + currentPlaying.outerText + fileType;
var oldName = currentPlaying.outerText.replace(/[》《]/gi,"");
thePath = prompt("现在的路径是:" + thePath + ":要更改吗?请输入文件名",oldName);
if (thePath == null)
{
return 0;
}
thePath = theFolder + "\\" + thePath.replace(/[\\\/\:\*\?\"\<\>\|]/gi,"&") + fileType;
if (fso.fileExists(thePath) && (confirm("文件" + thePath + "已存在!\n\n要替换吗?") == false) )
{
return 0;
}
downFile(mplayer.url, thePath, 1);
}
}
function downFile(url, filePath, tip)
{
try
{
var xmlHTTP=new ActiveXObject("Microsoft.XMLHTTP");
xmlHTTP.open("Get", url, false);
xmlHTTP.send();
var bite = xmlHTTP.responseBody;
xmlHTTP = null;
}catch(e)
{
return show("下载文件" + url + "出错! 下载文件操作已取消!\n\n" + e.description);
}
try
{
var adodbStream=new ActiveXObject("ADODB.Stream");
adodbStream.Type=1;
adodbStream.Open();
adodbStream.write(bite);
adodbStream.SaveToFile(filePath, 2);
adodbStream.Close();
adodbStream = null;
if (tip)
{
show("下载,保存文件完成");
}
reloadLrc();
} catch(e)
{
return show("保存文件" + filePath + "出错! 保存文件操作已取消!\n\n" + e.description);
}
}function reloadLrc()
{
chanleLrc();
getLrc(1);
}function showFolder(path)
{
var wshshell = new ActiveXObject("WScript.Shell");
wshshell.run('Explorer /select,"' + path + '"');
wshshell = null;
}function sendTo(pathFrom, pathTo)
{
try
{
fso.copyFile(pathFrom, pathTo, false);
show("发送完成");
}catch(e)
{
show("复制文件出错:" + e.description);
}
}function showEditLrcSpan()
{
if (typeof(currentPlaying) != "object")
{
return 0;
}
if (!showList)
{
winState.click();
}
var lrcName = fso.getbasename(currentPlaying.outerText);
var lrcPath = lrcFolder.value + "\\" + lrcName + ".lrc";
if (!fso.fileexists(lrcPath))
{
editText.value = "";
}else
{
editLrcFile.value = lrcName;
editLrcTitle.value = "";
editLrcAuthor.value = "";
editLrcArtist.value = "";
editLrcEditer.value = "qidizi";
lrcPath = fso.openTextFile(lrcPath, 1, false, false);
editText.value = lrcPath.readAll().replace(/\[[^\[\]:]*:[^\[\]:]*\]/g,"").replace(/^\r\n/gm,"");
lrcPath.close();
lrcPath = null;
}
editLrcSpan.style.display = "";
}function showLrcFile()
{
if (typeof(currentPlaying) != "object")
{
return 0;
}
var lrcName = fso.getbasename(currentPlaying.outerText);
var lrcPath = lrcFolder.value + "\\" + lrcName + ".lrc";
var wshshell = new ActiveXObject("WScript.Shell");
wshshell.run('Notepad.exe "' + lrcPath);
wshshell = null;
}function delLrcFile()
{
if (typeof(currentPlaying) != "object")
{
return 0;
}
var lrcName = fso.getbasename(currentPlaying.outerText);
var lrcPath = lrcFolder.value + "\\" + lrcName + ".lrc";
try
{
fso.deleteFile(lrcPath);
show("歌词已删除");
}catch(e)
{
show("删除歌词出错:" + e.description);
}
}
function typeTime()
{
var position = mplayer.controls.currentPositionString;
if ( enableType.checked
&& (editText.document.selection.type == "Text")
&& (position != "")
)
{
editText.document.selection.createRange().text = "[" + position + "]";
}
}function editLrcSave()
{
try
{
if ( (editLrcFile.value == "")
|| (/^( +)|(.*[\\\/:\*\?"<>\|]+.*)$/g.test(editLrcFile.value))
)
{
return show("歌词文件名不正确!\n\n1.不能包含:\\\/*?\"<>|\n2.空白未填");
}
var lrcFile = fso.CreateTextFile(lrcFolder.value + "\\" + editLrcFile.value + ".lrc", true, false);
lrcFile.writeLine("[ti:" + editLrcTitle.value + "]");
lrcFile.writeLine("[ar:" + editLrcArtist.value + "]");
lrcFile.writeLine("[al:" + editLrcAuthor.value + "]");
lrcFile.writeLine("[by:" + editLrcEditer.value + "]");
lrcFile.write(editText.value);
lrcFile.close();
lrcFile = null;
show("已保存编辑的歌词文件");
}catch(e)
{
show("保存编辑的歌词文件出错:\n\n" + e.description);
}
}function changeDelLrcValue()
{
switch (delLrc.value)
{
case "不删除":
delLrc.value = "提示删除";
break;
case "提示删除":
delLrc.value = "立刻删除";
break;
case "立刻删除":
delLrc.value = "不删除";
break;
}
}function viewSource()
{
var wshshell = new ActiveXObject("WScript.Shell");
wshshell.run('Notepad.exe "' + location.pathname + '"');
wshshell = null;
}
{
show('输入代码按CTRL+ENTER键运行<br>'
+ '<textarea style="width:100%;" rows=21 '
+ ' onkeypress="if (event.keyCode == 10){eval(this.value);}">'
+ '</textarea>');
}function changeMusicTitle()
{
switch (musicTitle.value)
{
case "文件名.格式":
musicTitle.value = "文件名";
break;
case "文件名":
musicTitle.value = "完整路径";
break;
case "完整路径":
musicTitle.value = "文件名.格式";
break;
}
}function setLrcTopColor(theRGB)
{
topLrc.style.color = theRGB;
lrcTopColor.value = theRGB;
}function setLrcBottomColor(theRGB)
{
bottomLrc.style.color = theRGB;
lrcBottomColor.value = theRGB;
}function setListFontColor(theRGB)
{
list.style.color = theRGB;
listFontColor.value = theRGB;
}function setListBackColor(theRGB)
{
list.style.background = theRGB;
listBackColor.value = theRGB;
}function setListPlayColor(theRGB)
{
list.style.background = theRGB;
listBackColor.value = theRGB;
}function showListWin()
{
if (winState.innerText == "2")
{//1,单窗口样式,窗口是展开
winState.innerText = 1;
showList = 1;
window.resizeTo(winWidth + towWin.offsetWidth, winHeight + towWin.offsetHeight);
}else
{//2,双窗口图标,窗口收起
winState.innerText = 2;
showList = 0;
window.resizeTo(winWidth + towWin.offsetWidth, winHeight + oneWin.offsetHeight + 1);
}
}function showColorBar(funName)
{
show(
'请在三色条中点下左键后不放,然后拉动调配颜色<br>'
+ '<input id=redColor value=0 on=0 onmousedown="this.on=1;" '
+ 'onmousemove ="changeColorName(this, \''+ funName + '\');" onmouseup="this.on=0;" '
+ 'onmouseout="this.on=0;" '
+ 'style="cursor:default; width:260px; background: red; text-align:center; " '
+ 'contenteditable=false UNSELECTABLE=on><BR>'
+ '<input id=blueColor value=0 on=0 onmousedown="this.on=1;" '
+ 'onmousemove ="changeColorName(this, \''+ funName + '\');" onmouseup="this.on=0;" '
+ 'onmouseout="this.on=0;" '
+ 'style="cursor:default; width:260px; background: blue; text-align:center;" '
+ 'contenteditable=false UNSELECTABLE=on><br>'
+ '<input id=greenColor value=0 on=0 onmousedown="this.on=1;" '
+ 'onmousemove ="changeColorName(this, \''+ funName + '\');" onmouseup="this.on=0;" '
+ 'onmouseout="this.on=0;" '
+ 'style="cursor:default; width:260px; background: green; text-align:center;" '
+ 'contenteditable=false UNSELECTABLE=on><br>'
);
}function changeColorName(obj, funName)
{
var colorNumber = event.x - obj.offsetLeft - 2;
if (
(obj.on == "1")
&& (colorNumber > -1)
&& (colorNumber < 251)
)
{
obj.value = colorNumber;
var theRGB = "RGB(" + redColor.value + ", " + blueColor.value + ", " + greenColor.value + ")";
eval(funName + "(theRGB)");
}}function setTestTime()
{
var theValue = parseInt(prompt("请输入每首曲只试听的秒数(小于10数字或非数字不启用)","10"));
if (theValue >= 10)
{
testListen.value = theValue;
}else
{
testListen.value = 0;
}
}function saveList()
{
var thePath;
if ( (list.children.length == 0) || ((thePath = prompt("输入列表的文件名","")) == null) || (thePath == ""))
{
return 0;
}
thePath = thePath.replace(/[\\\/:\*\?"<>\|]/gi,"&");
thePath = htaPath + thePath + ".txt";
if (fso.fileExists(thePath) && (confirm(thePath + "已存在!\n\n是否要替换?") == false))
{
return 0;
}
var listFile = fso.CreateTextFile(thePath, true, true);
var objCopy = currentPlaying;
playingAttribute(objCopy, 0);
var listText = list.innerHTML;
playingAttribute(objCopy, 1);
listFile.write(listText);
listFile.close();
listFile = null;
show("列表已保存在" + thePath);
}function loadList(path)
{
if (fso.fileExists(path))
{
var listText = fso.openTextFile(path, 1, false, true);
try
{
var getText = listText.readAll();
}catch(e)
{
var getText = "";
}
listText.close();
listText = null;
list.insertAdjacentHTML("beforeEnd",getText);
}
}function showSettingSpan()
{
switch (settingSpan.style.display)
{
case "":
settingSpan.style.display = "none";
break;
default:
settingSpan.style.display = "";
}
}function SaveSetting()
{
var settingJs = "function loadSetting()"
+ '{'
+ 'showPlaying.value = ' + showPlaying.value + ';'
+ 'volNumber.innerText = "音量" + (mplayer.settings.volume = ' + mplayer.settings.volume + ') + "%";'
+ 'volBar.style.width = mplayer.settings.volume / 2;'
+ 'playMode.innerText = "' + playMode.innerText + '";'
+ 'lrcFolder.value = "' + lrcFolder.value.replace("\\", "\\\\") + '";'
+ 'if (!fso.folderExists(lrcFolder.value))'
+ '{'
+ 'lrcFolder.value = htaPath + "lrc\\\\";'
+ 'fso.CreateFolder(lrcFolder.value);'
+ '}';
if (typeof(currentPlaying) == "object")
{
settingJs += 'playthis(currentPlaying, 1, ' + mplayer.controls.currentPosition + ');';
}
if (mplayer.playState == 3)
{
settingJs += 'mplayer.controls.play();';
}
settingJs += 'delLrc.value = "' + delLrc.value + '";';
settingJs += 'alertDel.value = "' + alertDel.value + '";';
settingJs += 'testListen.value = "' + testListen.value + '";';
settingJs += 'musicTitle.value = "' + musicTitle.value + '";';
settingJs += 'topLrc.style.color = lrcTopColor.value = "' + lrcTopColor.value + '";';
settingJs += 'bottomLrc.style.color = lrcBottomColor.value = "' + lrcBottomColor.value + '";';
settingJs += 'list.style.color = listFontColor.value = "' + listFontColor.value + '";';
settingJs += 'list.style.background = listBackColor.value = "' + listBackColor.value + '";';
settingJs += 'listPlayColor.value = "' + listPlayColor.value + '";';
settingJs += '}';
var settingFile = fso.CreateTextFile(htaPath + "setting.js", true, true);
settingFile.write(settingJs);
settingFile.close();
settingFile = null;
}function update(ver)
{
}
function getWinBorder()
{
moveTo(0,0);
winWidth = window.screenLeft * 2;
winHeight = window.screenTop + window.screenLeft;
showListWin();
}function window.onload()
{
getWinBorder();
update(document.title);
loadList(defaultList);
try{ loadSetting(); }catch(e){show("自定义播放器的设置文件丢失,还原播放器为默认状态!");}
}function window.onbeforeunload()
{
var listFile = fso.CreateTextFile(defaultList, true, true);
listFile.write(list.innerHTML);
listFile.close();
listFile = null;
SaveSetting();
}
</script><SCRIPT LANGUAGE = "JScript" FOR = mplayer EVENT = PositionChange(oldPosition, newPosition)>
chanleLrc();
getLrc();
clearInterval(positioner);
positioner = setInterval("setPosition();", 1000);
</SCRIPT><SCRIPT LANGUAGE = "JScript" FOR = mplayer EVENT = playStateChange(NewState)>switch (NewState){
case 1://stop
playPauseB.innerText = "4";
clearInterval(positioner);
setPosition();
chanleLrc();
break;
case 2://pause
chanleLrc();
clearInterval(positioner);
playPauseB.innerText = "4";
break;
case 3://playing
clearInterval(positioner);
positioner = setInterval("setPosition();", 1000);
playPauseB.innerText = ";";
if (parseInt(testListen.value))
{
chanleLrc();
bottomLrc.innerText = "";
topLrc.innerText = "试听模式";
clearTimeout(playTimer);
playTimer = setTimeout("playNewMusic(1);", parseInt(testListen.value) * 1000);
}else
{
getLrc();
}
break;
case 8://MediaEnded Media item has completed playback.
clearInterval(positioner);
clearTimeout(playTimer);
playTimer = setTimeout("playNewMusic(1);", 800);
break;
default:
playPauseB.innerText = 4;
clearInterval(positioner);
chanleLrc();
setPosition();
}
</SCRIPT><SCRIPT LANGUAGE = "JScript" FOR = mplayer EVENT = OpenStateChange(NewState)>if (NewState == 13)
{
mediaLen.innerText = mplayer.currentMedia.durationString;
}
</SCRIPT><script src="setting.js" language="javascript"></script>