The LRC lyrics in the MP3 player were analyzed last time. Today we will talk about how to play the LRC lyrics in sync with those in the mp3 player.
In as2, we generally use the sound or MediaPlayback component for playing mp3 files... the former is the sound management class, and the latter supports playing mp3 and flv files ..
For mp3 players .. we can directly use sound to solve basic requirements. However, to better synchronize LRC synchronization, we will use the MediaPlayback component, because MediaPlayback provides the cuePoint (prompt point) function, we can add the time in the array of lyrics to MediaPlayback. In this way, we can listen to the cuePoint event of MediaPlayback through the middleware to achieve synchronous display.
First, we pull a MediaPlayback component to the library ..
Then add the lyrics as the prompt point.
_ Root. attachMovie ("MediaPlayback", "mp3Player", 0); // Use the code to copy the component.
Then we use the addCuePoint function in MediaPlayback to add the lrc array as the cuepoint
Format: mp3Player. addCuePoint ("lyrics", Time );
Add a cuepoint event to display the lyrics.
Var listenerObject: Object = new Object ();
ListenerObject. cuePoint = function (eventObj: Object ){
TxtLRC. text = eventObj. cuePointName; // here... the lyrics are the cuepoint attribute of the prompt point.
};
Mp3Player. addEventListener ("cuePoint", listenerObject );
Now, you only need to specify the address of the lyrics and the address of the mp3.