From a907b9dff34a61bd1e278a994e7bbb673f42caf0 Mon Sep 17 00:00:00 2001 From: lyswhut Date: Thu, 1 Feb 2024 12:35:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E7=8A=B6=E6=80=81=E6=A0=8F?= =?UTF-8?q?=E6=AD=8C=E8=AF=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/app/build.gradle | 2 + android/app/proguard-rules.pro | 4 + .../cn/toside/music/mobile/lyric/Lyric.java | 153 ++++++++++++++---- .../music/mobile/lyric/LyricModule.java | 8 + android/gradle.properties | 2 +- package.json | 2 +- src/config/defaultSetting.ts | 2 + src/core/desktopLyric.ts | 8 + src/lang/en_us.json | 4 + src/lang/zh_cn.json | 4 + .../LyricDesktop/IsAutoPauseLyric.tsx | 33 ++++ .../settings/LyricDesktop/LyricType.tsx | 74 +++++++++ .../Setting/settings/LyricDesktop/index.tsx | 4 + src/types/app_setting.d.ts | 10 ++ src/utils/nativeModules/lyricDesktop.ts | 96 +++++------ 15 files changed, 327 insertions(+), 79 deletions(-) create mode 100644 src/screens/Home/Views/Setting/settings/LyricDesktop/IsAutoPauseLyric.tsx create mode 100644 src/screens/Home/Views/Setting/settings/LyricDesktop/LyricType.tsx diff --git a/android/app/build.gradle b/android/app/build.gradle index 06c47e10c..a830526c2 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -195,6 +195,8 @@ dependencies { // implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3") implementation group: 'wang.harlon.quickjs', name: 'wrapper-android', version: '1.0.0' + implementation 'com.github.xiaowine:Lyric-Getter-Api:6.0.0' + if (hermesEnabled.toBoolean()) { implementation("com.facebook.react:hermes-android") } else { diff --git a/android/app/proguard-rules.pro b/android/app/proguard-rules.pro index a6db10512..b770bf058 100644 --- a/android/app/proguard-rules.pro +++ b/android/app/proguard-rules.pro @@ -24,3 +24,7 @@ **[] $VALUES; public *; } + +# 排除混淆墨•状态栏歌词相关API +-keep class cn.lyric.getter.api.data.*{*;} +-keep class cn.lyric.getter.api.API{*;} 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 f93fd84b7..4dd2ba6f6 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 @@ -15,12 +15,19 @@ import java.util.List; import java.util.Objects; +import cn.lyric.getter.api.API; +import cn.lyric.getter.api.data.ExtraData; + public class Lyric extends LyricPlayer { LyricView lyricView = null; LyricEvent lyricEvent = null; + API statusBarLyric = null; + ExtraData extraData = null; ReactApplicationContext reactAppContext; boolean isShowLyric = false; + boolean isUseDesktopLyric = true; + boolean isAutoPause = true; // String lastText = "LX Music ^-^"; int lastLine = 0; List lines = new ArrayList(); @@ -47,6 +54,7 @@ private void registerScreenBroadcastReceiver() { BroadcastReceiver screenOnOffReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { + if (!isAutoPause) return; String strAction = intent.getAction(); switch (Objects.requireNonNull(strAction)) { @@ -69,7 +77,7 @@ private void handleScreenOff() { if (!isShowLyric) return; setTempPause(true); - if (lyricView != null) { + if (isUseDesktopLyric && lyricView != null) { lyricView.runOnUiThread(() -> { lyricView.destroyView(); }); @@ -78,55 +86,73 @@ private void handleScreenOff() { private void handleScreenOn() { if (!isShowLyric) return; - if (lyricView == null) lyricView = new LyricView(reactAppContext, lyricEvent); - lyricView.runOnUiThread(() -> { - lyricView.showLyricView(); - setViewLyric(lastLine); + if (isUseDesktopLyric) { + if (lyricView == null) lyricView = new LyricView(reactAppContext, lyricEvent); + lyricView.runOnUiThread(() -> { + lyricView.showLyricView(); + updateLyric(lastLine); + setTempPause(false); + }); + } else { + updateLyric(lastLine); setTempPause(false); - }); + } } - private void setViewLyric(int lineNum) { + private void updateLyric(int lineNum) { lastLine = lineNum; - if (lyricView == null) return; - if (lineNum >= 0 && lineNum < lines.size()) { + if (!isShowLyric) return; + String lineLyric; + ArrayList extendedLyrics; + if (lineNum < 0 || lineNum > lines.size() - 1) { + lineLyric = ""; + extendedLyrics = new ArrayList<>(0); + } else { HashMap line = (HashMap) lines.get(lineNum); - if (line != null) { - lyricView.setLyric((String) line.get("text"), (ArrayList) line.get("extendedLyrics")); - return; + if (line == null) { + lineLyric = ""; + extendedLyrics = new ArrayList<>(0); + } else { + lineLyric = (String) line.get("text"); + extendedLyrics = (ArrayList) line.get("extendedLyrics"); } } - lyricView.setLyric("", new ArrayList<>(0)); + + if (isUseDesktopLyric) { + if (lyricView == null) return; + lyricView.setLyric(lineLyric, extendedLyrics); + } else { + if (statusBarLyric == null) return; + statusBarLyric.sendLyric(lineLyric, extraData); + } } public void showLyric(Bundle options, Promise promise) { if (lyricEvent == null) lyricEvent = new LyricEvent(reactAppContext); - if (lyricView == null) lyricView = new LyricView(reactAppContext, lyricEvent); - try { - lyricView.showLyricView(options); - } catch (Exception e) { - promise.reject(e); - Log.e("Lyric", e.getMessage()); - return; + hideLyric(); + isUseDesktopLyric = options.getBoolean("isUseDesktopLyric", true); + isAutoPause = options.getBoolean("isAutoPause", true); + if (isUseDesktopLyric) { + showDesktopLyric(options, promise); + } else { + showStatusBarLyric(options, promise); } - - isShowLyric = true; - promise.resolve(null); } public void hideLyric() { this.pause(); - if (lyricView != null) { - lyricView.destroy(); + if (isUseDesktopLyric) { + hideViewLyric(); + } else { + hideStatusBarLyric(); } - isShowLyric = false; } private void refreshLyric() { ArrayList extendedLyrics = new ArrayList<>(2); if (isShowTranslation && !"".equals(translationText)) extendedLyrics.add(translationText); if (isShowRoma && !"".equals(romaLyricText)) extendedLyrics.add(romaLyricText); - if (lyricView != null) super.setLyric(lyricText, extendedLyrics); + if (isShowLyric) super.setLyric(lyricText, extendedLyrics); } public void setLyric(String lyric, String translation, String romaLyric) { @@ -139,7 +165,7 @@ public void setLyric(String lyric, String translation, String romaLyric) { @Override public void onSetLyric(List lines) { this.lines = lines; - setViewLyric(-1); + updateLyric(-1); // for (int i = 0; i < lines.size(); i++) { // HashMap line = (HashMap) lines.get(i); // Log.d("Lyric", "onSetLyric: " +(String) line.get("text") + " " + line.get("extendedLyrics")); @@ -148,14 +174,22 @@ public void onSetLyric(List lines) { @Override public void onPlay(int lineNum) { - setViewLyric(lineNum); + updateLyric(lineNum); // Log.d("Lyric", lineNum + " " + text + " " + (String) line.get("translation")); } public void pauseLyric() { pause(); if (!isShowLyric) return; - if (lyricView != null) lyricView.setLyric("", new ArrayList<>(0)); + if (isUseDesktopLyric) { + if (lyricView != null) lyricView.setLyric("", new ArrayList<>(0)); + } else { + if (statusBarLyric != null) statusBarLyric.clearLyric(); + } + } + + public void toggleAutoPause(boolean isAutoPause) { + this.isAutoPause = isAutoPause; } public void lockLyric() { @@ -209,4 +243,63 @@ public void setPlayedColor(String unplayColor, String playedColor, String shadow public void setLyricTextPosition(String positionX, String positionY) { lyricView.setLyricTextPosition(positionX, positionY); } + + public void setUseDesktopLyric(boolean enable, Bundle options, Promise promise) { + if (isShowLyric) { + if (isUseDesktopLyric) { + hideViewLyric(); + } else { + hideStatusBarLyric(); + } + } + isUseDesktopLyric = enable; + if (enable) { + showDesktopLyric(options, promise); + } else { + showStatusBarLyric(options, promise); + } + } + + public void showDesktopLyric (Bundle options, Promise promise) { + if (lyricView == null) lyricView = new LyricView(reactAppContext, lyricEvent); + try { + lyricView.showLyricView(options); + } catch (Exception e) { + promise.reject(e); + Log.e("Lyric", e.getMessage()); + return; + } + isShowLyric = true; + promise.resolve(null); + } + + public void hideViewLyric() { + if (lyricView != null) { + lyricView.destroy(); + } + isShowLyric = false; + } + + public void showStatusBarLyric(Bundle options, Promise promise) { + if (statusBarLyric == null) { + statusBarLyric = new API(); + extraData = new ExtraData(); + extraData.setPackageName(reactAppContext.getPackageName()); + } + if (statusBarLyric.getHasEnable()) { + // statusBarLyric.updateLyric(lyricText); + isShowLyric = true; + promise.resolve(null); + } else { + isShowLyric = false; + promise.reject(new Exception("statusBar lyric disabled")); + } + } + + public void hideStatusBarLyric() { + if (statusBarLyric != null) { + statusBarLyric.clearLyric(); + } + isShowLyric = false; + } } diff --git a/android/app/src/main/java/cn/toside/music/mobile/lyric/LyricModule.java b/android/app/src/main/java/cn/toside/music/mobile/lyric/LyricModule.java index 05a29b042..924ac2728 100644 --- a/android/app/src/main/java/cn/toside/music/mobile/lyric/LyricModule.java +++ b/android/app/src/main/java/cn/toside/music/mobile/lyric/LyricModule.java @@ -121,6 +121,14 @@ public void pause(Promise promise) { promise.resolve(null); } + @ReactMethod + public void toggleAutoPause(boolean isAutoPause, Promise promise) { + if (lyric != null) { + lyric.toggleAutoPause(isAutoPause); + } + promise.resolve(null); + } + @ReactMethod public void toggleLock(boolean isLock, Promise promise) { if (lyric != null) { diff --git a/android/gradle.properties b/android/gradle.properties index 75b35e9da..31ccee055 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -27,7 +27,7 @@ android.enableJetifier=true # Use this property to specify which architecture you want to build. # You can also override it from the CLI using # ./gradlew -PreactNativeArchitectures=x86_64 -reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64 +reactNativeArchitectures=arm64-v8a # Use this property to enable support to the new architecture. # This will allow you to use TurboModules and the Fabric render in diff --git a/package.json b/package.json index b5391b916..f880937f3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lx-music-mobile", - "version": "1.4.2", + "version": "1.4.2-sl", "versionCode": 67, "private": true, "scripts": { diff --git a/src/config/defaultSetting.ts b/src/config/defaultSetting.ts index 4fbdce95a..5947e0bd0 100644 --- a/src/config/defaultSetting.ts +++ b/src/config/defaultSetting.ts @@ -40,6 +40,8 @@ const defaultSetting: LX.AppSetting = { 'playDetail.isShowLyricProgressSetting': false, 'desktopLyric.enable': false, + 'desktopLyric.isUseDesktopLyric': true, + 'desktopLyric.isAutoPause': true, 'desktopLyric.isLock': false, 'desktopLyric.width': 100, 'desktopLyric.maxLineNum': 5, diff --git a/src/core/desktopLyric.ts b/src/core/desktopLyric.ts index 613888a83..1facbb6bb 100644 --- a/src/core/desktopLyric.ts +++ b/src/core/desktopLyric.ts @@ -20,15 +20,20 @@ import { checkOverlayPermission, openOverlayPermissionActivity, onPositionChange, + toggleAutoPause, } from '@/utils/nativeModules/lyricDesktop' import settingState from '@/store/setting/state' import playerState from '@/store/player/state' import { tranditionalize } from '@/utils/simplify-chinese-main' import { getPosition } from '@/plugins/player' +import { toast } from '@/utils/tools' export const showDesktopLyric = async() => { const setting = settingState.setting await showLyric({ + enable: setting['desktopLyric.enable'], + isUseDesktopLyric: setting['desktopLyric.isUseDesktopLyric'], + isAutoPause: setting['desktopLyric.isAutoPause'], isShowToggleAnima: setting['desktopLyric.showToggleAnima'], isSingleLine: setting['desktopLyric.isSingleLine'], isLock: setting['desktopLyric.isLock'], @@ -43,6 +48,8 @@ export const showDesktopLyric = async() => { positionY: setting['desktopLyric.position.y'], textPositionX: setting['desktopLyric.textPosition.x'], textPositionY: setting['desktopLyric.textPosition.y'], + }).catch((err: any) => { + toast(err.message, 'long') }) let lrc = playerState.musicInfo.lrc ?? '' let tlrc = playerState.musicInfo.tlrc ?? '' @@ -70,6 +77,7 @@ export const setDesktopLyricPlaybackRate = setPlaybackRate export const toggleDesktopLyricTranslation = toggleTranslation export const toggleDesktopLyricRoma = toggleRoma export const toggleDesktopLyricLock = toggleLock +export const toggleDesktopAutoPause = toggleAutoPause export const setDesktopLyricColor = async(unplayColor: string | null, playedColor: string | null, shadowColor: string | null) => { return setColor(unplayColor ?? settingState.setting['desktopLyric.style.lyricUnplayColor'], playedColor ?? settingState.setting['desktopLyric.style.lyricPlayedColor'], diff --git a/src/lang/en_us.json b/src/lang/en_us.json index b3b1f1402..e44cefbc9 100644 --- a/src/lang/en_us.json +++ b/src/lang/en_us.json @@ -297,9 +297,13 @@ "setting_list_show_album_name": "Show song album name", "setting_lyric_dektop_permission_tip": "The desktop lyrics function needs to be granted the permission of LX Music to display the floating window in the system permission setting before it can be used. Do you go to the relevant interface to grant this permission?", "setting_lyric_desktop": "Desktop lyrics", + "setting_lyric_desktop_auto_pause": "Automatically pause lyrics when the screen is off", "setting_lyric_desktop_enable": "Show desktop lyrics", "setting_lyric_desktop_lock": "Lock lyrics", "setting_lyric_desktop_maxlineNum": "maximum number of lines", + "setting_lyric_desktop_show_lyric_type": "How to display lyrics", + "setting_lyric_desktop_show_lyric_type_desktop_lyric": "Desktop lyrics", + "setting_lyric_desktop_show_lyric_type_statusbar_lyric": "StatusBarLyric (requires \\\"StatusBarLyric\\\" installed)", "setting_lyric_desktop_single_line": "Use single line lyrics", "setting_lyric_desktop_text_opacity": "Lyric font transparency", "setting_lyric_desktop_text_size": "Lyric font size", diff --git a/src/lang/zh_cn.json b/src/lang/zh_cn.json index d74340b9a..cf92062a3 100644 --- a/src/lang/zh_cn.json +++ b/src/lang/zh_cn.json @@ -297,9 +297,13 @@ "setting_list_show_album_name": "显示歌曲专辑名", "setting_lyric_dektop_permission_tip": "桌面歌词功能需要在系统权限设置中授予LX Music显示悬浮窗口的权限才能使用,是否去相关界面授予此权限?", "setting_lyric_desktop": "桌面歌词", + "setting_lyric_desktop_auto_pause": "息屏时自动暂停歌词", "setting_lyric_desktop_enable": "显示桌面歌词", "setting_lyric_desktop_lock": "锁定歌词", "setting_lyric_desktop_maxlineNum": "最大行数", + "setting_lyric_desktop_show_lyric_type": "歌词显示方式", + "setting_lyric_desktop_show_lyric_type_desktop_lyric": "桌面歌词", + "setting_lyric_desktop_show_lyric_type_statusbar_lyric": "墨•状态栏歌词(需要安装“墨•状态栏歌词”模块)", "setting_lyric_desktop_single_line": "使用单行歌词", "setting_lyric_desktop_text_opacity": "歌词字体透明度", "setting_lyric_desktop_text_size": "歌词字体大小", diff --git a/src/screens/Home/Views/Setting/settings/LyricDesktop/IsAutoPauseLyric.tsx b/src/screens/Home/Views/Setting/settings/LyricDesktop/IsAutoPauseLyric.tsx new file mode 100644 index 000000000..963d8c86d --- /dev/null +++ b/src/screens/Home/Views/Setting/settings/LyricDesktop/IsAutoPauseLyric.tsx @@ -0,0 +1,33 @@ +import { memo } from 'react' +import { View } from 'react-native' +import { useSettingValue } from '@/store/setting/hook' +import { useI18n } from '@/lang' +import { createStyle } from '@/utils/tools' + + +import CheckBoxItem from '../../components/CheckBoxItem' +import { toggleDesktopAutoPause } from '@/core/desktopLyric' +import { updateSetting } from '@/core/common' + +export default memo(() => { + const t = useI18n() + const isAutoPause = useSettingValue('desktopLyric.isAutoPause') + const setLock = (isAutoPause: boolean) => { + void toggleDesktopAutoPause(isAutoPause).then(() => { + updateSetting({ 'desktopLyric.isAutoPause': isAutoPause }) + }) + } + + return ( + + + + ) +}) + + +const styles = createStyle({ + content: { + marginTop: 5, + }, +}) diff --git a/src/screens/Home/Views/Setting/settings/LyricDesktop/LyricType.tsx b/src/screens/Home/Views/Setting/settings/LyricDesktop/LyricType.tsx new file mode 100644 index 000000000..2a6f00007 --- /dev/null +++ b/src/screens/Home/Views/Setting/settings/LyricDesktop/LyricType.tsx @@ -0,0 +1,74 @@ +import { memo, useCallback, useMemo } from 'react' + +import { StyleSheet, View } from 'react-native' + +import SubTitle from '../../components/SubTitle' +import CheckBox from '@/components/common/CheckBox' +import { useSettingValue } from '@/store/setting/hook' +import { useI18n } from '@/lang' +import { updateSetting } from '@/core/common' + + +import { showDesktopLyric } from '@/core/desktopLyric' + +import settingState from '@/store/setting/state' + +const LIST = [ + { + id: true, + name: 'setting_lyric_desktop_show_lyric_type_desktop_lyric', + }, + { + id: false, + name: 'setting_lyric_desktop_show_lyric_type_statusbar_lyric', + }, +] as const + +const useActive = (id: LX.AppSetting['desktopLyric.isUseDesktopLyric']) => { + const isUseDesktopLyric = useSettingValue('desktopLyric.isUseDesktopLyric') + const isActive = useMemo(() => isUseDesktopLyric == id, [isUseDesktopLyric, id]) + return isActive +} + +const Item = ({ id, label, updaue }: { + id: LX.AppSetting['desktopLyric.isUseDesktopLyric'] + label: string + updaue: (id: LX.AppSetting['desktopLyric.isUseDesktopLyric']) => void +}) => { + const isActive = useActive(id) + // const [toggleCheckBox, setToggleCheckBox] = useState(false) + return { updaue(id) }} need /> +} + +export default memo(() => { + const t = useI18n() + + const list = useMemo(() => { + return LIST.map((item) => ({ id: item.id, name: t(item.name) })) + }, [t]) + + const updaue = useCallback((isUseDesktopLyric: boolean) => { + console.log(isUseDesktopLyric) + updateSetting({ 'desktopLyric.isUseDesktopLyric': isUseDesktopLyric }) + if (settingState.setting['desktopLyric.enable']) { + void showDesktopLyric() + } + }, []) + + return ( + + + { + list.map(({ id, name }) => ) + } + + + ) +}) + +const styles = StyleSheet.create({ + list: { + flexGrow: 0, + flexShrink: 1, + }, +}) diff --git a/src/screens/Home/Views/Setting/settings/LyricDesktop/index.tsx b/src/screens/Home/Views/Setting/settings/LyricDesktop/index.tsx index 484d9547c..9c8075287 100644 --- a/src/screens/Home/Views/Setting/settings/LyricDesktop/index.tsx +++ b/src/screens/Home/Views/Setting/settings/LyricDesktop/index.tsx @@ -2,6 +2,8 @@ import { memo } from 'react' import Section from '../../components/Section' import IsShowLyric from './IsShowLyric' +import LyricType from './LyricType' +import IsAutoPauseLyric from './IsAutoPauseLyric' import IsLockLyric from './IsLockLyric' import IsShowToggleAnima from './IsShowToggleAnima' import IsSingleLine from './IsSingleLine' @@ -21,9 +23,11 @@ export default memo(() => { return (
+ + diff --git a/src/types/app_setting.d.ts b/src/types/app_setting.d.ts index c71351d2b..b5ad2e3f1 100644 --- a/src/types/app_setting.d.ts +++ b/src/types/app_setting.d.ts @@ -221,6 +221,16 @@ declare global { */ 'desktopLyric.enable': boolean + /** + * 是否使用桌面歌词 + */ + 'desktopLyric.isUseDesktopLyric': boolean + + /** + * 是否息屏时自动暂停桌面歌词 + */ + 'desktopLyric.isAutoPause': boolean + /** * 是否锁定桌面歌词 */ diff --git a/src/utils/nativeModules/lyricDesktop.ts b/src/utils/nativeModules/lyricDesktop.ts index 1063807e4..44fcb9b9a 100644 --- a/src/utils/nativeModules/lyricDesktop.ts +++ b/src/utils/nativeModules/lyricDesktop.ts @@ -3,6 +3,7 @@ import { NativeModules, NativeEventEmitter } from 'react-native' const { LyricModule } = NativeModules let isShowLyric = false +let isUseDesktopLyric = true // export const themes = [ // { id: 'green', value: '#07c556' }, @@ -34,26 +35,10 @@ let isShowLyric = false const getAlpha = (num: number) => num / 100 const getTextSize = (num: number) => num / 10 - -/** - * show lyric - */ -export const showLyric = async({ - isShowToggleAnima, - isSingleLine, - width, - maxLineNum, - isLock, - unplayColor, - playedColor, - shadowColor, - opacity, - textSize, - positionX, - positionY, - textPositionX, - textPositionY, -}: { +interface Options { + enable: boolean + isUseDesktopLyric: boolean + isAutoPause: boolean isShowToggleAnima: boolean isSingleLine: boolean width: number @@ -68,23 +53,31 @@ export const showLyric = async({ positionY: number textPositionX: LX.AppSetting['desktopLyric.textPosition.x'] textPositionY: LX.AppSetting['desktopLyric.textPosition.y'] -}): Promise => { - if (isShowLyric) return Promise.resolve() +} + +/** + * show lyric + */ +export const showLyric = async(options: Options): Promise => { + // if (isShowLyric) return Promise.resolve() + isUseDesktopLyric = options.isUseDesktopLyric return LyricModule.showLyric({ - isSingleLine, - isShowToggleAnima, - isLock, - unplayColor, - playedColor, - shadowColor, - alpha: getAlpha(opacity), - textSize: getTextSize(textSize), - lyricViewX: positionX, - lyricViewY: positionY, - textX: textPositionX.toUpperCase(), - textY: textPositionY.toUpperCase(), - width, - maxLineNum, + isUseDesktopLyric: options.isUseDesktopLyric, + isAutoPause: options.isAutoPause, + isSingleLine: options.isSingleLine, + isShowToggleAnima: options.isShowToggleAnima, + isLock: options.isLock, + unplayColor: options.unplayColor, + playedColor: options.playedColor, + shadowColor: options.shadowColor, + alpha: getAlpha(options.opacity), + textSize: getTextSize(options.textSize), + lyricViewX: options.positionX, + lyricViewY: options.positionY, + textX: options.textPositionX.toUpperCase(), + textY: options.textPositionY.toUpperCase(), + width: options.width, + maxLineNum: options.maxLineNum, }).then(() => { isShowLyric = true }) @@ -153,12 +146,21 @@ export const toggleRoma = async(isShowRoma: boolean): Promise => { return LyricModule.toggleRoma(isShowRoma) } +/** + * toggle is auto pause lyric + * @param isAutoPause is auto pause lyric + */ +export const toggleAutoPause = async(isAutoPause: boolean): Promise => { + // if (!isShowLyric || !isUseDesktopLyric) return Promise.resolve() + return LyricModule.toggleAutoPause(isAutoPause) +} + /** * toggle is lock lyric window * @param isLock is lock lyric window */ export const toggleLock = async(isLock: boolean): Promise => { - if (!isShowLyric) return Promise.resolve() + if (!isShowLyric || !isUseDesktopLyric) return Promise.resolve() return LyricModule.toggleLock(isLock) } @@ -169,7 +171,7 @@ export const toggleLock = async(isLock: boolean): Promise => { * @param shadowColor */ export const setColor = async(unplayColor: string, playedColor: string, shadowColor: string): Promise => { - if (!isShowLyric) return Promise.resolve() + if (!isShowLyric || !isUseDesktopLyric) return Promise.resolve() return LyricModule.setColor(unplayColor, playedColor, shadowColor) } @@ -178,7 +180,7 @@ export const setColor = async(unplayColor: string, playedColor: string, shadowCo * @param alpha text alpha */ export const setAlpha = async(alpha: number): Promise => { - if (!isShowLyric) return Promise.resolve() + if (!isShowLyric || !isUseDesktopLyric) return Promise.resolve() return LyricModule.setAlpha(getAlpha(alpha)) } @@ -187,42 +189,42 @@ export const setAlpha = async(alpha: number): Promise => { * @param size text size */ export const setTextSize = async(size: number): Promise => { - if (!isShowLyric) return Promise.resolve() + if (!isShowLyric || !isUseDesktopLyric) return Promise.resolve() return LyricModule.setTextSize(getTextSize(size)) } export const setShowToggleAnima = async(isShowToggleAnima: boolean): Promise => { - if (!isShowLyric) return Promise.resolve() + if (!isShowLyric || !isUseDesktopLyric) return Promise.resolve() return LyricModule.setShowToggleAnima(isShowToggleAnima) } export const setSingleLine = async(isSingleLine: boolean): Promise => { - if (!isShowLyric) return Promise.resolve() + if (!isShowLyric || !isUseDesktopLyric) return Promise.resolve() return LyricModule.setSingleLine(isSingleLine) } export const setPosition = async(x: number, y: number): Promise => { - if (!isShowLyric) return Promise.resolve() + if (!isShowLyric || !isUseDesktopLyric) return Promise.resolve() return LyricModule.setPosition(x, y) } export const setMaxLineNum = async(maxLineNum: number): Promise => { - if (!isShowLyric) return Promise.resolve() + if (!isShowLyric || !isUseDesktopLyric) return Promise.resolve() return LyricModule.setMaxLineNum(maxLineNum) } export const setWidth = async(width: number): Promise => { - if (!isShowLyric) return Promise.resolve() + if (!isShowLyric || !isUseDesktopLyric) return Promise.resolve() return LyricModule.setWidth(width) } // export const fixViewPosition = async(): Promise => { -// if (!isShowLyric) return Promise.resolve() +// if (!isShowLyric|| !isUseDesktopLyric) return Promise.resolve() // return LyricModule.fixViewPosition() // } export const setLyricTextPosition = async(textX: LX.AppSetting['desktopLyric.textPosition.x'], textY: LX.AppSetting['desktopLyric.textPosition.y']): Promise => { - if (!isShowLyric) return Promise.resolve() + if (!isShowLyric || !isUseDesktopLyric) return Promise.resolve() return LyricModule.setLyricTextPosition(textX.toUpperCase(), textY.toUpperCase()) }