修复无法关闭状态栏歌曲进度的问题

pull/733/head
lyswhut 2021-12-13 14:07:26 +08:00
parent f76f4d9d29
commit 0f5d2189e0
3 changed files with 11 additions and 10 deletions

View File

@ -62,13 +62,17 @@ export default ({ setting, playNext }) => {
// if (!isPlay) audio.play() // if (!isPlay) audio.play()
} }
const handleSetTaskBarState = (progress, status) => {
if (setting.value.player.isShowTaskProgess) setTaskBarProgress(progress, status)
}
const handlePlay = () => { const handlePlay = () => {
prevProgressStatus = 'normal' prevProgressStatus = 'normal'
setTaskBarProgress(playProgress.progress, prevProgressStatus) handleSetTaskBarState(playProgress.progress, prevProgressStatus)
} }
const handlePause = () => { const handlePause = () => {
prevProgressStatus = 'paused' prevProgressStatus = 'paused'
setTaskBarProgress(playProgress.progress, prevProgressStatus) handleSetTaskBarState(playProgress.progress, prevProgressStatus)
clearBufferTimeout() clearBufferTimeout()
} }
@ -76,13 +80,13 @@ export default ({ setting, playNext }) => {
setNowPlayTime(0) setNowPlayTime(0)
setMaxplayTime(0) setMaxplayTime(0)
prevProgressStatus = 'none' prevProgressStatus = 'none'
setTaskBarProgress(playProgress.progress, prevProgressStatus) handleSetTaskBarState(playProgress.progress, prevProgressStatus)
} }
const handleError = () => { const handleError = () => {
if (!restorePlayTime) restorePlayTime = getCurrentTime() // 记录出错的播放时间 if (!restorePlayTime) restorePlayTime = getCurrentTime() // 记录出错的播放时间
prevProgressStatus = 'error' prevProgressStatus = 'error'
setTaskBarProgress(playProgress.progress, prevProgressStatus) handleSetTaskBarState(playProgress.progress, prevProgressStatus)
} }
const handleLoadeddata = () => { const handleLoadeddata = () => {
@ -135,7 +139,7 @@ export default ({ setting, playNext }) => {
watch(() => playProgress.progress, (newValue, oldValue) => { watch(() => playProgress.progress, (newValue, oldValue) => {
if (newValue.toFixed(2) === oldValue.toFixed(2)) return if (newValue.toFixed(2) === oldValue.toFixed(2)) return
setTaskBarProgress(newValue, prevProgressStatus) handleSetTaskBarState(newValue, prevProgressStatus)
}) })
watch(() => playProgress.nowPlayTime, (newValue, oldValue) => { watch(() => playProgress.nowPlayTime, (newValue, oldValue) => {
if (Math.abs(newValue - oldValue) > 2) window.eventHub.emit(eventPlayerNames.activeTransition) if (Math.abs(newValue - oldValue) > 2) window.eventHub.emit(eventPlayerNames.activeTransition)

View File

@ -137,7 +137,7 @@ export const onGetDesktopLyricInfo = callback => {
export const setTaskBarProgress = (status, mode) => { export const setTaskBarProgress = (status, mode) => {
rendererSend(NAMES.mainWindow.progress, { rendererSend(NAMES.mainWindow.progress, {
status: status < 0.01 ? 0.01 : status, status: status < 0 ? status : Math.max(0.01, status),
mode: mode || 'normal', mode: mode || 'normal',
}) })
} }

View File

@ -47,10 +47,7 @@ export default {
watch(() => currentStting.value.player.isShowTaskProgess, val => { watch(() => currentStting.value.player.isShowTaskProgess, val => {
if (val) return if (val) return
nextTick(() => { nextTick(() => {
setTaskBarProgress({ setTaskBarProgress(-1, 'normal')
status: -1,
mode: 'normal',
})
}) })
}) })