修复调整当前播放歌曲的位置时会导致切歌的问题
parent
5aad81c696
commit
96c3034a07
|
@ -3,10 +3,16 @@ import { onBeforeUnmount } from '@renderer/utils/vueTools'
|
||||||
import { player as eventPlayerNames, list as eventListNames } from '@renderer/event/names'
|
import { player as eventPlayerNames, list as eventListNames } from '@renderer/event/names'
|
||||||
import { playInfo, playMusicInfo, updatePlayIndex } from '@renderer/core/share/player'
|
import { playInfo, playMusicInfo, updatePlayIndex } from '@renderer/core/share/player'
|
||||||
import { getList } from '@renderer/core/share/utils'
|
import { getList } from '@renderer/core/share/utils'
|
||||||
|
import { throttle } from '@renderer/utils'
|
||||||
|
|
||||||
|
const changedListIds = new Set()
|
||||||
|
|
||||||
export default ({ playNext }) => {
|
export default ({ playNext }) => {
|
||||||
const handleListChange = listIds => {
|
const throttleListChange = throttle(() => {
|
||||||
if (!listIds.includes(playInfo.playListId) && !listIds.includes(playMusicInfo.listId)) return
|
const isSkip = !changedListIds.has(playInfo.playListId) && !changedListIds.has(playMusicInfo.listId)
|
||||||
|
changedListIds.clear()
|
||||||
|
if (isSkip) return
|
||||||
|
|
||||||
const { playIndex } = updatePlayIndex()
|
const { playIndex } = updatePlayIndex()
|
||||||
if (playIndex < 0 && !playMusicInfo.isTempPlay) { // 歌曲被移除
|
if (playIndex < 0 && !playMusicInfo.isTempPlay) { // 歌曲被移除
|
||||||
if (getList(playMusicInfo.listId).length) {
|
if (getList(playMusicInfo.listId).length) {
|
||||||
|
@ -15,6 +21,13 @@ export default ({ playNext }) => {
|
||||||
window.eventHub.emit(eventPlayerNames.setStop)
|
window.eventHub.emit(eventPlayerNames.setStop)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const handleListChange = listIds => {
|
||||||
|
for (const id of listIds) {
|
||||||
|
changedListIds.add(id)
|
||||||
|
}
|
||||||
|
throttleListChange()
|
||||||
}
|
}
|
||||||
|
|
||||||
window.eventHub.on(eventListNames.listChange, handleListChange)
|
window.eventHub.on(eventListNames.listChange, handleListChange)
|
||||||
|
|
|
@ -402,8 +402,8 @@ export const getPlayList = () => rendererInvoke(NAMES.mainWindow.get_playlist).c
|
||||||
let filePath = path.join(dataPath, 'playList.json.bak')
|
let filePath = path.join(dataPath, 'playList.json.bak')
|
||||||
rendererInvoke(NAMES.mainWindow.show_dialog, {
|
rendererInvoke(NAMES.mainWindow.show_dialog, {
|
||||||
type: 'error',
|
type: 'error',
|
||||||
message: window.i18n.t('store.state.load_list_file_error_title'),
|
message: window.i18n.t('load_list_file_error_title'),
|
||||||
detail: window.i18n.t('store.state.load_list_file_error_detail', {
|
detail: window.i18n.t('load_list_file_error_detail', {
|
||||||
path: filePath,
|
path: filePath,
|
||||||
detail: error.message,
|
detail: error.message,
|
||||||
}),
|
}),
|
||||||
|
|
Loading…
Reference in New Issue