⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bd_synclrc.js

📁 这是网站里可以播放不同音乐的程序
💻 JS
字号:
var loaderInterval=null;var getPTimeout=null;var getObjectInterval=null;var getlrcInterval=null;var tmpScroll;var tmpScrollId;var perLength;var tmpMatchLrcLine=0;var preMatchLrcLine=-1;var count=0;var tmpLrcContent="";var preStyleObj=null;var nowStyleObj=null;var tmpLrcs=new Array();var lineCount=new Array();var perLineCount=new Array();var preLrcContent=new Array();var nextLrcContent=new Array();var color=new Array(21);color[0]="#000000";color[1]="#0d0500";color[2]="#1a0a00";color[3]="#270f00";color[4]="#341400";color[5]="#411900";color[6]="#4e1e00";color[7]="#5b2300";color[8]="#682800";color[9]="#752d00";color[10]="#823200";color[11]="#8f3700";color[12]="#9c3c00";color[13]="#a94100";color[14]="#b64600";color[15]="#c34b00";color[16]="#d05000";color[17]="#dd5500";color[18]="#ea5a00";color[19]="#f75f00";color[20]="#ff5a00";function lrcInterface(pType,lrcID){preStyleObj=document.styleSheets[0].rules[0];nowStyleObj=document.styleSheets[0].rules[1];var tmpOutput=document.getElementById('LrcShower_div');count=0;tmpOutput.innerHTML="<br><br><br><br><br><br><span style='font-size:12px;margin-left:12px'>&nbsp;正在加载歌词信息,请您稍等片刻....";tmpLrcContent="";tmpLrcs=new Array();if(getObjectInterval!=null)clearInterval(getObjectInterval);getObjectInterval=setInterval(getObject,200);function getObject(){bdLRC=new bdSyncLRC();if(bdLRC!=null){if(getObjectInterval!=null)clearInterval(getObjectInterval);bdLRC.setPlayer(pType);bdLRC.setURL(lrcID);bdLRC.setOutput("LrcShower_div");bdLRC.Exchange();bdLRC.begin()}else{if(count==25){if(getObjectInterval!=null)clearInterval(getObjectInterval);tmpOutput.innerHTML="<br><br><br><br><br><br><span style='font-size:12px;margin-left:12px'>&nbsp;可能是因为网络的原因,系统没有找到合适的歌词。请稍后重试."}else count++}}};function bdSyncLRC(){var playerObj=null;var playerTypeStr=null;var lrcURL="";var lrcShower="";var lrcContent="";var lrcObjArray=new Array();this.preLRC=new Array();this.offsetTime=0;this.scrollMoveLen=20;var playerType="MPH"};bdSyncLRC.prototype.setPlayer=function(){if(arguments.length>=1){arg=arguments[0];this.playerType=arg;if(arg=="MPH"||arg=="MPL")arg="MediaPlayer1";else if(arg=="RP")arg="RealPlayer1";playerTypeStr=String(arg);if(typeof(arg)=="string")this.playerObj=document.getElementById(arg);else if(typeof(arg)=="object")this.playerObj=arg}};bdSyncLRC.prototype.setPlayerType=function(){if(arguments.length>=1){this.playerType=arguments[0]}};bdSyncLRC.prototype.getPlayer=function(){if(typeof(document.getElementById("this.playerObj"))=='object')return this.playerObj;else return null};bdSyncLRC.prototype.getPlayerType=function(){return this.playerType};bdSyncLRC.prototype.setURL=function(){if(arguments.length>=1){var lrcDir,lrcFileName;lrcDir=String(Math.floor((parseInt(arguments[0])/100)));lrcFileName=arguments[0]+".lrc";this.lrcURL="http://box.zhangmen.baidu.com"+"/bdlrc/"+lrcDir+"/"+lrcFileName}};bdSyncLRC.prototype.getURL=function(){return this.lrcURL};bdSyncLRC.prototype.setContent=function(){if(arguments.length>=1)this.lrcContent=arguments[0]};bdSyncLRC.prototype.getContent=function(){return this.lrcContent};bdSyncLRC.prototype.setLRC=function(){if(arguments.length>=1)this.lrcObjArray=arguments[0]};bdSyncLRC.prototype.getLRC=function(){return this.lrcObjArray};bdSyncLRC.prototype.setOutput=function(showerId){this.lrcShower=showerId};bdSyncLRC.prototype.getOutput=function(){if(this.lrcShower!=""){arg=this.lrcShower;if(typeof(arg)=="string")return document.getElementById(arg);else if(typeof(arg)=="object")return arg};return null};bdSyncLRC.prototype.multiLRC=function(lrcLine){thisObj=this;tmpVar=lrcLine.split("]");if(tmpVar.length>=2){lrcText=tmpVar[tmpVar.length-1];for(j=0;j<tmpVar.length-1;j++){lrcTime=tmpVar[j]+"]";thisObj.preLRC.push(lrcTime+""+lrcText)}}};bdSyncLRC.prototype.preSyncLRC=function(){if(this.getContent()==null||this.getContent()=="")return;lrcLines=this.getContent().split("\n");tmpArr=new Array();var tmpItem;var n=0;var cc=lrcLines.length;for(n=0;n<cc;n++){this.multiLRC(replaceStr(lrcLines[n]))}this.preLRC.sort();var tmpVar="aaa";for(n=this.preLRC.length-1;n>=0;n--)if(this.preLRC[n]==tmpVar){tmpVar=this.preLRC[n];this.preLRC.splice(n,1)}else tmpVar=this.preLRC[n];preTime=0;indexLRC=1;tmpArr[0]=new LRCItem(0,"");for(n=0;n<this.preLRC.length;n++){if(this.preLRC[n].length>9){tmpTime=getLyrcTime(this.preLRC[n]);tmpLrc=getLyrc(this.preLRC[n]);if(tmpTime<preTime||tmpLrc=="")continue;if(tmpTime==0){tmpArr[0].lrcContent=tmpLrc;continue};preTime=tmpTime;tmpItem=new LRCItem(tmpTime,tmpLrc);tmpArr[indexLRC++]=tmpItem}};var tmpItem=new LRCItem(3600,"Over...");tmpArr[indexLRC]=tmpItem;this.setLRC(tmpArr);getLineCount(tmpArr);getLrcContent(tmpArr);tmpLrcs=this.getLRC();tmpScroll=this.getOutput();tmpScrollId=this.getOutput();perLength=this.scrollMoveLen;if(perLength<=0)perLength=1;tmpScrollId.scrollTop=0;tmpMatchLrcLine=0;preMatchLrcLine=-1};function replaceStr(tmpStr){return tmpStr.replace(/^\s*|\s*$/g,"")};function getLyrc(tmpStr){try{tmpArray=tmpStr.split("]");return tmpArray[tmpArray.length-1]}catch(e){};return ""};function getLyrcTime(tmpStr){try{tmpChar=tmpStr.split("]")[0].split("[")[1];tmpVar=tmpChar.split(":");if(tmpVar.length<2)return 0;min=tmpVar[1].split(".")[0];tmpInt=parseInt(tmpVar[0])*60+parseFloat(min);if(!isNaN(tmpInt))return tmpInt}catch(e){};return 0};function LRCItem(){var lrcTime=-1;var lrcContent="";if(arguments.length>=2){this.lrcTime=arguments[0];this.lrcContent=arguments[1]}};function getLineCount(tmpLrcs){for(m=0;m<tmpLrcs.length;m++){lineCount[m]=Math.floor(tmpLrcs[m].lrcContent.length/67);perLineCount[m]=0;for(j=0;j<m;j++)perLineCount[m]+=lineCount[j]}};function getLrcContent(tmpLrcs){for(m=0;m<tmpLrcs.length;m++){preLrcContent[m]="<br>"+"<br>"+"<br>"+"<br>"+"<br>"+"<br>"+"<br>";nextLrcContent[m]="";for(j=0;j<m-1;j++)preLrcContent[m]+="<span style='font-size:12px;margin-left:12px'>&nbsp;<font color=#000000>"+replaceStr(tmpLrcs[j].lrcContent)+"</font></span><br>";for(j=m+1;j<tmpLrcs.length;j++)nextLrcContent[m]+="<span style='font-size:12px;margin-left:12px'>&nbsp;<font color=#000000>"+replaceStr(tmpLrcs[j].lrcContent)+"</font></span><br>";nextLrcContent[m]+="<br><br><br><br><br><br><br>"}};bdSyncLRC.prototype.Exchange=function(){var xmlhttp=null;if(window.XMLHttpRequest){xmlhttp=new XMLHttpRequest()}else{if(window.ActiveXObject){try{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")}catch(ee){xmlhttp=new ActiveXObject("MSXML.XMLHTTP")}}};var tmpURL=this.getURL();thisObj=this;var tmpStr="";try{xmlhttp.open("GET",tmpURL,false);xmlhttp.onreadystatechange=function(){if((xmlhttp.readyState==4)&&(xmlhttp.status==200)){tmpStr=bdBytes2Str(xmlhttp.responseBody);thisObj.setContent(tmpStr)}};xmlhttp.send(null)}catch(ee){}};bdSyncLRC.prototype.begin=function(){thisObj=this;tmpPlayerObj=thisObj.getPlayer();var tmpOutput=document.getElementById('LrcShower_div');if(getlrcInterval!=null)clearInterval(getlrcInterval);getlrcInterval=setInterval(getlrc,100);count=0;function getlrc(){if(typeof(thisObj.getContent())!="undefined"){if(getlrcInterval!=null)clearInterval(getlrcInterval);thisObj.preSyncLRC();if(thisObj.getLRC()[0].lrcContent!="")thisObj.getOutput().innerHTML="<br><br><br><br><br><br>"+"<span style='font-size:12px;margin-left:12px'>&nbsp;<font color=#000000>"+replaceStr(thisObj.getLRC()[0].lrcContent)+"</font></span><br>"+nextLrcContent[0];else thisObj.getOutput().innerHTML="<br><br><br><br><br><br>"+nextLrcContent[0];getPlayingTime(thisObj.getPlayer(),thisObj)}else{if(count==50){if(getlrcInterval!=null)clearInterval(getlrcInterval);tmpOutput.innerHTML="<br><br><br><br><br><br><span style='font-size:12px;margin-left:12px'>&nbsp;可能是因为网络的原因,系统没有找到合适的歌词。请稍后重试"}else count++}}};function getPlayingTime(playerObj,bdLRCObj){try{tmpbdLRCObj=bdLRCObj;var tmpPlayerObj=playerObj;if(typeof(tmpPlayerObj)=="string")tmpPlayerObj=document.getElementById(tmpPlayerObj);if(getPTimeout!=null)clearTimeout(getPTimeout);getPTimeout=window.setTimeout("getPlayingTime(tmpPlayerObj,tmpbdLRCObj)",1000);bdsyncLyrc(tmpbdLRCObj)}catch(e){}};function getCurrentPosition(tmpPlayer,playerType){if(playerType=="MPH")return tmpPlayer.controls.currentPosition;else if(playerType=="MPL")return tmpPlayer.CurrentPosition;else if(playerType=="RP")return tmpPlayer.GetPosition()/1000;return 0};function findLoc(bdLRCObj){var start;var end;var tmpPlayer=bdLRCObj.getPlayer();currentTime=getCurrentPosition(tmpPlayer,bdLRCObj.getPlayerType());if(currentTime>=tmpLrcs[tmpMatchLrcLine].lrcTime){start=tmpMatchLrcLine;end=tmpLrcs.length}else{start=0;end=tmpMatchLrcLine+1};var j;for(j=start;j<end;j++){nowLrc=tmpLrcs[j];nextLrc=tmpLrcs[(j<end-1)?j+1:j];nowTime=nowLrc.lrcTime+bdLRCObj.offsetTime;nextTime=nextLrc.lrcTime+bdLRCObj.offsetTime;if(nowTime<=currentTime&&currentTime<nextTime)return j};return 0};function bdsyncLyrc(bdLRCObj){try{var j=findLoc(bdLRCObj);tmpMatchLrcLine=j;tmpLrcContent=preLrcContent[j];if(j>0)tmpLrcContent+="<span class=prelrc>&nbsp;"+replaceStr(tmpLrcs[j-1].lrcContent)+"</span><br>";tmpLrcContent+="<span class=nowlrc>&nbsp;"+replaceStr(tmpLrcs[j].lrcContent)+"</span><br>";tmpLrcContent+=nextLrcContent[j];if(preMatchLrcLine!=tmpMatchLrcLine){tmpScroll.innerHTML=tmpLrcContent;if(Math.abs(tmpMatchLrcLine-preMatchLrcLine)>1){tmpScrollId.scrollTop=(tmpMatchLrcLine+perLineCount[tmpMatchLrcLine]+1)*perLength}else{var count_i=0;function scrollAdd(){tmpScrollId.scrollTop+=2*(1+lineCount[preMatchLrcLine]);count_i++;if(count_i>=10){clearInterval(loaderInterval);loaderInterval=null;count_i=0}else if(count_i<0){count_i=0}};if(loaderInterval!=null){clearInterval(loaderInterval);loaderInterval=null;count_i=0};loaderInterval=setInterval(scrollAdd,25)}};preMatchLrcLine=tmpMatchLrcLine}catch(e){}};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -