mirror of
https://github.com/ikun0014/lx-music-mobile.git
synced 2025-07-05 21:58:56 +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) {
|
private void setViewLyric(int lineNum) {
|
||||||
lastLine = lineNum;
|
lastLine = lineNum;
|
||||||
if (lyricView == null) return;
|
if (lyricView == null) return;
|
||||||
if (lineNum > lines.size() - 1) return;
|
if (lineNum < 0 || lineNum > lines.size() - 1) return;
|
||||||
HashMap line = (HashMap) lines.get(lineNum);
|
HashMap line = (HashMap) lines.get(lineNum);
|
||||||
if (line == null) {
|
if (line == null) {
|
||||||
lyricView.setLyric("", "");
|
lyricView.setLyric("", "");
|
||||||
@ -138,7 +138,7 @@ public class Lyric extends LyricPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlay(int lineNum, String text) {
|
public void onPlay(int lineNum) {
|
||||||
setViewLyric(lineNum);
|
setViewLyric(lineNum);
|
||||||
// Log.d("Lyric", lineNum + " " + text + " " + (String) line.get("translation"));
|
// Log.d("Lyric", lineNum + " " + text + " " + (String) line.get("translation"));
|
||||||
}
|
}
|
||||||
|
@ -185,7 +185,7 @@ public class LyricPlayer {
|
|||||||
int curLineNum = this.findCurLineNum(getCurrentTime());
|
int curLineNum = this.findCurLineNum(getCurrentTime());
|
||||||
if (this.curLineNum != curLineNum) {
|
if (this.curLineNum != curLineNum) {
|
||||||
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() {
|
private void handleMaxLine() {
|
||||||
this.onPlay(this.curLineNum, (String) lines.get(curLineNum).get("text"));
|
this.onPlay(this.curLineNum);
|
||||||
this.pause();
|
this.pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,17 +219,18 @@ public class LyricPlayer {
|
|||||||
// Log.d("Lyric", "refresh: " + curLineNum);
|
// Log.d("Lyric", "refresh: " + curLineNum);
|
||||||
|
|
||||||
curLineNum++;
|
curLineNum++;
|
||||||
if (curLineNum == maxLine) {
|
if (curLineNum >= maxLine) {
|
||||||
handleMaxLine();
|
handleMaxLine();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
HashMap curLine = lines.get(curLineNum);
|
HashMap curLine = lines.get(curLineNum);
|
||||||
HashMap nextLine = lines.get(curLineNum + 1);
|
|
||||||
int currentTime = getCurrentTime();
|
int currentTime = getCurrentTime();
|
||||||
int driftTime = currentTime - (int) curLine.get("time");
|
int driftTime = currentTime - (int) curLine.get("time");
|
||||||
// Log.d("Lyric", "driftTime: " + driftTime);
|
// Log.d("Lyric", "driftTime: " + driftTime);
|
||||||
|
|
||||||
if (driftTime >= 0 || curLineNum == 0) {
|
if (driftTime >= 0 || curLineNum == 0) {
|
||||||
|
HashMap nextLine = lines.get(curLineNum + 1);
|
||||||
delay = (int) nextLine.get("time") - (int) curLine.get("time") - driftTime;
|
delay = (int) nextLine.get("time") - (int) curLine.get("time") - driftTime;
|
||||||
// Log.d("Lyric", "delay: " + delay + " driftTime: " + driftTime);
|
// Log.d("Lyric", "delay: " + delay + " driftTime: " + driftTime);
|
||||||
if (delay > 0) {
|
if (delay > 0) {
|
||||||
@ -246,7 +247,7 @@ public class LyricPlayer {
|
|||||||
refresh();
|
refresh();
|
||||||
}, delay);
|
}, delay);
|
||||||
}
|
}
|
||||||
onPlay(curLineNum, (String) curLine.get("text"));
|
onPlay(curLineNum);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -262,7 +263,7 @@ public class LyricPlayer {
|
|||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPlay(int lineNum, String text) {}
|
public void onPlay(int lineNum) {}
|
||||||
|
|
||||||
public void onSetLyric(List lines) {}
|
public void onSetLyric(List lines) {}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user