快速业务通道

flash中显示LRC歌词原理

作者 佚名技术 来源 服务器技术 浏览 发布时间 2012-07-10
0);
} else if (lineData.indexOf("]") == startCharID+6) {
//兼容[00:21]格式
lrcData.info[i] = lineData.slice(lineData.lastIndexOf("]")+1);
lrcData.timer[i] = Number(lineData.slice(startCharID+1, startCharID+3))*60+Number(lineData.slice(startCharID+4, startCharID+6));
}
} else {
var tagName;
//解析标识标签
//[ar:艺人名]
if (lineData.indexOf("[ar:") != -1) {
tagName = "艺人:";
} else if (lineData.indexOf("[ti:") != -1) {
//[ti:曲名]
tagName = "歌曲:";
} else if (lineData.indexOf("[al:") != -1) {
//[al:专辑名]
tagName = "专辑:";
} else if (lineData.indexOf("[by:") != -1) {
//[by:编辑LRC歌词的网友信息]
tagName = "歌词制作:";
}
if (lineData.lastIndexOf("]")>lineData.lastIndexOf("[")) {
lrcData.info[i] = tagName+lineData.slice(lineData.lastIndexOf(":")+1, lineData.lastIndexOf("]"));
} else {
lrcData.info[i] = lineData;
}
if (lineData.indexOf("[offset:") != -1) {
//[offset:时间补偿值]
lrcData.info[i] = "------------------------------------------";
offset = Number(lineData.slice(lineData.lastIndexOf(":")+1, lineData.lastIndexOf("]")));
if (isNaN(offset)) {
offset = 0;
}
}
lrcData.timer[i] = 0;
}
i++;
//[01:17][02:24][02:53][03:21] 多时间标签支持
var surplusData = new String(lineData.slice(lineData.indexOf("]")+1));
if (surplusData.indexOf("[") != -1) {
hasMoreTags = true;
parseLineData(surplusData);
}
}
function sortTimer() {
lrcData.timerID = new Array();
for (var i = 0; i lrcData.timerID[i] = i;
}
////使用快速排序(备用)
//QuickSorter(lrcData.timer);
InsertionSorter(lrcData.timer);
lrcData.tmpInfo = new Array();
for (var i = 0; i lrcData.tmpInfo[i] = lrcData.info[lrcData.timerID[i]];
}
lrcData.info = lrcData.tmpInfo;
}
//数组排序算法:插入排序
//这份算法代码核心是从网上找的
function InsertionSorter(list) {
for (var i = 1; i var t = list[i];
var j = i;
while ((j>0) && (list[j-1]>t)) {
list[j] = list[j-1];
var myC = lrcData.timerID[j];
lrcData.timerID[j] = lrcData.timerID[j-1];
lrcData.timerID[j-1] = myC;
--j;
}
list[j] = t;
}
}
//快速排序(备用)
//这份算法代码核心是从网上找的
function QuickSorter(list) {
var low = 0;
var high = list.length-1;
if (high<=low) {
return;
} else if (high == low+1) {
if (list[low]>list[high]) {
Swap(low, high);
return;
}
}
myQuickSort(list, low, high);
}
function myQuickSort(list, low, high) {
if (low var pivot = Partition(list, low, high);
myQuickSort(list, low, pivot-1);
myQuickSort(list, pivot+1, high);
}
}
function Partition(list, low, high) {
var pivot;
var pivot = list[low];
while (low while (low=pivot) {
high--;
}
if (low != high) {
Swap(low, high);
low++;
}
while (low low++;
}
if (low != high) {
Swap(low, high);
high--;
}
}
return low;
}
function Swap(l, r) {
var myl = lrcData.timerID[l];
lrcData.timerID[l] = lrcData.timerID[r];
lrcData.timerID[r] = myl;
lrcData.timer[l] = lrcData.timer[l] ^ lrcData.timer[r];
lrcData.timer[r] = lrcData.timer[l] ^ lrcData.timer[r];
lrcData.timer[l] = lrcData.timer[l] ^ lrcData.timer[r];
}
//
//LRC显示
function startShowLRC() {
this.onEnterFrame = checTimer;
isLRCShow = true;
var t = getTimer();
var

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号