修复界面不可见时状态栏歌词没有更新的问题
parent
b0881726fa
commit
9eb87911a6
|
@ -228,7 +228,7 @@ export default class Lyric {
|
||||||
} else this.playingLineNum = 0
|
} else this.playingLineNum = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
setAutoPause(autoPause) {
|
setDisabledAutoPause(autoPause) {
|
||||||
this.linePlayer.setAutoPause(autoPause)
|
this.linePlayer.setDisabledAutoPause(autoPause)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,15 +225,15 @@ export default class LinePlayer {
|
||||||
this._init()
|
this._init()
|
||||||
}
|
}
|
||||||
|
|
||||||
setAutoPause(autoPause) {
|
setDisabledAutoPause(disabledAutoPause) {
|
||||||
if (autoPause) {
|
if (disabledAutoPause) {
|
||||||
timeoutTools.nextTick = window.requestAnimationFrame.bind(window)
|
|
||||||
timeoutTools.cancelNextTick = window.cancelAnimationFrame.bind(window)
|
|
||||||
} else {
|
|
||||||
timeoutTools.nextTick = (handler) => {
|
timeoutTools.nextTick = (handler) => {
|
||||||
return setTimeout(handler, 20)
|
return setTimeout(handler, 20)
|
||||||
}
|
}
|
||||||
timeoutTools.cancelNextTick = clearTimeout.bind(global)
|
timeoutTools.cancelNextTick = clearTimeout.bind(global)
|
||||||
|
} else {
|
||||||
|
timeoutTools.nextTick = window.requestAnimationFrame.bind(window)
|
||||||
|
timeoutTools.cancelNextTick = window.cancelAnimationFrame.bind(window)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -186,8 +186,18 @@ export const setLyric = () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const setAutoPause = (autoPause: boolean) => {
|
export const setDisabledAutoPause = (disabledAutoPause: boolean) => {
|
||||||
lrc.setAutoPause(autoPause)
|
lrc.setDisabledAutoPause(disabledAutoPause)
|
||||||
|
}
|
||||||
|
|
||||||
|
let sources = new Map<string, boolean>()
|
||||||
|
let prevDisabled = false
|
||||||
|
export const setDisableAutoPauseBySource = (disabled: boolean, source: string) => {
|
||||||
|
sources.set(source, disabled)
|
||||||
|
const currentDisabled = Array.from(sources.values()).some(e => e)
|
||||||
|
if (prevDisabled == currentDisabled) return
|
||||||
|
prevDisabled = currentDisabled
|
||||||
|
setDisabledAutoPause(currentDisabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import { appSetting } from '@renderer/store/setting'
|
||||||
|
|
||||||
import useSync from './useSync'
|
import useSync from './useSync'
|
||||||
import useOpenAPI from './useOpenAPI'
|
import useOpenAPI from './useOpenAPI'
|
||||||
|
import useStatusbarLyric from './useStatusbarLyric'
|
||||||
import useUpdate from './useUpdate'
|
import useUpdate from './useUpdate'
|
||||||
import useDataInit from './useDataInit'
|
import useDataInit from './useDataInit'
|
||||||
import useHandleEnvParams from './useHandleEnvParams'
|
import useHandleEnvParams from './useHandleEnvParams'
|
||||||
|
@ -27,6 +28,7 @@ export default () => {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const initSyncService = useSync()
|
const initSyncService = useSync()
|
||||||
const initOpenAPI = useOpenAPI()
|
const initOpenAPI = useOpenAPI()
|
||||||
|
const initStatusbarLyric = useStatusbarLyric()
|
||||||
useEventListener()
|
useEventListener()
|
||||||
const initPlayer = usePlayer()
|
const initPlayer = usePlayer()
|
||||||
const handleEnvParams = useHandleEnvParams()
|
const handleEnvParams = useHandleEnvParams()
|
||||||
|
@ -65,6 +67,7 @@ export default () => {
|
||||||
void initDeeplink(envParams)
|
void initDeeplink(envParams)
|
||||||
void initSyncService()
|
void initSyncService()
|
||||||
void initOpenAPI()
|
void initOpenAPI()
|
||||||
|
void initStatusbarLyric()
|
||||||
sendInited()
|
sendInited()
|
||||||
|
|
||||||
handleListAutoUpdate()
|
handleListAutoUpdate()
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { watch } from '@common/utils/vueTools'
|
||||||
import { appSetting } from '@renderer/store/setting'
|
import { appSetting } from '@renderer/store/setting'
|
||||||
import { sendOpenAPIAction } from '@renderer/utils/ipc'
|
import { sendOpenAPIAction } from '@renderer/utils/ipc'
|
||||||
import { openAPI } from '@renderer/store'
|
import { openAPI } from '@renderer/store'
|
||||||
import { setAutoPause } from '@renderer/core/lyric'
|
import { setDisableAutoPauseBySource } from '@renderer/core/lyric'
|
||||||
|
|
||||||
export default () => {
|
export default () => {
|
||||||
const handleEnable = async(enable: boolean, port: string, bindLan: boolean) => {
|
const handleEnable = async(enable: boolean, port: string, bindLan: boolean) => {
|
||||||
|
@ -21,9 +21,9 @@ export default () => {
|
||||||
openAPI.message = error.message
|
openAPI.message = error.message
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
if (openAPI.address) {
|
if (openAPI.address) {
|
||||||
setAutoPause(false)
|
setDisableAutoPauseBySource(true, 'openAPI')
|
||||||
} else {
|
} else {
|
||||||
setAutoPause(true)
|
setDisableAutoPauseBySource(false, 'openAPI')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
import { watch } from '@common/utils/vueTools'
|
||||||
|
import { appSetting } from '@renderer/store/setting'
|
||||||
|
import { setDisableAutoPauseBySource } from '@renderer/core/lyric'
|
||||||
|
|
||||||
|
export default () => {
|
||||||
|
const handleEnable = (enable: boolean) => {
|
||||||
|
setDisableAutoPauseBySource(enable, 'statusBarLyric')
|
||||||
|
}
|
||||||
|
watch(() => appSetting['player.isShowStatusBarLyric'], enable => {
|
||||||
|
handleEnable(enable)
|
||||||
|
})
|
||||||
|
|
||||||
|
return async() => {
|
||||||
|
if (appSetting['player.isShowStatusBarLyric']) {
|
||||||
|
handleEnable(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue