From 6c6571e704412f81d007826e44a1b2912fd88dc3 Mon Sep 17 00:00:00 2001 From: lyswhut Date: Wed, 27 Nov 2024 13:02:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=90=AF=E7=94=A8=E6=A1=8C?= =?UTF-8?q?=E9=9D=A2=E6=AD=8C=E8=AF=8D=E6=97=B6=E8=93=9D=E7=89=99=E6=AD=8C?= =?UTF-8?q?=E8=AF=8D=E5=9C=A8=E9=94=81=E5=B1=8F=E5=90=8E=E8=A2=AB=E6=9A=82?= =?UTF-8?q?=E5=81=9C=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/toside/music/mobile/lyric/Lyric.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/android/app/src/main/java/cn/toside/music/mobile/lyric/Lyric.java b/android/app/src/main/java/cn/toside/music/mobile/lyric/Lyric.java index 3503d23..08ab659 100644 --- a/android/app/src/main/java/cn/toside/music/mobile/lyric/Lyric.java +++ b/android/app/src/main/java/cn/toside/music/mobile/lyric/Lyric.java @@ -30,6 +30,7 @@ public class Lyric extends LyricPlayer { boolean isShowRoma; boolean isShowLyricView = false; boolean isSendLyricTextEvent = false; + boolean isScreenOff = false; String lyricText = ""; String translationText = ""; String romaLyricText = ""; @@ -102,22 +103,20 @@ public class Lyric extends LyricPlayer { // } // } + private boolean isDisableAutoPause() { + return !isRunPlayer || isSendLyricTextEvent; + } private void handleScreenOff() { - if (!isRunPlayer || !isShowLyricView) return; + isScreenOff = true; + if (isDisableAutoPause()) return; setTempPause(true); - - if (lyricView != null) { - lyricView.runOnUiThread(() -> { - lyricView.destroyView(); - }); - } } private void handleScreenOn() { - if (!isRunPlayer || !isShowLyricView) return; + isScreenOff = false; + if (isDisableAutoPause()) return; if (lyricView == null) lyricView = new LyricView(reactAppContext, lyricEvent); lyricView.runOnUiThread(() -> { - lyricView.showLyricView(); handleGetCurrentLyric(lastLine); setTempPause(false); }); @@ -130,7 +129,7 @@ public class Lyric extends LyricPlayer { } private void setCurrentLyric(String lyric, ArrayList extendedLyrics) { - if (isShowLyricView && lyricView != null) { + if (isShowLyricView && !isScreenOff && lyricView != null) { lyricView.setLyric(lyric, extendedLyrics); } if (isSendLyricTextEvent) {