In Flash, use as to realize LRC lyrics dynamic display _flash as

Source: Internet
Author: User
Winplay can use the LRC plug-in to achieve the dynamic display of lyrics, in Flash can also [demo], select a ranking version of the song, more easily seen.
If you are careful, open a LRC file with Notepad, his file format is as follows:

[TI: Dongfeng Break]
[AR: Jay Chou]
[Al: Ye Huimei]
[By: Ye Zesheng]
[offset:500]
[00:00.00] Dongfeng break
[00:03.22]
[00:05.46] Jay Chou
[00:07.37] Word: Wenshanensis song: Jay Chou
[00:10.27] LRC: Ye Zesheng
[00:12.45]
[00:13.88] A lonely stand in the window
[00:20.2] I'm behind the door pretending you're still here.
[00:26.52] The moon is more lonely as the old haunts revisit
[00:32.98] The sober candle of the Midnight can't bear to criticize me
[00:40.04] A pot of drift roaming the hard throat
[00:46.47] After you leave the wine warm memories Miss Thin
[00:52.93] How to steal the time of water flowing eastward
[00:59.28] bloom is once ripe and I miss it.
[01:06.31]
[03:50.68] [02:58.31] [01:09.30] who is playing an easterly wind with Pipa
[03:57.23] [03:04.88] [01:16.23] years on the wall peeling see when you were young
[04:03.55] [03:11.11] [01:22.58] Remember that year we were young
[04:10.3] [03:17.62] [01:28.87] And now the sound of my waiting you haven't heard
[04:17.07] [03:24.5] [01:36.08] who is playing an easterly wind with Pipa
[04:23.67] [03:30.95] [01:42.3] Maple Leaf will dye the end of the story I see
[04:30.02] [03:37.35] [01:48.88] The ancient road outside the fence I lead you through
[04:36.69] [01:55.52] The years of wild smoke and grass, even the breakup is very quiet
[05:01.62] [02:07.25] [02:15.36]
[02:27.75] A pot of drift roaming the hard throat
[02:35.15] After you leave the wine warm memories Miss Thin
[02:41.54] How to steal the time of water flowing eastward
[02:48.06] bloom is once ripe and I miss it.
[05:09.43] [04:49.63] [02:57.23]
[03:43.97] The years of wild smoke and grass have even parted

This thing if Flash read is more troublesome, but if the regular expression of the VBS is more convenient, the result output to the following look:

<?xml version= "1.0" encoding= "GB2312" standalone= "yes"?>
<! DOCTYPE MUSIC [
<! ELEMENT MUSIC (ARTIST, TITLE, ALBUM, LANGUAGE, Editer, OFFSET, lyrics) >
<! ELEMENT ARTIST (#PCDATA) >
<! ELEMENT TITLE (#PCDATA) >
<! ELEMENT ALBUM (#PCDATA) >
<! ELEMENT LANGUAGE (#PCDATA) >
<! ELEMENT editer (#PCDATA) >
<! ELEMENT OFFSET (#PCDATA) >
<! ELEMENT lyrics (LRC) *>
<! ELEMENT LRC (#PCDATA) >
<! Attlist LRC
TAG CDATA #REQUIRED >
]>
<MUSIC>
<ARTIST> Jay Chou </ARTIST>
<TITLE> Dongfeng Broken </TITLE>
<ALBUM> Ye Huimei </ALBUM>
<LANGUAGE></LANGUAGE>
<EDITER> Ye Zesheng </EDITER>
<OFFSET>500</OFFSET>
<LYRICS>
&LT;LRC tag= "0" > Dongfeng break </LRC>
&LT;LRC tag= "3220" ></LRC>
&LT;LRC tag= "5460" > Jay Chou </LRC>
&LT;LRC tag= "7370" >: Wenshanensis Song: Jay Chou </LRC>
&LT;LRC tag= "10270" &GT;LRC: Ye Zesheng </LRC>
&LT;LRC tag= "12450" ></LRC>
&LT;LRC tag= "13880" > A lonely stand in the window </LRC>
&LT;LRC tag= "20200" > I'm behind the door pretending you're not gone </LRC>
&LT;LRC tag= "26520" > old haunts such as revisiting the Moon more lonely </LRC>
&LT;LRC tag= "32980" > Midnight Sober Candle can't bear to criticize me </LRC>
&LT;LRC tag= "40040" > a pot of wandering in the throat </LRC>
&LT;LRC tag= "46470" > After you left the wine warm memories Miss Thin </LRC>
&LT;LRC tag= "52930" > Water eastward flow time how to steal </LRC>
&LT;LRC tag= "59280" > Blossom just once mature I miss </LRC>
&LT;LRC tag= "66310" ></LRC>
&LT;LRC tag= "69300" > who is playing with Pipa a song Dong Feng break </LRC>
&LT;LRC tag= "76230" > Years on the wall flaking see childhood </LRC>
&LT;LRC tag= "82580" > Still remember that year we were very young </LRC>
&LT;LRC tag= "88870" > and now the music is faint I wait you haven't heard </LRC>
&LT;LRC tag= "96080" > who is playing with Pipa a song Dong Feng break </LRC>
&LT;LRC tag= "102300" > Maple Leaf will dye the end of the story I see through </LRC>
&LT;LRC tag= "108880" > The ancient road outside the fence I lead you through </LRC>
&LT;LRC tag= "115520" > The old days of grass-smoke and weeds are very silent </LRC>
&LT;LRC tag= "127250" ></LRC>
&LT;LRC tag= "135360" ></LRC>
&LT;LRC tag= "147750" > a pot of wandering in the throat </LRC>
&LT;LRC tag= "155150" > After you left the wine warm memories Miss Thin </LRC>
&LT;LRC tag= "161540" > Water eastward flow time how to steal </LRC>
&LT;LRC tag= "168060" > Blossom just once mature I miss </LRC>
&LT;LRC tag= "177230" ></LRC>
&LT;LRC tag= "178310" > who is playing with Pipa a song Dong Feng break </LRC>
&LT;LRC tag= "184880" > Years on the wall flaking see childhood </LRC>
&LT;LRC tag= "191110" > Still remember that year we were very young </LRC>
&LT;LRC tag= "197620" > and now the music is faint I wait you haven't heard </LRC>
&LT;LRC tag= "204500" > who is playing with Pipa a song Dong Feng break </LRC>
&LT;LRC tag= "210950" > Maple Leaf will dye the end of the story I see through </LRC>
&LT;LRC tag= "217350" > The ancient road outside the fence I lead you through </LRC>
&LT;LRC tag= "223970" > The days of the wild smoke and weeds even break up </LRC>
&LT;LRC tag= "230680" > who is playing with Pipa a song Dong Feng break </LRC>
&LT;LRC tag= "237230" > Years on the wall flaking see childhood </LRC>
&LT;LRC tag= "243550" > Still remember that year we were very young </LRC>
&LT;LRC tag= "250300" > and now the music is faint I wait you haven't heard </LRC>
&LT;LRC tag= "257070" > who is playing with Pipa a song Dong Feng break </LRC>
&LT;LRC tag= "263670" > Maple Leaf will dye the end of the story I see through </LRC>
&LT;LRC tag= "270020" > The ancient road outside the fence I lead you through </LRC>
&LT;LRC tag= "276690" > The old days of grass-smoke and weeds are very silent </LRC>
&LT;LRC tag= "289630" ></LRC>
&LT;LRC tag= "301620" ></LRC>
&LT;LRC tag= "309430" ></LRC>
</LYRICS>
</MUSIC>



The use of Flash XML read, he will be very convenient.

Music_word_arr = new Array ();
New array, storing lyrics
Music_word_xml = new XML ();
New XML object, that is, storing the XML described above
Music_word_xml.ignorewhite = true;
Music_word_xml.onload = function (success) {
if (success) {
var tracks_xml = Music_word_xml.firstchild;
var LRC = tracks_xml.childnodes[tracks_xml.childnodes.length-1];
for (var i = 0; i<lrc.childnodes.length; i++) {
var time = lrc.childnodes[i].attributes. TAG;
Get time
var geci = lrc.childnodes[i].childnodes;
Get lyrics
Music_word_arr.push ({time:time, word:geci});
Place time information and lyrics in Music_word_arr array
}
Show_word ();
Output
} else {
Trace ("Error loading Musicword.");
If not loaded, an error is displayed
}
Delete Music_word_xml;
deleting XML objects
};
Music_word_xml.load (URL);


Now let's talk about how to keep the lyrics synchronized with the songs.

Just look at the code, the code shows everything:

function Show_word () {
t = 0;
Word.text = "";
Music_word = new Object ();
Loop Object
Music_word.interval = function () {
var zs = mysound.position/100;
if (int (music_word_arr[t). time/100) = = Int (ZS)) {
if (music_word_arr[t). Word = = "" | | Music_word_arr[t]. Word = = null) {
Word.text = "";
} else {
Word.text = Music_word_arr[t]. Word;
}
t++;
}
if (int (music_word_arr[t). time/100) <int (ZS)) {
t++;
}
};
Music_word_n = SetInterval (Music_word, "interval", 10);
}

Should be easy to understand, because not long, noteworthy places have a:
if (int (music_word_arr[t). time/100) <int (ZS)) {
t++;
}

What's the use of this line of code? He is mainly used to solve the song played, and the lyrics have not yet loaded, at this time, he is responsible for the lyrics to catch the song play Progress, and not let the song waiting for him. In fact, he also has a more important function, I want to do the player should know, here I will not say, you think about it, haha ~~~~~ (as if some wrong??) ¥%¥# Unidentified Object landed ... Ah, ~!!!!!. )

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.