- <html>
- <head>
- <title>网页背景音乐播放器-http://www.wscxy.com-QQ:124727276</title>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <meta http-equiv="Content-Language" content="UTF-8">
- <style>
- <!--
- body{padding:0px;margin:0px;overflow:hidden}
- button{font-family:webdings}
- .btnSpanL{float:left;cursor:hand;font-family:webdings;font-size:9pt;width:16;height:15;background-color:silver;color:black;border:gray 2px outset;border-right-width:1px;text-align:center;margin:0px;padding:0px}
- .btnSpan{float:left;cursor:hand;font-family:webdings;font-size:9pt;width:16;height:15;background-color:silver;color:black;border:gray 2px outset;border-left-width:0px;border-right-width:1px;text-align:center;margin:0px;padding:0px}
- .btnSpanR{float:left;cursor:hand;font-family:webdings;font-size:9pt;width:16;height:15;background-color:silver;color:black;border:gray 2px outset;border-left-width:0px;text-align:center;margin:0px;padding:0px}
- -->
- </style>
- <!-- 播放曲目列表文件,请按实际情况修改 -->
- <script language="javascript" src="playList.js"></script>
- <script language="javascript">
- <!--
- /**************************************************************
- * 设计制作:shosh (即曾经的mesecretme)
- * 作者Site:http://www.wscxy.com/
- * 作者QQ: 124727276
- * 制作时间:2007年12月下旬
- * 本播放器使用者请保留此版权信息,谢谢!
- **************************************************************/
- var curPlayIndex = 0; //当前播放的曲目
- var manStopped = false; //是否人工停止播放,或是播放完毕停止,帮助判断是否自动播放下一曲
- var timeOutNoDisp; //setTimeout变量,控制播放器控制按钮是否显示
- var volInterval; //setInterval变量,用于控制是否继续改变音量
- var playPosInterval; //setInterval变量,用于控制是否继续快进或快退
- //如果想按顺序播放,请将playKinds的值改成2
- var playKinds = 0; //0:所有循环1:随机2:单曲循环 //默认值+1为最后的默认值
- var playKindsState = "所有循环";
- var errCheckTimes = 0; //打开失败控制
- var quickBackFor = 0; //0:关闭快进快退;>0:快进中;<0:快退中;
- var infoReporter = 0; //控制显示信息
- var lastSortType = -1;
- var theReporter = " (状态栏显示播放信息及简要操作提示)"; //显示信息
- var songNumPerPage = 10; //每页显示的数目>0
- var gWinForPlayList; //记录播放列表窗口
- var gWinForPlayListType; //0没有 1播放列表 2搜索窗口 3歌词窗口
- var childAotuShow = true;
-
- var initKeyword = "请输入关键字";
- var initSearchType = 3; //1歌名2歌手3both
- var bBusyNoAutoShow = false; //当搜索或排序中为true
- var timeoutDelayAutoShow; //有时候不能够及时更新列表窗口(比如处于显示歌词或搜索结果状态),用于记录timer,该timer设定一定时间再尝试更新
- /*回放功能说明:
- 按前后键按照回放列表进行播放的前提条件是:播放模式为随机,按上一首按钮启动该功能(可以按停止播放按钮关闭该功能)
- 在随机播放模式下:
- 若当前回放列表中只有a,第一次按<-,播放a,第二次按<-,播放b,继续则:abababa……
- 若当前回放列表中有abcdef,则第一次按<-,播放e(而不是f,这样才感觉播放到了上一首),继续则:dcbafedcbafedc……
- 接上一种情况,在回放过程中,多次按了<-,播放了……dcbafedcbafedc,如果此时按->,则播放d,继续连续->,efghi,即f后面的随机生成,这是跟<-不一样的地方(<-会循环向前)
- 同样,如果不想在回放过程中按->一直到回放列表的最后才开始随机播放,可以先按停止播放按钮关闭回放模式(如果再按<-重新启动回放模式),然后按->一下即可随机播放歌曲。
- 回放列表允许曲目重复,但是相邻曲目不会重复
- */
- var shoPlayBackList = new Array(); //add the function of play back
- var shoCurBackIndex = -1; //the current index of play back list
- var shoIsBackPlayMode = false; //只有在随机模式下按<-才会设为true,在true的时候播放上一首和下一首的时候会先从回放列表读取
- this.name = "ShoshWebPageBackgroundMusicPlayer";
-
- if (undefined == musicList)
- {
- var musicList = new Array();
- musicList[0] = new Array("http://www.917y.com/tz.mp3", "同桌的你", "老狼", 13947, -15000);
- musicList[1] = new Array("http://server.wxsbxx.com/XSPD/MUSIC/mp3/ny/chumai.mp3", "出卖", "那英", 17120, 0);
- musicList[2] = new Array("http://125.46.42.151/pub_music/divide_part_44/e792a542a731a756ff017667d43b5c16a1fa2ac3.mp3", "怎样", "戴佩妮", 33197, 1500);
- musicList[3] = new Array("http://hflz.com/music/content/chinese/bld/love.mp3", "爱就一个字", "张信哲", 42625, 0);
- musicList[4] = new Array("http://www.lygame.com/onlinemusic/forlygame/029.%BA%C3%D0%C4%B7%D6%CA%D6.mp3", "好心分手", "卢巧音", 49192, 3000);
- musicList[5] = new Array("http://jy.hlj.stats.gov.cn/XiuXianShiGuang/xxsg2006032819-01.mp3", "冰雨", "刘德华", 13904, 0);
- musicList[6] = new Array("http://61.155.11.85/music/20070727_1(fybh).mp3", "我们说好的", "张靓颖", 68555, 0);
- }
-
- function cmpBySingerAsc(a, b) //先歌手顺序后歌名顺序
- {
- var result = a[2].toUpperCase().localeCompare(b[2].toUpperCase());
- if (0 == result)
- result = a[1].toUpperCase().localeCompare(b[1].toUpperCase());
- return result;
- }
- function cmpBySingerDesc(b, a) //先歌手逆序后歌名逆序
- {
- var result = a[2].toUpperCase().localeCompare(b[2].toUpperCase());
- if (0 == result)
- result = a[1].toUpperCase().localeCompare(b[1].toUpperCase());
- return result;
- }
-
- function cmpByWordNumAsc(a, b) //先字数顺序后歌名顺序,一个单词或一个数字算一个字
- {
- var alen = a[1].replace(/[^\u0000-\u00ff]/g, " s ").replace(/\b([a-z0-9]+)\b/gi, "s").replace(/\s/g, "").length;
- var blen = b[1].replace(/[^\u0000-\u00ff]/g, " s ").replace(/\b([a-z0-9]+)\b/gi, "s").replace(/\s/g, "").length;
- if (alen != blen)
- return (alen - blen);
- return a[1].toUpperCase().localeCompare(b[1].toUpperCase());
- }
- function shoSortList(sortType)
- {
- if (lastSortType == sortType)
- return;
- var resorted = true;
- var theIdUrl = musicList[curPlayIndex][0];
- bBusyNoAutoShow = true;
- switch (sortType)
- {
- case 1: //按歌名顺序
- musicList.sort(function(a, b){return a[1].toUpperCase().localeCompare(b[1].toUpperCase())});
- break;
- case 2: //按歌名逆序
- musicList.sort(function(a, b){return b[1].toUpperCase().localeCompare(a[1].toUpperCase())});
- break;
- case 3: //按歌手顺序
- musicList.sort(cmpBySingerAsc);
- break;
- case 4: //按歌手逆序
- musicList.sort(cmpBySingerDesc);
- break;
- case 5: //按字数顺序
- musicList.sort(cmpByWordNumAsc);
- break;
- default:
- resorted = false;
- break;
- }
- if (resorted)
- {
- shoPlayBackList.splice(0, shoPlayBackList.length);
- shoCurBackIndex = -1;
- shoIsBackPlayMode = false;
- lastSortType = sortType;
- for (var i = musicList.length - 1; i >= 0; i--)
- {
- if (theIdUrl == musicList[i][0])
- {
- curPlayIndex = i;
- shoPlayBackList.concat(curPlayIndex); //其他参数在循环前已经设置好
- break;
- }
- }
- setListWindow(-33);
- }
- bBusyNoAutoShow = false;
- }
-
- function setBody()
- {
- //main body to display
- var url = decodeURI(unescape(document.location.toString())).match(/\$\$\$([^(&&)]*)&&/g);
- if(null != url)
- {
- url[0] = url[0].substring(3,url[0].length-2);
- url[0] = url[0].replace(/(^[\s| ]*)|([\s| ]*$)/g, "");
- if ("" != url[0])
- document.getElementById("mainFrm").src = url[0];
- if (url.length > 1 && document.getElementById("footprint"))
- {
- url[1] = decodeURI(url[1].substring(3, url[1].length - 2));
- url[1] = url[1].replace(/ /g, " ");
- if ("" != url[1].replace(/\s/ig,"")) //允许空格,但是不能够全空。
- {
- if (url[1].match(/\s$/))
- url[1] += " ";
- document.getElementById("footprint").innerText = url[1];
- }
- }
- }
- else
- {
- //请设置成你的网站的默认地址,如 http://www.mysite.com/index.aspx
- document.getElementById("mainFrm").src = "http://www.wscxy.com/shosh/";
- }
- //background music
- var myPlayer = document.getElementById("shoPlayer");
- if (1 == (playKinds + 1) % 3 && musicList.length > 1) //一开始就随机,否则从初始化的值(一般是0)开始
- {
- curPlayIndex = Math.floor(Math.random() * musicList.length);
- }
- if (myPlayer)
- {
- myPlayer.url = musicList[curPlayIndex][0];
- if (0 == shoPlayBackList.length || curPlayIndex != shoPlayBackList[shoPlayBackList.length - 1]) //不能够调换顺序
- shoPlayBackList = shoPlayBackList.concat(curPlayIndex);
- shoIsBackPlayMode = false;
- shoCurBackIndex = -1;
- if (10 == shoPlayer.playState)
- {
- myPlayer.controls.play();
- setRandPlay(); //保证对应,结果为变量初始值+1
- switchQuickOrNext(); //设置快进或下一曲
- setInterval("showProgress('m')", 1000);
- }
- }
- }
- window.onerror=new function(){return true;}
- function switchQuickOrNext()
- {
- var obj;
- if (2 == playKinds || musicList.length < 2) //单曲播放,快进
- {
- obj = document.getElementById("PreAndBack");
- if (obj)
- {
- obj.innerText = "7";
- obj.title = "快退";
- }
- obj = document.getElementById("NextAndForward");
- if (obj)
- {
- obj.innerText = "8";
- obj.title = "快进";
- }
- }
- else
- {
- obj = document.getElementById("PreAndBack");
- if (obj)
- {
- obj.innerText = "9";
- obj.title = "上一首";
- }
- obj = document.getElementById("NextAndForward");
- if (obj)
- {
- obj.innerText = ":";
- obj.title = "下一首";
- }
- }
- }
-
- function shoPause()
- {
- if (3 == shoPlayer.playState)
- shoPlayer.controls.pause();
- else if (2 == shoPlayer.playState)
- shoPlayer.controls.play();
- }
-
- function getState(state)
- {
- switch (state)
- {
- case 1: return "[播放已停止";
- case 2:
- if (0 == quickBackFor)
- return "[播放已暂停";
- else if (quickBackFor > 0)
- return "[快进中...";
- else
- return "[快退中...";
- case 3: return "[正在播放...";
- case 4: return "[向前搜索中...";
- case 5: return "[向后搜索中...";
- case 6: return "[缓冲处理中...";
- case 7: return "[等待反应中...";
- case 8: return "[已播放完毕";
- case 9: return "[连接媒体中...";
- case 10: return "[已准备就绪";
- default: return "[数据读取中...";
- }
- }
- function setInfo()
- {
- infoReporter = ++infoReporter % 48;
- switch (infoReporter)
- {
- case 0:
- theReporter = " (设计制作:shosh)";
- break;
- case 4:
- theReporter = " (作者Site:http:\/\/www.wscxy.com)";
- break;
- case 10:
- theReporter = " (作者QQ:124727276)";
- break;
- case 15:
- theReporter = " (最后修改时间:" + document.lastModified + ")";
- break;
- case 20:
- theReporter = " (最后修改内容:重新排序后添加当前播放歌曲到回放列表。)";
- break;
- case 25:
- theReporter = " (鼠标移至页面左上角显示播放器界面)";
- break;
- case 30:
- theReporter = " (在播放器界面上右击鼠标可打开曲目列表窗口)";
- break;
- case 35:
- theReporter = " (在曲目列表窗口可进行播放、排序、查找等各种操作)";
- break;
- case 40:
- theReporter = " (08年2月4日成功完成滚动显示歌词功能)";
- break;
- default:
- break; //do nothing
- }
- }
- var maxErrTryTimes = 15; //定义尝试连接播放的次数(时间)
- function showProgress(id)
- {
- //debug info//
- //top.document.title = shoPlayBackList.toString() + " : " + shoPlayBackList[shoCurBackIndex] + " \/ " + curPlayIndex;
- top.status = getState(shoPlayer.playState);
- if (10 == shoPlayer.playState && errCheckTimes > 0 && errCheckTimes < maxErrTryTimes - 3) //快速判断
- errCheckTimes = maxErrTryTimes - 3;
- if (errCheckTimes > 0 && shoPlayer.playState > 5)
- top.status += maxErrTryTimes - errCheckTimes;
- else
- errCheckTimes = 0;
- top.status += "|" + playKindsState;
- top.status += shoPlayer.settings.mute ? "|静音] " : "] ";
- top.status += musicList[curPlayIndex][1] + "-" + musicList[curPlayIndex][2] + " ";
- if (shoPlayer.controls.currentPositionString && shoPlayer.currentMedia.durationString)
- top.status += shoPlayer.controls.currentPositionString + "\/" + shoPlayer.currentMedia.durationString;
- else
- top.status += "00:00\/00:00";
- if (!volInterval)
- {
- setInfo();
- top.status += theReporter;
- }
- if (!manStopped && "m" == id)
- {
- if (1 == shoPlayer.playState)
- {
- playNextSong(true);
- }
- else if (shoPlayer.playState > 5)
- {
- if(++errCheckTimes > maxErrTryTimes) //无法播放,继续
- {
- errCheckTimes = 0;
- top.status = musicList[curPlayIndex][1] + "-" + musicList[curPlayIndex][2] + ":无法播放,尝试" + ((musicList.length > 1 && playKinds != 2) ? "播放下一曲..." : "再次连接打开...");
- shoIsBackPlayMode = false;
- shoCurBackIndex = -1;
- playNextSong(true);
- }
- }
- }
- }
- function playSpSong(theValue)
- {
- clearAllQuickInterval();
- theValue = parseInt(theValue)
- if (theValue < 0 || theValue >= musicList.length)
- return;
- errCheckTimes = 0;
- curPlayIndex = theValue;
- shoPlayer.url = musicList[curPlayIndex][0];
- if (shoPlayBackList.length == 0 || curPlayIndex != shoPlayBackList[shoPlayBackList.length - 1]) //不能够调换顺序
- shoPlayBackList = shoPlayBackList.concat(curPlayIndex);
- shoIsBackPlayMode = false;
- shoCurBackIndex = -1;
- chkSetListWindow();
- if (shoPlayer.playState == 10)
- shoPlayer.controls.play();
- }
-
- var intvalLrcQuickBack = null;
- var intvalLrcQuickForth = null;
- function clearAllQuickInterval(noResetBtnText)
- {
- if (intvalLrcQuickForth)
- {
- clearInterval(intvalLrcQuickForth);
- }
- if (intvalLrcQuickBack)
- {
- clearInterval(intvalLrcQuickBack);
- }
- if (playPosInterval)
- {
- clearInterval(playPosInterval);
- //shoPlayer.controls.play();
- }
- intvalLrcQuickForth = intvalLrcQuickBack = playPosInterval = null;
- quickBackFor = 0; //标记未处于快进快退中
- if (!noResetBtnText)
- {
- try
- {
- if (gWinForPlayList && gWinForPlayListType == 3)
- {
- gWinForPlayList.document.getElementById("lrcBtnQuickBack").innerText = "7";
- gWinForPlayList.document.getElementById("lrcBtnQuickForth").innerText = "8";
- }
- }catch(e){}
- }
- }
- function lrcQuickBack(who)
- {
- clearAllQuickInterval(true);
- try
- {
- if (who)
- {
- var obj = who.document.getElementById("lrcBtnQuickBack");
- if ("7" == obj.innerText && shoPlayer.controls.currentPosition && shoPlayer.playState < 6)
- {
- obj.innerText = "4";
- shoPlayer.controls.pause();
- quickBackFor = -1;
- intvalLrcQuickBack = setInterval("setCurPosition(-1)", 100);
- }
- else
- {
- shoPlayer.controls.play();
- obj.innerText = "7";
- }
- who.document.getElementById("lrcBtnQuickForth").innerText = "8";
- }
- }catch(e){}
- }
- function lrcQuickForth(who)
- {
- clearAllQuickInterval(true);
- try
- {
- if (who)
- {
- var obj = who.document.getElementById("lrcBtnQuickForth");
- if ("8" == obj.innerText && shoPlayer.controls.currentPosition && shoPlayer.playState < 6)
- {
- shoPlayer.controls.pause();
- quickBackFor = 1;
- intvalLrcQuickForth = setInterval("setCurPosition(1)", 100);
- obj.innerText = "4";
- }
- else
- {
- shoPlayer.controls.play();
- obj.innerText = "8";
- }
- who.document.getElementById("lrcBtnQuickBack").innerText = "7";
- }
- }catch(e){}
- }
-
- function lrcPlayPrev()
- {
- var temPlayKind = playKinds;
- if (2 == temPlayKind)
- playKinds = 1; //单曲变随机
- playPrevSong();
- playKinds = temPlayKind;
- }
-
- function lrcPlayNext()
- {
- var temPlayKind = playKinds;
- if (2 == temPlayKind)
- playKinds = 1; //单曲变随机
- playNextSong();
- playKinds = temPlayKind;
- }
-
-
- function playNextSong(noFreshStatus) //该参数一般为false(未传入),当一曲播放失败会显示信息,传入true,要求不要立即更新显示播放信息
- {
- clearAllQuickInterval();
- if (2 == playKinds || musicList.length < 2) //单曲循环
- {
- if (noFreshStatus) //播放完一曲继续从头播放,noFreshStatus为true正说明不是用户手动按下按钮调用该事件的
- {
- shoPlayer.controls.stop();
- shoPlayer.controls.play();
- showProgress();
- }
- else if (shoPlayer.controls.currentPosition && shoPlayer.playState < 6 ) //快进
- {
- shoPlayer.controls.pause();
- if (quickBackFor >= 0)
- quickBackFor++; //标记快退
- else
- quickBackFor = 1; //正常情况下不会这样,快退时按了快进
- //if (playPosInterval) //先停止后加速
- // clearInterval(playPosInterval);
- playPosInterval = setInterval("setCurPosition(" + quickBackFor + ")", 100);
- //shoPlayer.controls.fastForward();
- }
- return;
- }
-
- errCheckTimes = 0;
- if (1 == playKinds && shoIsBackPlayMode && shoCurBackIndex >= 0 && shoCurBackIndex < shoPlayBackList.length - 1) //按回放列表播放下一首
- {
- curPlayIndex = shoPlayBackList[++shoCurBackIndex];
- }
- else
- {
- if (1 == playKinds) //随机
- {
- var temIndex = curPlayIndex;
- while (curPlayIndex == temIndex)
- {
- temIndex = Math.floor(Math.random() * musicList.length);
- }
- curPlayIndex = temIndex;
- }
- else //所有循环
- curPlayIndex = (curPlayIndex + 1) % musicList.length;
- if (0 == shoPlayBackList.length || curPlayIndex != shoPlayBackList[shoPlayBackList.length - 1]) //不能够调换顺序
- shoPlayBackList = shoPlayBackList.concat(curPlayIndex);
- shoIsBackPlayMode = false;
- shoCurBackIndex = -1;
- }
- shoPlayer.url = musicList[curPlayIndex][0];
- chkSetListWindow();
- if (!noFreshStatus) //先显示播放失败信息,所以不要更新
- showProgress(); //for quick show the song name
- if (10 == shoPlayer.playState)
- shoPlayer.controls.play();
- }
- function playPrevSong()
- {
- clearAllQuickInterval();
- if ((2 == playKinds || musicList.length < 2)) //单曲循环
- {
- if(shoPlayer.controls.currentPosition && shoPlayer.playState < 6) //快退
- {
- shoPlayer.controls.pause();
- if (quickBackFor <= 0)
- quickBackFor--; //标记快退
- else
- quickBackFor = -1; //正常情况下不会这样,快进时按了快退
- //if (playPosInterval) //先停止后加速
- // clearInterval(playPosInterval);
- playPosInterval = setInterval("setCurPosition(" + quickBackFor + ")", 100);
- }
- return;
- }
- errCheckTimes = 0;
- var doElse = true;
- if (1 == playKinds && shoPlayBackList.length > 0) //按列表播放上一首
- {
- doElse = false;
- if (shoIsBackPlayMode)
- {
- if (shoPlayBackList.length > 1)
- {
- shoCurBackIndex--;
- if (shoCurBackIndex < 0)
- shoCurBackIndex = shoPlayBackList.length - 1;
- else
- shoCurBackIndex %= shoPlayBackList.length; //直接上一首
- curPlayIndex = shoPlayBackList[shoCurBackIndex];
- }
- else
- {
- //shoIsBackPlayMode = false; //只有一首,取消回放模式,set in doElse
- //shoCurBackIndex = -1;
- doElse = true;
- }
- }
- else
- {
- if (shoPlayBackList.length > 1)
- {
- shoIsBackPlayMode = true;
- shoCurBackIndex = shoPlayBackList.length - 2; //直接上一首
- curPlayIndex = shoPlayBackList[shoCurBackIndex];
- }
- else if (1 == shoPlayBackList.length)
- {
- shoIsBackPlayMode = true;
- shoCurBackIndex = 0; //直接上一首
- curPlayIndex = shoPlayBackList[shoCurBackIndex];
- }
- else
- {
- doElse = true;
- }
- }
- }
- if (doElse)
- {
- if (1 == playKinds) //随机
- {
- var temIndex = curPlayIndex;
- if (musicList.length > 1)
- {
- while (curPlayIndex == temIndex)
- {
- temIndex = Math.floor(Math.random() * musicList.length);
- }
- curPlayIndex = temIndex;
- }
- }
- else //所有循环
- {
- curPlayIndex--;
- if (curPlayIndex < 0)
- curPlayIndex = musicList.length - 1;
- }
- if (0 == shoPlayBackList.length || curPlayIndex != shoPlayBackList[shoPlayBackList.length - 1]) //不能够调换顺序
- shoPlayBackList = shoPlayBackList.concat(curPlayIndex);
- shoIsBackPlayMode = false;
- shoCurBackIndex = -1;
-
- }
- showProgress(); //for quick show the song name
- shoPlayer.url = musicList[curPlayIndex][0];
- chkSetListWindow();
- if (10 == shoPlayer.playState)
- shoPlayer.controls.play();
- }
- function btnPlayMusic()
- {
- clearAllQuickInterval();
- errCheckTimes = 0;
- shoPlayer.controls.play();
- manStopped = false;
- }
- function btnStopMusic()
- {
- clearAllQuickInterval();
- shoPlayer.controls.stop();
- manStopped = true;
- shoCurBackIndex = -1;
- shoIsBackPlayMode = false;
- }
- function setMute(who)
- {
- if (shoPlayer.settings.mute)
- {
- shoPlayer.settings.mute = false;
- who.innerText = "U";
- }
- else
- {
- shoPlayer.settings.mute = true;
- who.innerText = "V";
- }
- showProgress();
- }
- function volControl(who,offset)
- {
- btnClickDown(who);
- if (volInterval)
- clearInterval(volInterval);
- volInterval = setInterval("setVolValue(" + offset + ")", 100);
- }
- function setVolValue(offset)
- {
- if (shoPlayer.settings.mute)
- {
- showProgress();
- top.status += " 请关闭静音状态调节音量。"
- return;
- }
- var curValue = shoPlayer.settings.volume;
- curValue += offset;
- if (curValue < 0)
- {
- curValue = 0;
- if (volInterval)
- clearInterval(volInterval);
- }
- else if (curValue > 100)
- {
- curValue = 100;
- if (volInterval)
- clearInterval(volInterval);
- }
- shoPlayer.settings.volume = curValue;
- showProgress();
- top.status += " 音量" + (offset>0 ? "增" : "降") + "至 " + curValue + " 。";
- }
- function setCurPosition(offset)
- {
- var curPosition = shoPlayer.controls.currentPosition;
- curPosition += offset;
- if (curPosition <= 0)
- {
- curPosition = 0.1; //保证退到开始处后还能够直接快进
- clearAllQuickInterval(true);
- //playPosInterval = null;
- //quickBackFor = 0;
- }
- else if (curPosition >= shoPlayer.currentMedia.duration)
- {
- curPosition = shoPlayer.currentMedia.duration;
- clearAllQuickInterval(true);
- //playPosInterval = false;
- //quickBackFor = 0;
- }
- shoPlayer.controls.currentPosition = curPosition;
- showProgress();
- }
-
- //button show functions
- function btnMouseOver(who)
- {
- if (timeOutNoDisp)
- clearTimeout(timeOutNoDisp);
- if (who)
- {
- who.style.backgroundColor = "gray";
- }
- }
- function btnMouseOut(who)
- {
- timeOutNoDisp=setTimeout("hideCtrlPanel()", 300);
- if (who)
- {
- who.style.backgroundColor = "silver";
- who.style.color = "black";
- }
- }
- function btnClickDown(who)
- {
- if (who)
- {
- who.style.color = "white";
- }
- }
- function btnClickUp(who)
- {
- if (who)
- {
- who.style.color = "black";
- }
- }
- function setRandPlay()
- {
- playKinds = ++playKinds % 3;
- switchQuickOrNext(); //可能需要快进下一曲的切换
- var innerText;
- switch (playKinds)
- {
- case 0:
- playKindsState = "所有循环";
- innerText = "`";
- break;
- case 1:
- playKindsState = "随机";
- innerText = "~";
- break;
- case 2:
- playKindsState = "单曲循环";
- innerText = "q";
- break;
- }
- var who = document.getElementById("PlayState");
- if (who)
- who.innerText = innerText;
- showProgress();
- }
- function showInformation()
- {
- if (window.confirm("播放器信息:\n\tAuther: Shosh\n\tSite: http:\/\/www.wscxy.com\n\tLast Modified: " + document.lastModified + "\n\n点击[确定]显示播放曲目列表(可进行排序搜索查看歌词等操作)\n\n点击[取消]查看更多播放器信息。"))
- {
- if (gWinForPlayList)
- {
- try
- {
- gWinForPlayList.focus();
- }
- catch(e)
- {
- setListWindow(-33, true);
- }
- }
- else
- setListWindow(-33); //传入-33表示指示当前播放曲目
- }
- else
- {
- document.getElementById("mainFrm").src = "http://www.wscxy.com/shosh/article.asp?id=36"; //请勿修改本地址
- }
- }
-
- function chkSetListWindow() //当换播歌曲时调用该函数用来处理子窗口
- {
- if (!gWinForPlayList)
- return;
- if (childAotuShow && 1 == gWinForPlayListType)
- {
- if(bBusyNoAutoShow)
- {
- if (timeoutDelayAutoShow)
- clearTimeout(timeoutDelayAutoShow);
- timeoutDelayAutoShow = setTimeout("chkSetListWindow()", 300);
- }
- else
- setListWindow(-33);
- }
- else if (3 == gWinForPlayListType)
- {
- try
- {
- if (false == gWinForPlayList.document.getElementById("stopAutoScroll").checked)
- {
- showSongLyric(-33);
- }
- }
- catch(e)
- {
- gWinForPlayListType = 1;
- }
- }
- }
- function setChildWnd(who, shoMusicID) //shoMusicID仅用于歌词窗口
- {
- try
- {
- if (!who)
- {
- who = gWinForPlayList;
- if(!who)
- return;
- }
- if (1 == gWinForPlayListType || 2 == gWinForPlayListType) //1播放列表 2搜索窗口
- {
- switch (lastSortType)
- {
- case 1:
- who.defaultStatus = "@ 歌名(拼音)升序";
- break;
- case 2:
- who.defaultStatus = "@ 歌名(拼音)降序";
- break;
- case 3:
- who.defaultStatus = "@ 歌手(拼音)升序,后歌名(拼音)升序";
- break;
- case 4:
- who.defaultStatus = "@ 歌手(拼音)降序,后歌名(拼音)降序";
- break;
- case 5:
- who.defaultStatus = "@ 先歌名字数(单词记一字,空格不记)升序,后歌名升序";
- break;
- default:
- who.defaultStatus = "@ 原始顺序(未经排序)";
- break;
- }
-
- if (1 == gWinForPlayListType) //1播放列表
- {
- var item = who.document.getElementById("ShoSortType" + lastSortType);
- if (item)
- item.disabled = true;
- }
- }
- else if (3 == gWinForPlayListType) //3 歌词窗口
- {
- var theObj;
- if (isNaN(shoMusicID))
- shoMusicID = curPlayIndex;
- else if (shoMusicID < 0 || shoMusicID >= musicList.length)
- shoMusicID = curPlayIndex;
- //设定自动滚动
- var bNotCurPlayLyric = (shoMusicID != curPlayIndex);
- theObj = who.document.getElementById("stopAutoScroll");
- if (theObj)
- theObj.checked = bNotCurPlayLyric;
- who.shoStopSelfScroll = bNotCurPlayLyric;
- theObj = who.document.getElementById("showScrollBar");
- if (theObj)
- theObj.checked = bNotCurPlayLyric;
- theObj = who.document.getElementById("LrcShower_div");
- if (theObj)
- theObj.style.overflowY = bNotCurPlayLyric ? "scroll" : "hidden";
-
- who.lrcInterface("MPH", musicList[shoMusicID][3]); //load lyric
- //setLyricPlayOffset(musicList[shoMusicID][4]); //需要等给gWinForPlayList赋值
- setTimeout("setLyricPlayOffset(musicList[" + shoMusicID + "][4])", 300); //set offset time and default status
- who.document.title = "歌词: " + musicList[shoMusicID][1] + " - " + musicList[shoMusicID][2] + " -- shosh网页播放器";
- }
- } catch(e){}
- }
-
- function setListWindow(page,mustFocus) //传入-33表示指示当前播放曲目
- {
- if (songNumPerPage <= 0)
- songNumPerPage = 10; //防止设置错误或意外修改
- var maxPage = Math.ceil(musicList.length / songNumPerPage);
- if (-33 == page && songNumPerPage > 0 && musicList.length > 1)
- page = Math.ceil((curPlayIndex + 1) / songNumPerPage);
- if (page)
- {
- page = parseInt(page);
- if (page < 1)
- page = maxPage; //循环效果
- }
- else
- page = maxPage;
- if (page > maxPage)
- page = 1; //循环效果
- var startId = songNumPerPage * (page - 1);
- try //当已经被其他窗口打开时再操作会出错
- {
- var hasOpened = gWinForPlayList;
- var winDsnByShosh=window.open('', 'MusicListForShoshMusicPlayer', 'height=310, width=600, top=200, left=200, toolbar=no, menubar=no, resizable=no,location=no, status=yes, scrollbars=yes');
- gWinForPlayListType = 1;
- var i = 0;
- with (winDsnByShosh.document)
- {
- open();
- writeln("<title>shosh 背景音乐-曲目列表<\/title><meta http-equiv=\"Content-Type\" content=\"text/html;charset=gb2312\"><style>body{font-size:10pt;overflow:auto}a{font-size:10pt;color:green;text-decoration:none}td{font-size:10pt;text-align:center;padding-top:2px;padding-bottom:0px}a.directlink{text-decoration:underline}a:hover{color:red}div,span{font-size:10pt}button{padding:0px;height:20px;background-color:rgb(162,200,169);border:#00AA00 2px output}</style>");
- writeln("<body onkeydown=\"if(event.keyCode == 8)return false\" oncontextmenu=\"return false\" onload=\"if(window.opener==null || window.opener.name != \'ShoshWebPageBackgroundMusicPlayer\'){window.opener=null;window.close();}window.opener.setChildWnd(this)\" text=blue onunload=\"window.opener.gWinForPlayList=null;\">");
-
- writeln("<table width=100% border=0><tr><td style=\"text-align:left\"><button onclick=\"window.opener.showSongLyric(-33)\">显示滚动歌词<\/button><\/td><td style=\"text-align:center\"><label for=\"aotuShowCurPlay\" style=\"color:red\">自动指示<\/label><input type=checkbox id=\"aotuShowCurPlay\" onclick=\"window.opener.childAotuShow=this.checked;\"" + (childAotuShow ? " checked" : "") + "><button onclick=\"window.opener.setListWindow(-33)\">指示当前播放<\/button><\/td><td style=\"text-align:right\"><a class=\"directlink\" href=\"javascript:window.opener.setListWindow(" + (page-1) + ")\">上一页<\/a><span style=\"margin-left:6px;margin-right:6px\">|<\/span><a class=\"directlink\" href=\"javascript:window.opener.setListWindow(" + (page+1) + ")\">下一页<\/a>");
- writeln("<select onchange=\"javascript:window.opener.setListWindow(this.options[this.selectedIndex].value)\" id=\"theCurPageList\">");
- }
- for (i = 1; i <= maxPage; i++)
- winDsnByShosh.document.writeln("<option value=\"" + i + "\"" + (i == page ? " selected" : "") + ">第" + i + "页<\/option>");
- winDsnByShosh.document.writeln("<\/select><button onclick=\"javascript:window.opener.shoApiSearchMusic(3)\" onmouseover=\"window.status=\'在歌名和歌手中(不需要完整输入歌名或歌名)搜索\'\">搜索<\/button><\/td><\/tr><\/table>");
- winDsnByShosh.document.writeln("<table border=1 width=100%><tr><td title=\'序号==ID\'><b>ID/歌词<\/b><\/td><td><b>歌曲<\/b><button id=\"ShoSortType1\" onclick=\"window.opener.shoSortList(1)\" onmouseover=\"window.status=\'按歌名(拼音)升序排列...\'\">升<\/button><button id=\"ShoSortType2\" onclick=\"window.opener.shoSortList(2)\" onmouseover=\"window.status=\'按歌名(拼音)降序排列...\'\">降<\/button><button id=\"ShoSortType5\" onclick=\"window.opener.shoSortList(5)\" onmouseover=\"window.status=\'先按歌名字数升序后按歌名(拼音)升序排列...\'\">数<\/button><button onclick=\"javascript:window.opener.shoApiSearchMusic(1)\" onmouseover=\"window.status=\'搜索歌名(不需要完整输入歌名)\'\">搜<\/button><\/td><td><b>演唱者<\/b><button id=\"ShoSortType3\" onclick=\"window.opener.shoSortList(3)\" onmouseover=\"window.status=\'先按歌手(拼音)升序后按歌名(拼音)升序排列...\'\">升<\/button><button id=\"ShoSortType4\" onclick=\"window.opener.shoSortList(4)\" onmouseover=\"window.status=\'先按歌手(拼音)降序后按歌名(拼音)降序排列...\'\">降<\/button><button onclick=\"javascript:window.opener.shoApiSearchMusic(2)\" onmouseover=\"window.status=\'搜索歌手(不需要完整输入歌手名字)\'\">搜<\/button> <\/td></thead>");
- var stopId = startId + songNumPerPage;
- if (stopId > musicList.length)
- stopId = musicList.length;
- var lrcHrefText;
- for (i = startId; i < stopId; i++)
- {
- if (musicList[i][3] != "undefined" && String(musicList[i][3]) != "0")
- lrcHrefText = "..<a href=\"javascript:window.opener.showSongLyric(" + i + ")\" title=\"查看歌词\">歌词<\/a>";
- else
- lrcHrefText = "<a style=\"visibility:hidden\">..歌词<\/a>";
- winDsnByShosh.document.writeln("<tr" + (i == curPlayIndex ? " style=\"background-color:yellow\"" : "" ) + "><td>" + (i+1) + ""+ lrcHrefText + "<\/td><td><a href='javascript:window.opener.playSpSong("+i+")'>"+musicList[i][1]+"<\/a><\/td><td>"+musicList[i][2]+"<\/td><\/tr>");
- }
- winDsnByShosh.document.writeln("<\/table><\/body>");
- winDsnByShosh.document.close();
- if (!hasOpened || 1 != gWinForPlayListType || mustFocus)
- winDsnByShosh.focus();
- gWinForPlayList = winDsnByShosh;
- }
- catch (e)
- {
- alert("播放曲目列表窗口打开失败,可能原因如下:\n\n1、播放曲目列表窗口已经被其他窗口打开。\n\n2、播放曲目列表窗口被弹出窗口拦截程序所拦截,\n请允许弹出窗口或关闭弹窗拦截程序。");
- }
- }
-
-
- var curPanelAlpha = 80;
- var alphaInterval;
- function dispCtrlPanel()
- {
- if (alphaInterval)
- clearInterval(alphaInterval);
- alphaInterval = setInterval("flashAlphaPanel(20)", 100);
- //document.getElementById('bgMusicControl').style.visibility="visible";
- //document.getElementById("panelContainer").style.filter = "alpha(opacity=20)";
- }
- function hideCtrlPanel()
- {
- if (alphaInterval)
- clearInterval(alphaInterval);
- alphaInterval = setInterval("flashAlphaPanel(-5)", 100);
- //document.getElementById("panelContainer").style.filter = "alpha(opacity=0)";
- //document.getElementById('bgMusicControl').style.visibility="hidden";
- }
- function flashAlphaPanel(offset)
- {
- curPanelAlpha += offset;
- if (curPanelAlpha < 0)
- {
- if (alphaInterval)
- clearInterval(alphaInterval);
- curPanelAlpha = 0;
- }
- else if (curPanelAlpha > 80)
- {
- if (alphaInterval)
- clearInterval(alphaInterval);
- curPanelAlpha = 80;
- }
- document.getElementById("panelContainer").style.filter = "alpha(opacity=" + curPanelAlpha +")";
- }
- function leavePlayer()
- {
- if (gWinForPlayList)
- {
- try
- {
- gWinForPlayList.opener = null;
- gWinForPlayList.close();
- }catch(e){}
- }
- }
- function shoApiSearchMusic(where)
- {
- shoSearchMusic(initKeyword, where);
- }
- function shoWndSrhBackToWndList()
- {
- bBusyNoAutoShow = false;
- if (timeoutDelayAutoShow)
- clearTimeout(timeoutDelayAutoShow);
- setListWindow(-33);
- }
- function shoSearchMusic(what,where)
- {
- if (undefined == what)
- what = initKeyword;
- if (undefined == where)
- where = initSearchType;
- var temWhat = what.replace(/(^[\s| |\|]*)|([\s| |\|]*$)/g, "");
- initSearchType = where;
- initKeyword = what;
- var listLen = musicList.length;
- var reg = new RegExp();
- try
- {
- what = temWhat.replace(/[\s| ]+/g, "|");
- if (what.length < 1)
- {
- throw "";
- }
- reg.compile("\(" + what + "\)", "gi");
- }
- catch(e)
- {
- alert("Error: 无效关键字。" + "\n\n请输入正确的关键字(支持正则表达)。\n\n正则表达简单举例:\n\\d\t\t\t含有数字\n[a-z]+\t\t\t含有字母\n[^\\u0000-\\u00FF]+\t含非ASCII字符(如汉字)\n.*\t\t\t全部匹配,列出所有曲目\n你.*我|我.*你\t\t同时出现你、我两字\n我.*你\t\t\t同时出现你、我两字,且我字在你字之前\n\\s\t\t\t含有空格\n\n空格表示多关键字或查询(同符号|)");
- if (gWinForPlayList)
- gWinForPlayList.focus();
- return;
- }
- try //当已经被其他窗口打开时再操作会出错
- {
- bBusyNoAutoShow = true;
- var winDsnByShosh = window.open('', 'MusicListForShoshMusicPlayer', 'height=310, width=600, top=200, left=200, toolbar=no, menubar=no, resizable=no,location=no, status=yes, scrollbars=yes');
- gWinForPlayListType = 2;
- with (winDsnByShosh.document)
- {
- open();
- writeln("<title>搜索结果 - shosh 背景音乐-曲目列表<\/title><meta http-equiv=\"Content-Type\" content=\"text/html;charset=gb2312\"><style>body{font-size:10pt;overflow:auto}a{font-size:10pt;color:green;text-decoration:none}td{font-size:10pt;text-align:center;padding-top:2px;padding-bottom:0px}a.directlink{text-decoration:underline}a:hover{color:red}div,span{font-size:10pt}button{padding:0px;height:20px;background-color:rgb(162,200,169);border:#00AA00 2px outset}.blackIndex{color:black}</style>");
- writeln("<body onkeydown=\"if(event.srcElement.tagName.toUpperCase() != \'INPUT\')return false\" oncontextmenu=\"return false\" onload=\"if(window.opener==null || window.opener.name != \'ShoshWebPageBackgroundMusicPlayer\'){window.opener=null;window.close();}window.opener.setChildWnd(this)\" text=blue onunload=\"window.opener.gWinForPlayList=null;\">");
- writeln("<table width=100% border=0><tr><td style=\"text-align:left\"><button onclick=\"window.opener.shoWndSrhBackToWndList()\">返回曲目列表<\/button><\/td><td style=\"text-align:center\"><button onclick=\"window.opener.showSongLyric(-33)\">显示滚动歌词<\/button><\/td><td style=\"text-align:right\">关键字<input type=text style=\"width:100px\" id=\"srcKeyWord\" value=\"" + temWhat + "\"> 范围<select id=\"searchArea\"><option value=1 " + ((where == 1)?"selected":"") + ">歌曲名<\/option><option value=2 " + ((where == 2)?"selected":"") + ">歌手<\/option><option value=3 " + ((where!=1 && where!=2)?"selected":"") + ">歌名+歌手<\/option><\/select><button onclick=\"window.opener.shoSearchMusic(document.getElementById(\'srcKeyWord\').value,document.getElementById(\'searchArea\').options[document.getElementById(\'searchArea\').selectedIndex].value)\">搜索<\/button><\/td><\/tr><\/table>");
- }
- var i = 0;
- var searchIndex = 0;
- winDsnByShosh.document.writeln("<table border=1 width=100%><tr><td><b>序号<\/b><\/td><td><b>ID/歌词<\/b><\/td> <td><b>歌曲<\/b><\/td><td><b>演唱者<\/b><\/td></thead>");
-
- var lrcHrefText;
- if (1 == where || 2 == where)
- {
- for (i = 0; i < listLen; i++)
- {
- if (musicList[i][where].match(reg))
- {
- searchIndex++;
- &nb