修复启用桌面歌词时蓝牙歌词在锁屏后被暂停的问题

This commit is contained in:
lyswhut 2024-11-27 13:02:52 +08:00
parent c21122a753
commit 6c6571e704

View File

@ -30,6 +30,7 @@ public class Lyric extends LyricPlayer {
boolean isShowRoma; boolean isShowRoma;
boolean isShowLyricView = false; boolean isShowLyricView = false;
boolean isSendLyricTextEvent = false; boolean isSendLyricTextEvent = false;
boolean isScreenOff = false;
String lyricText = ""; String lyricText = "";
String translationText = ""; String translationText = "";
String romaLyricText = ""; String romaLyricText = "";
@ -102,22 +103,20 @@ public class Lyric extends LyricPlayer {
// } // }
// } // }
private void handleScreenOff() { private boolean isDisableAutoPause() {
if (!isRunPlayer || !isShowLyricView) return; return !isRunPlayer || isSendLyricTextEvent;
setTempPause(true);
if (lyricView != null) {
lyricView.runOnUiThread(() -> {
lyricView.destroyView();
});
} }
private void handleScreenOff() {
isScreenOff = true;
if (isDisableAutoPause()) return;
setTempPause(true);
} }
private void handleScreenOn() { private void handleScreenOn() {
if (!isRunPlayer || !isShowLyricView) return; isScreenOff = false;
if (isDisableAutoPause()) return;
if (lyricView == null) lyricView = new LyricView(reactAppContext, lyricEvent); if (lyricView == null) lyricView = new LyricView(reactAppContext, lyricEvent);
lyricView.runOnUiThread(() -> { lyricView.runOnUiThread(() -> {
lyricView.showLyricView();
handleGetCurrentLyric(lastLine); handleGetCurrentLyric(lastLine);
setTempPause(false); setTempPause(false);
}); });
@ -130,7 +129,7 @@ public class Lyric extends LyricPlayer {
} }
private void setCurrentLyric(String lyric, ArrayList<String> extendedLyrics) { private void setCurrentLyric(String lyric, ArrayList<String> extendedLyrics) {
if (isShowLyricView && lyricView != null) { if (isShowLyricView && !isScreenOff && lyricView != null) {
lyricView.setLyric(lyric, extendedLyrics); lyricView.setLyric(lyric, extendedLyrics);
} }
if (isSendLyricTextEvent) { if (isSendLyricTextEvent) {