mirror of
https://github.com/ikun0014/lx-music-mobile.git
synced 2025-07-03 04:12:10 +08:00
修复一些潜在的错误
This commit is contained in:
parent
7742f23f6d
commit
0e1deed340
@ -89,7 +89,7 @@ public class Lyric extends LyricPlayer {
|
||||
private void setViewLyric(int lineNum) {
|
||||
lastLine = lineNum;
|
||||
if (lyricView == null) return;
|
||||
if (lineNum > lines.size() - 1) return;
|
||||
if (lineNum < 0 || lineNum > lines.size() - 1) return;
|
||||
HashMap line = (HashMap) lines.get(lineNum);
|
||||
if (line == null) {
|
||||
lyricView.setLyric("", "");
|
||||
@ -138,7 +138,7 @@ public class Lyric extends LyricPlayer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlay(int lineNum, String text) {
|
||||
public void onPlay(int lineNum) {
|
||||
setViewLyric(lineNum);
|
||||
// Log.d("Lyric", lineNum + " " + text + " " + (String) line.get("translation"));
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ public class LyricPlayer {
|
||||
int curLineNum = this.findCurLineNum(getCurrentTime());
|
||||
if (this.curLineNum != curLineNum) {
|
||||
this.curLineNum = curLineNum;
|
||||
this.onPlay(curLineNum, (String) ((HashMap) lines.get(curLineNum)).get("text"));
|
||||
this.onPlay(curLineNum);
|
||||
}
|
||||
}
|
||||
|
||||
@ -210,7 +210,7 @@ public class LyricPlayer {
|
||||
}
|
||||
|
||||
private void handleMaxLine() {
|
||||
this.onPlay(this.curLineNum, (String) lines.get(curLineNum).get("text"));
|
||||
this.onPlay(this.curLineNum);
|
||||
this.pause();
|
||||
}
|
||||
|
||||
@ -219,17 +219,18 @@ public class LyricPlayer {
|
||||
// Log.d("Lyric", "refresh: " + curLineNum);
|
||||
|
||||
curLineNum++;
|
||||
if (curLineNum == maxLine) {
|
||||
if (curLineNum >= maxLine) {
|
||||
handleMaxLine();
|
||||
return;
|
||||
}
|
||||
HashMap curLine = lines.get(curLineNum);
|
||||
HashMap nextLine = lines.get(curLineNum + 1);
|
||||
|
||||
int currentTime = getCurrentTime();
|
||||
int driftTime = currentTime - (int) curLine.get("time");
|
||||
// Log.d("Lyric", "driftTime: " + driftTime);
|
||||
|
||||
if (driftTime >= 0 || curLineNum == 0) {
|
||||
HashMap nextLine = lines.get(curLineNum + 1);
|
||||
delay = (int) nextLine.get("time") - (int) curLine.get("time") - driftTime;
|
||||
// Log.d("Lyric", "delay: " + delay + " driftTime: " + driftTime);
|
||||
if (delay > 0) {
|
||||
@ -246,7 +247,7 @@ public class LyricPlayer {
|
||||
refresh();
|
||||
}, delay);
|
||||
}
|
||||
onPlay(curLineNum, (String) curLine.get("text"));
|
||||
onPlay(curLineNum);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -262,7 +263,7 @@ public class LyricPlayer {
|
||||
init();
|
||||
}
|
||||
|
||||
public void onPlay(int lineNum, String text) {}
|
||||
public void onPlay(int lineNum) {}
|
||||
|
||||
public void onSetLyric(List lines) {}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user