javascript之水平横向滚动歌词同步的应用

2019-06-02 20:35:49于丽
参考地址:http://aboutplayer.com

var lrc0, lrc1, lrc2;
moveflag = false;
var top, bottom;
var lrcobj;
var lrctop;
predlt = 0;
curdlt = 0;

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

  this.oTime = 0;

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

  if(/[offset:(-?d+)]/i.test(tt))
    this.oTime = RegExp.$1/1000;

  tt = tt.replace(/[:][^$n]*(n|$)/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(/(([[^[]]+:[^[]]+])+[^[rn]*)[^[]*/,"n");
    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] = Math.round((tse-this.oTime)*1000)/1000;
      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] = Math.round((tse-this.oTime)*1000)/1000;