修复禁用切歌时歌曲播放完毕后的歌曲信息显示问题

pull/1123/head
lyswhut 2023-01-06 14:39:08 +08:00
parent 399208429d
commit 1db54195f5
5 changed files with 43 additions and 24 deletions

View File

@ -5,6 +5,7 @@
- 修复Linux arm64系统下无法启动的问题#1102
- 修复桌面歌词使用斜体出现截断的问题(#1106
- 修复某些情况下歌词的滚动问题
- 修复禁用切歌时歌曲播放完毕后的歌曲信息显示问题
### 优化

View File

@ -142,9 +142,11 @@ export default {
})
onMounted(() => {
window.app_event.on('musicToggled', updateMusicInfo)
window.app_event.on('lyricUpdated', updateMusicInfo)
})
onBeforeUnmount(() => {
window.app_event.off('musicToggled', updateMusicInfo)
window.app_event.off('lyricUpdated', updateMusicInfo)
})

View File

@ -126,12 +126,11 @@ const handleRestorePlay = async(restorePlayInfo: LX.Player.SavedPlayInfo) => {
rlrc: lyricInfo.rlyric,
rawlrc: lyricInfo.rawlrcInfo.lyric,
})
window.app_event.lyricUpdated()
}).catch((err) => {
console.log(err)
if (musicInfo.id != playMusicInfo.musicInfo?.id) return
setAllStatus(window.i18n.t('lyric__load_error'))
}).finally(() => {
window.app_event.lyricUpdated()
})
if (appSetting['player.togglePlayMethod'] == 'random') addPlayedList({ ...playMusicInfo as LX.Player.PlayMusicInfo })
@ -161,7 +160,7 @@ const handlePlay = () => {
if (appSetting['player.togglePlayMethod'] == 'random' && !playMusicInfo.isTempPlay) addPlayedList({ ...(playMusicInfo as LX.Player.PlayMusicInfo) })
void setMusicUrl(musicInfo)
setMusicUrl(musicInfo)
void getPicPath({ musicInfo, listId: playMusicInfo.isTempPlay ? null : playMusicInfo.listId }).then((url: string) => {
if (musicInfo.id != playMusicInfo.musicInfo?.id) return
@ -178,12 +177,11 @@ const handlePlay = () => {
rlrc: lyricInfo.rlyric,
rawlrc: lyricInfo.rawlrcInfo.lyric,
})
window.app_event.lyricUpdated()
}).catch((err) => {
console.log(err)
if (musicInfo.id != playMusicInfo.musicInfo?.id) return
setAllStatus(window.i18n.t('lyric__load_error'))
}).finally(() => {
window.app_event.lyricUpdated()
})
}
@ -221,11 +219,17 @@ export const playNext = async(isAutoToggle = false): Promise<void> => {
return
}
if (playMusicInfo.musicInfo == null) return handleToggleStop()
if (playMusicInfo.musicInfo == null) {
handleToggleStop()
return
}
// console.log(playInfo.playerListId)
const currentListId = playInfo.playerListId
if (!currentListId) return handleToggleStop()
if (!currentListId) {
handleToggleStop()
return
}
const currentList = getList(currentListId)
if (playedList.length) { // 移除已播放列表内不存在原列表的歌曲
@ -263,7 +267,10 @@ export const playNext = async(isAutoToggle = false): Promise<void> => {
playerMusicInfo: currentList[playInfo.playerPlayIndex],
})
if (!filteredList.length) return handleToggleStop()
if (!filteredList.length) {
handleToggleStop()
return
}
// let currentIndex: number = filteredList.indexOf(currentList[playInfo.playerPlayIndex])
if (playerIndex == -1 && filteredList.length) playerIndex = 0
let nextIndex = playerIndex
@ -309,10 +316,16 @@ export const playNext = async(isAutoToggle = false): Promise<void> => {
*
*/
export const playPrev = async(isAutoToggle = false): Promise<void> => {
if (playMusicInfo.musicInfo == null) return handleToggleStop()
if (playMusicInfo.musicInfo == null) {
handleToggleStop()
return
}
const currentListId = playInfo.playerListId
if (!currentListId) return handleToggleStop()
if (!currentListId) {
handleToggleStop()
return
}
const currentList = getList(currentListId)
if (playedList.length) {
@ -350,7 +363,10 @@ export const playPrev = async(isAutoToggle = false): Promise<void> => {
playedList,
playerMusicInfo: currentList[playInfo.playerPlayIndex],
})
if (!filteredList.length) return handleToggleStop()
if (!filteredList.length) {
handleToggleStop()
return
}
// let currentIndex = filteredList.indexOf(currentList[playInfo.playerPlayIndex])
if (playerIndex == -1 && filteredList.length) playerIndex = 0
@ -398,7 +414,7 @@ export const playPrev = async(isAutoToggle = false): Promise<void> => {
export const play = () => {
if (playMusicInfo.musicInfo == null) return
if (isEmpty()) {
void setMusicUrl(playMusicInfo.musicInfo)
setMusicUrl(playMusicInfo.musicInfo)
return
}
setPlay()

View File

@ -61,7 +61,7 @@ export default () => {
const setProgress = (time: number, maxTime?: number) => {
if (!musicInfo.id) return
console.log('setProgress', time, maxTime)
restorePlayTime = time
if (time > 0) restorePlayTime = time
if (mediaBuffer.playTime) {
clearBufferTimeout()
mediaBuffer.playTime = time
@ -106,12 +106,6 @@ export default () => {
const handleLoadeddata = () => {
setMaxplayTime(getDuration())
console.log('handleLoadeddata', restorePlayTime)
if (restorePlayTime) {
setCurrentTime(restorePlayTime)
restorePlayTime = 0
}
if (playMusicInfo.musicInfo && 'source' in playMusicInfo.musicInfo && !playMusicInfo.musicInfo.interval) {
console.log(formatPlayTime2(playProgress.maxPlayTime))
@ -128,12 +122,15 @@ export default () => {
}
const handleCanplay = () => {
console.log('handleCanplay', mediaBuffer.playTime)
console.log('handleCanplay', mediaBuffer.playTime, restorePlayTime)
clearBufferTimeout()
if (mediaBuffer.playTime) {
let playTime = mediaBuffer.playTime
mediaBuffer.playTime = 0
setCurrentTime(playTime)
} else if (restorePlayTime) {
setCurrentTime(restorePlayTime)
restorePlayTime = 0
}
}
const handleWating = () => {

View File

@ -20,7 +20,7 @@ import {
setAllStatus,
addPlayedList,
clearPlayedList,
resetPlayerMusicInfo,
// resetPlayerMusicInfo,
} from '@renderer/store/player/action'
import { appSetting } from '@renderer/store/setting'
@ -68,9 +68,12 @@ export default () => {
}
const handleEnded = () => {
// setTimeout(() => {
if (window.lx.isPlayedStop) return setAllStatus(t('player__end'))
resetPlayerMusicInfo()
window.app_event.stop()
if (window.lx.isPlayedStop) {
setAllStatus(t('player__end'))
return
}
// resetPlayerMusicInfo()
// window.app_event.stop()
setAllStatus(t('player__end'))
void playNext(true)
// })