1. Previous scrolling just Anch to refresh, now is not by line to scroll, in fact, is in a certain period of time to move the whole, for example, in the 1S refresh 10 times, because the naked eye looks like scrolling.
The key code is as follows:
Copy Code code as follows:
Float plus = Currentdunringtime = 0? 30
: 30
+ (((float) currenttime-(float) sentencttime)/(float) currentdunringtime)
* (float) 30;
Scroll up this is based on the length of the lyrics to scroll, the overall move up
Canvas.translate (0,-plus);
Plus is the size of each move, which is calculated according to the duration of the lyrics, and the longer the time, the smaller the plus value. Specific look at the code.
Here is the message to get the lyrics:
Copy Code code as follows:
public void Updateindex (long) {
This.currenttime = time;
Lyrics serial Number
index = Mlyric.getnowsentenceindex (time);
if (index!=-1) {
Sentence sen = sentencelist.get (index);
Sentencttime = Sen.getfromtime ();
Currentdunringtime = Sen.getduring ();
}
}
Here's the new thread:
Copy Code code as follows:
Class Uiupdatethread implements Runnable {
long time = 100; Scrolling speed
public void Run () {
while (Mp.isplaying ()) {
Lyricview.updateindex (Mp.getcurrentposition ());
Mhandler.post (Mupdateresults);
try {
Thread.Sleep (time);
catch (Interruptedexception e) {
TODO auto-generated Catch block
E.printstacktrace ();
}
}
}
}
Project Link:
Click to download