当前位置:首页 > 程序&理念 >

网上流传的歌词同步技术

时间:2006-12-07 14:48:18浏览:138046 转载

<html>
<head>
<meta http-equiv=Content-Type content=text/html; charset=gb2312>
<title>谱乐视听 -- 千言万语</title>
<STYLE type=text/css>
TD { FONT-SIZE: 9pt; LINE-HEIGHT: 17px; }
BODY{
FONT-SIZE: 9pt;
LINE-HEIGHT: 17px;
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
#lrcollbox td, #lrcollbox font {font-family: 黑体; font-size: 16px;}
#lrcoll td { color:#0080C0; cursor: default; }
#lrcbox { color:#00FF00 }
#lrcfilter { filter: alpha(opacity=0) }
#lrcbc { color:#FFFF33 }
</STYLE>
<script language=\"JavaScript\">
var lyrics=\"[ti:千言万语]
[ar:邓丽君]
[au:尔英]
[al:邓丽君 - 宝丽金 88 极品音色系列]
[by:www.aboutplayer.com]
[00:02.00]千言万语 - 邓丽君
[00:09.25]电影《彩云飞》插曲
[00:16.50]古月 曲 尔英 词
[00:23.70] 
[00:25.20]<00:25.70>不<00:26.00>知<00:26.35>道<00:26.80>为<00:27.30>了<00:27.90>什<00:28.60>麽<00:30.20>
[00:31.35]<00:31.85>忧<00:32.20>愁<00:32.60>它<00:33.00>围<00:33.40>绕<00:34.15>着<00:34.60>我<00:36.60>
[00:37.60]<00:38.10>我<00:38.45>每<00:38.85>天<00:39.25>都<00:39.60>在<00:40.45>祈<00:41.30>祷<00:43.80>
[00:43.90]<00:44.20>快<00:44.60>赶<00:45.00>走<00:45.45>爱<00:45.95>的<00:46.50>寂<00:47.75>寞<00:48.80>
[00:48.90]<00:49.20>那<00:49.50>天<00:49.95>起<00:51.30> <00:51.90>你<00:52.25>对<00:52.65>我<00:53.00>说<00:54.40>
[00:54.90]<00:55.40>永<00:56.05>远<00:56.80>地<00:57.50>爱<00:58.60>着<00:59.10>我<01:00.70>
[01:00.85]<01:01.35>千<01:02.00>言<01:03.80>和<01:04.70>万<01:05.35>语<01:06.80>
[01:06.90]<01:07.25>随<01:08.05>风<01:09.25>云<01:10.65>掠<01:11.20>过<01:12.80>
[01:14.00]<01:14.50>不<01:14.85>知<01:15.25>道<01:15.65>为<01:16.30>了<01:16.80>什<01:17.45>麽<01:19.25>
[01:20.10]<01:20.60>忧<01:21.05>愁<01:21.40>它<01:21.90>围<01:22.35>绕<01:23.05>着<01:23.40>我<01:25.60>
[01:26.40]<01:26.90>我<01:27.25>每<01:27.65>天<01:28.05>都<01:28.50>在<01:29.50>祈<01:30.15>祷<01:32.50>
[01:32.60]<01:33.10>快<01:33.45>赶<01:33.85>走<01:34.25>爱<01:34.90>的<01:35.40>寂<01:36.70>寞<01:39.30>
[01:40.80] 
[01:41.30] 
[02:01.45] 
[02:01.95] 
[02:03.45]<02:03.95>不<02:04.25>知<02:04.70>道<02:05.10>为<02:05.75>了<02:06.30>什<02:06.95>麽<02:08.10>
[02:09.70]<02:10.20>忧<02:10.55>愁<02:10.95>它<02:11.40>围<02:11.85>绕<02:12.50>着<02:12.90>我<02:15.40>
[02:15.90]<02:16.40>我<02:16.85>每<02:17.15>天<02:17.50>都<02:17.90>在<02:18.90>祈<02:19.60>祷<02:22.10>
[02:22.20]<02:22.50>快<02:22.90>赶<02:23.30>走<02:23.75>爱<02:24.30>的<02:24.80>寂<02:26.10>寞<02:27.20>
[02:27.30]<02:27.50>那<02:27.85>天<02:28.30>起<02:29.60> <02:30.10>你<02:30.50>对<02:30.90>我<02:31.40>说<02:32.50>
[02:33.15]<02:33.65>永<02:34.25>远<02:35.05>地<02:35.75>爱<02:36.90>着<02:37.40>我<02:38.65>
[02:39.15]<02:39.65>千<02:40.35>言<02:42.15>和<02:43.05>万<02:43.55>语<02:45.30>
[02:45.40]<02:45.70>随<02:46.40>风<02:47.50>云<02:49.10>掠<02:49.70>过<02:50.90>
[02:52.40]<02:52.90>不<02:53.25>知<02:53.65>道<02:54.05>为<02:54.65>了<02:55.25>什<02:55.85>麽<02:57.55>
[02:58.50]<02:59.00>忧<02:59.40>愁<02:59.90>它<03:00.35>围<03:00.75>绕<03:01.35>着<03:01.80>我<03:03.65>
[03:04.75]<03:05.25>我<03:05.60>每<03:06.00>天<03:06.40>都<03:06.80>在<03:07.80>祈<03:08.50>祷<03:11.10>
[03:11.20]<03:11.45>快<03:12.20>赶<03:12.60>走<03:12.90>爱<03:13.50>的<03:14.10>寂<03:15.45>寞<03:18.45>
[03:19.95] 
[03:21.45] 
[03:22.95] 
[03:23.25]网上服务由 www.aboutplayer.com 提供\";
var lrcO;
var lrcobj;

function lrcClass(tt)
{
 this.inr = [];

 this.oTime = 0;

 this.dts = -1;
 this.dte = -1;
 this.dlt = -1;
 this.ddh;
 this.fjh;

 lrcbc.style.width = 0;

 if(/[offset:(-?d+)]/i.test(tt))
 this.oTime = RegExp.$1/1000;
 
 tt = tt.replace(/[:][^$
]*(
|$)/g,\"$1\");
 tt = tt.replace(/[[^[]:]*]/g,\"\");
 tt = tt.replace(/[[^[]]*[^[]d]+[^[]]*:[^[]]*]/g,\"\");
 tt = tt.replace(/[[^[]]*:[^[]]*[^[]d.]+[^[]]*]/g,\"\");
 tt = tt.replace(/<[^<>]*[^<>d]+[^<>]*:[^<>]*>/g,\"\");
 tt = tt.replace(/<[^<>]*:[^<>]*[^<>d.]+[^<>]*>/g,\"\");

 while(/[[^[]]+:[^[]]+]/.test(tt))
 {
 tt = tt.replace(/(([[^[]]+:[^[]]+])+[^[
]*)[^[]*/,\"
\");
 var zzzt = RegExp.$1;
 /^(.+])([^]]*)$/.exec(zzzt);
 var ltxt = RegExp.$2;
 var eft = RegExp.$1.slice(1,-1).split(\"][\");
 for(var ii=0; ii<eft.length; ii++)
 {
 var sf = eft[ii].split(\":\");
 var tse = parseInt(sf[0],10) * 60 + parseFloat(sf[1]);
 var sso = { t:[] , w:[] , n:ltxt }
 sso.t[0] = tse-this.oTime;
 this.inr[this.inr.length] = sso;
 }
 }
 this.inr = this.inr.sort( function(a,b){return a.t[0]-b.t[0];} );

 for(var ii=0; ii<this.inr.length; ii++)
 {
 while(/<[^<>]+:[^<>]+>/.test(this.inr[ii].n))
 {
 this.inr[ii].n = this.inr[ii].n.replace(/<(d+):([d.]+)>/,\"%=%\");
 var tse = parseInt(RegExp.$1,10) * 60 + parseFloat(RegExp.$2);
 this.inr[ii].t[this.inr[ii].t.length] = tse-this.oTime;
 }
 lrcbc.innerHTML = \"<font>\"+ this.inr[ii].n.replace(/&/g,\"&amp;\").replace(/</g,\"&lt;\").replace(/>/g,\"&gt;\").replace(/%=%/g,\"</font><font>\") +\" </font>\";
 var fall = lrcbc.getElementsByTagName(\"font\");
 for(var wi=0; wi<fall.length; wi++)
 this.inr[ii].w[this.inr[ii].w.length] = fall[wi].offsetWidth;
 this.inr[ii].n = lrcbc.innerText;
 }

 this.run = function(tme)
 {
 if(tme<this.dts || tme>=this.dte)
 {
 var ii;
 for(ii=this.inr.length-1; ii>=0 && this.inr[ii].t[0]>tme; ii--){}
 if(ii<0) return;
 this.ddh = this.inr[ii].t;
 this.fjh = this.inr[ii].w;
 this.dts = this.inr[ii].t[0];
 this.dte = (ii<this.inr.length-1)?this.inr[ii+1].t[0]:aboutplayer.currentMedia.duration;

 lrcwt1.innerText = this.retxt(ii-7);
 lrcwt2.innerText = this.retxt(ii-6);
 lrcwt3.innerText = this.retxt(ii-5);
 lrcwt4.innerText = this.retxt(ii-4);
 lrcwt5.innerText = this.retxt(ii-3);
 lrcwt6.innerText = this.retxt(ii-2);
 lrcwt7.innerText = this.retxt(ii-1);
 lrcfilter.innerText = this.retxt(ii-1);
 lrcwt8.innerText = this.retxt(ii+1);
 lrcwt9.innerText = this.retxt(ii+2);
 lrcwt10.innerText = this.retxt(ii+3);
 lrcwt11.innerText = this.retxt(ii+4);
 lrcwt12.innerText = this.retxt(ii+5);
 lrcwt13.innerText = this.retxt(ii+6);
 this.print(this.retxt(ii));
 if(this.dlt==ii-1)
 {
 clearTimeout(lrcO);
 golrcoll(0);
 golrcolor(0);
 }
 this.dlt = ii;
 }
 var bbw = 0;
 var ki;
 for(ki=0; ki<this.ddh.length && this.ddh[ki]<=tme; ki++)
 bbw += this.fjh[ki];
 var kt = ki-1;
 var sc = ((ki<this.ddh.length)?this.ddh[ki]:this.dte) - this.ddh[kt];
 var tc = tme - this.ddh[kt];
 bbw -= this.fjh[kt] - tc / sc * this.fjh[kt];
 if(bbw>lrcbox.offsetWidth)
 bbw = lrcbox.offsetWidth;
 lrcbc.style.width = Math.round(bbw);
 }

 this.retxt = function(i)
 {
 return (i<0 || i>=this.inr.length)?\"\":this.inr[i].n;
 }

 this.print = function(txt)
 {
 lrcbox.innerText = txt;
 lrcbc.innerText = txt;
 }

 this.print(\"www.aboutplayer.com\");
 lrcwt1.innerText = \"\";
 lrcwt2.innerText = \"\";
 lrcwt3.innerText = \"\";
 lrcwt4.innerText = \"\";
 lrcwt5.innerText = \"\";
 lrcwt6.innerText = \"\";
 lrcwt8.innerText = \"\";
 lrcwt9.innerText = \"\";
 lrcwt10.innerText = \"\";
 lrcwt11.innerText = \"\";
 lrcwt12.innerText = \"\";
 lrcwt13.innerText = \"\";
}

function golrcoll(s)
{
 lrcoll.style.top = -2-(s++)*3;
 if(s<=6)
 lrcO = setTimeout(\"golrcoll(\"+s+\")\",100);
}

function golrcolor(t)
{
 lrcfilter.filters.alpha.opacity = 100-(t++)*10;
 if(t<=10)
 setTimeout(\"golrcolor(\"+t+\")\",60);
}

function lrcrun(m)
{
 lrcobj = new lrcClass(m);
 setInterval(\"try {lrcobj.run(aboutplayer.controls.currentPosition)} catch(hh){}\",10);
}
</script>
<script language=\"VBScript\">
sub aboutplayer_openStateChange(sf)
if sf=13 then
lrcrun(lyrics)
end if
end sub
</script>
</head>
<script language=\"JavaScript\">
self.moveTo(0,0);
self.resizeTo(screen.availWidth,screen.availHeight);
</script>
<base onmouseover=\"window.status=' aboutplayer.com 别忘了把地址告诉你QQ上的朋友哦!'; return true;\">
<body leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" onselectstart=\"self.event.returnValue=false\" oncontextmenu=\"return false;\">
<center>
<object classid=\"clsid:6bf52a52-394a-11d3-b153-00c04f79faa6\" id=\"aboutplayer\" width=\"480\" height=\"240\">
<param name=\"url\" value=\"http://aboutplayer.com/play.asp?id=6&action=url\">
<param name=\"volume\" value=\"100\">
<param name=\"enablecontextmenu\" value=\"0\">
<param name=\"enableerrordialogs\" value=\"0\">
</object>
<div id=\"lrcollbox\" style=\"overflow:hidden; height:260; width:480; background-color:#000000;\">
<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\" id=\"lrcoll\" style=\"position:relative; top: -20px;\">
<tr><td nowrap height=\"20\" align=\"center\" id=\"lrcwt1\"></td></tr>
<tr><td nowrap height=\"20\" align=\"center\" id=\"lrcwt2\"></td></tr>
<tr><td nowrap height=\"20\" align=\"center\" id=\"lrcwt3\"></td></tr>
<tr><td nowrap height=\"20\" align=\"center\" id=\"lrcwt4\"></td></tr>
<tr><td nowrap height=\"20\" align=\"center\" id=\"lrcwt5\"></td></tr>
<tr><td nowrap height=\"20\" align=\"center\" id=\"lrcwt6\"></td></tr>
<tr><td nowrap height=\"20\" align=\"center\">
<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr><td nowrap height=\"20\"><span id=\"lrcwt7\" style=\"height:20\"></span></td></tr>
<tr style=\"position:relative; top: -20px; z-index:6\"><td nowrap height=\"20\"><div id=\"lrcfilter\" style=\"overflow:hidden; width:100%; color:#FFFF33; height:20\"></div></td></tr>
</table>
</td></tr>
<tr style=\"position:relative; top: -20px\"><td nowrap height=\"20\" align=\"center\">
<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr><td nowrap height=\"20\"><span id=\"lrcbox\" style=\"height:20\">歌词加载中</span></td></tr>
<tr style=\"position:relative; top: -20px; z-index:6;\"><td nowrap height=\"20\"><div id=\"lrcbc\" style=\"overflow:hidden; height:20; width:0;\"></div></td></tr>
</table>
</td></tr>
<tr style=\"position:relative; top: -40px;\"><td nowrap height=\"20\" align=\"center\" id=\"lrcwt8\"></td></tr>
<tr style=\"position:relative; top: -40px;\"><td nowrap height=\"20\" align=\"center\" id=\"lrcwt9\"></td></tr>
<tr style=\"position:relative; top: -40px;\"><td nowrap height=\"20\" align=\"center\" id=\"lrcwt10\"></td></tr>
<tr style=\"position:relative; top: -40px;\"><td nowrap height=\"20\" align=\"center\" id=\"lrcwt11\"></td></tr>
<tr style=\"position:relative; top: -40px;\"><td nowrap height=\"20\" align=\"center\" id=\"lrcwt12\"></td></tr>
<tr style=\"position:relative; top: -40px;\"><td nowrap height=\"20\" align=\"center\" id=\"lrcwt13\"></td></tr>
</table>
</div>
</center>
</body>
</html>
1

上一篇:优秀程序员的两大要素:懒 + 笨
下一篇:成为编程高手的八大奥秘

发表评论

昵称:  验证码:

关于博主

博主

博主:BlueCode

职业:web程序

简介:2002年开始一直从事Web制作,网站运营,会PHP+MYSQL ASP+MSSQL,微信开发