修复播放下载列表的歌曲时切歌、歌词显示问题
parent
e15178150b
commit
1f85492690
|
@ -1,3 +1,4 @@
|
||||||
### 修复
|
### 修复
|
||||||
|
|
||||||
- 修复随机播放下无法切歌的问题
|
- 修复播放下载列表的歌曲时切歌的问题
|
||||||
|
- 修复播放下载列表的歌曲时歌词无法显示的问题
|
||||||
|
|
|
@ -268,7 +268,7 @@ export default {
|
||||||
'setting.player.togglePlayMethod'(n) {
|
'setting.player.togglePlayMethod'(n) {
|
||||||
audio.loop = n === 'singleLoop'
|
audio.loop = n === 'singleLoop'
|
||||||
if (this.playedList.length) this.clearPlayedList()
|
if (this.playedList.length) this.clearPlayedList()
|
||||||
if (n == 'random') this.setPlayedList(this.playMusicInfo)
|
if (n == 'random' && !this.playMusicInfo.isTempPlay) this.setPlayedList(this.playMusicInfo)
|
||||||
},
|
},
|
||||||
'setting.player.isMute'(n) {
|
'setting.player.isMute'(n) {
|
||||||
audio.muted = n
|
audio.muted = n
|
||||||
|
@ -487,7 +487,7 @@ export default {
|
||||||
|
|
||||||
const targetSong = this.targetSong
|
const targetSong = this.targetSong
|
||||||
|
|
||||||
if (this.setting.player.togglePlayMethod == 'random') this.setPlayedList(this.playMusicInfo)
|
if (this.setting.player.togglePlayMethod == 'random' && !this.playMusicInfo.isTempPlay) this.setPlayedList(this.playMusicInfo)
|
||||||
this.retryNum = 0
|
this.retryNum = 0
|
||||||
this.restorePlayTime = 0
|
this.restorePlayTime = 0
|
||||||
|
|
||||||
|
@ -646,7 +646,7 @@ export default {
|
||||||
|
|
||||||
if (!this.musicInfo.img) {
|
if (!this.musicInfo.img) {
|
||||||
this.getPic(targetSong).then(() => {
|
this.getPic(targetSong).then(() => {
|
||||||
if (targetSong !== this.targetSong) return
|
if (targetSong.songmid !== this.musicInfo.songmid) return
|
||||||
this.musicInfo.img = targetSong.img
|
this.musicInfo.img = targetSong.img
|
||||||
this.updateMediaSessionInfo()
|
this.updateMediaSessionInfo()
|
||||||
})
|
})
|
||||||
|
@ -654,7 +654,7 @@ export default {
|
||||||
},
|
},
|
||||||
setLrc(targetSong) {
|
setLrc(targetSong) {
|
||||||
this.getLrc(targetSong).then(({ lyric, tlyric, lxlyric }) => {
|
this.getLrc(targetSong).then(({ lyric, tlyric, lxlyric }) => {
|
||||||
if (targetSong !== this.targetSong) return
|
if (targetSong.songmid !== this.musicInfo.songmid) return
|
||||||
this.musicInfo.lrc = lyric
|
this.musicInfo.lrc = lyric
|
||||||
this.musicInfo.tlrc = tlyric
|
this.musicInfo.tlrc = tlyric
|
||||||
this.musicInfo.lxlrc = lxlyric
|
this.musicInfo.lxlrc = lxlyric
|
||||||
|
|
|
@ -13,9 +13,10 @@ import {
|
||||||
assertApiSupport,
|
assertApiSupport,
|
||||||
} from '../../utils'
|
} from '../../utils'
|
||||||
|
|
||||||
|
window.downloadList = []
|
||||||
// state
|
// state
|
||||||
const state = {
|
const state = {
|
||||||
list: [],
|
list: window.downloadList,
|
||||||
waitingList: [],
|
waitingList: [],
|
||||||
downloadStatus: {
|
downloadStatus: {
|
||||||
RUN: 'run',
|
RUN: 'run',
|
||||||
|
@ -369,6 +370,7 @@ const actions = {
|
||||||
status: state.downloadStatus.WAITING,
|
status: state.downloadStatus.WAITING,
|
||||||
statusText: '待下载',
|
statusText: '待下载',
|
||||||
url: null,
|
url: null,
|
||||||
|
// songmid: musicInfo.songmid,
|
||||||
fileName: `${rootState.setting.download.fileName
|
fileName: `${rootState.setting.download.fileName
|
||||||
.replace('歌名', musicInfo.name)
|
.replace('歌名', musicInfo.name)
|
||||||
.replace('歌手', musicInfo.singer)}.${ext}`.replace(filterFileName, ''),
|
.replace('歌手', musicInfo.singer)}.${ext}`.replace(filterFileName, ''),
|
||||||
|
@ -667,7 +669,7 @@ const mutations = {
|
||||||
downloadInfo.order = order
|
downloadInfo.order = order
|
||||||
},
|
},
|
||||||
updateDownloadList(state, list) {
|
updateDownloadList(state, list) {
|
||||||
state.list = list
|
state.list = window.downloadList = list
|
||||||
},
|
},
|
||||||
updateUrl(state, { downloadInfo, url }) {
|
updateUrl(state, { downloadInfo, url }) {
|
||||||
downloadInfo.url = url
|
downloadInfo.url = url
|
||||||
|
|
|
@ -40,7 +40,7 @@ const filterList = async({ playedList, listInfo, savePath, commit }) => {
|
||||||
canPlayList.push(item)
|
canPlayList.push(item)
|
||||||
|
|
||||||
// 排除已播放音乐
|
// 排除已播放音乐
|
||||||
let index = filteredPlayedList.indexOf(item)
|
let index = filteredPlayedList.findIndex(m => (m.songmid || m.musicInfo.songmid) == item.musicInfo.songmid)
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
filteredPlayedList.splice(index, 1)
|
filteredPlayedList.splice(index, 1)
|
||||||
continue
|
continue
|
||||||
|
@ -52,7 +52,7 @@ const filterList = async({ playedList, listInfo, savePath, commit }) => {
|
||||||
// if (!assertApiSupport(s.source)) return false
|
// if (!assertApiSupport(s.source)) return false
|
||||||
canPlayList.push(s)
|
canPlayList.push(s)
|
||||||
|
|
||||||
let index = filteredPlayedList.indexOf(s)
|
let index = filteredPlayedList.findIndex(m => (m.songmid || m.musicInfo.songmid) == s.songmid)
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
filteredPlayedList.splice(index, 1)
|
filteredPlayedList.splice(index, 1)
|
||||||
return false
|
return false
|
||||||
|
@ -141,12 +141,12 @@ const getLyric = function(musicInfo, retryedSource = [], originMusic) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
let prevPlayIndex
|
let prevListPlayIndex
|
||||||
// getters
|
// getters
|
||||||
const getters = {
|
const getters = {
|
||||||
list: state => state.listInfo.list,
|
list: state => state.listInfo.list,
|
||||||
changePlay: satte => satte.changePlay,
|
changePlay: satte => satte.changePlay,
|
||||||
playInfo(state) {
|
playInfo(state, getters) {
|
||||||
if (state.playMusicInfo == null) return { listId: null, playIndex: -1, playListId: null, listPlayIndex: -1, isPlayList: false, musicInfo: null }
|
if (state.playMusicInfo == null) return { listId: null, playIndex: -1, playListId: null, listPlayIndex: -1, isPlayList: false, musicInfo: null }
|
||||||
const playListId = state.listInfo.id
|
const playListId = state.listInfo.id
|
||||||
let listId = state.playMusicInfo.listId
|
let listId = state.playMusicInfo.listId
|
||||||
|
@ -156,15 +156,28 @@ const getters = {
|
||||||
let listPlayIndex = state.playIndex
|
let listPlayIndex = state.playIndex
|
||||||
|
|
||||||
if (listId != '__temp__') {
|
if (listId != '__temp__') {
|
||||||
|
const currentSongmid = state.playMusicInfo.musicInfo.songmid || state.playMusicInfo.musicInfo.musicInfo.songmid
|
||||||
if (isPlayList) {
|
if (isPlayList) {
|
||||||
playIndex = state.listInfo.list.findIndex(m => m.songmid == state.playMusicInfo.musicInfo.songmid)
|
playIndex = state.listInfo.list.findIndex(m => (m.songmid || m.musicInfo.songmid) == currentSongmid)
|
||||||
if (!isTempPlay) listPlayIndex = playIndex
|
if (!isTempPlay) listPlayIndex = playIndex
|
||||||
|
} else if (listId == 'download') {
|
||||||
|
playIndex = window.downloadList.findIndex(m => m.musicInfo.songmid == currentSongmid)
|
||||||
} else {
|
} else {
|
||||||
let list = window.allList[listId]
|
let list = window.allList[listId]
|
||||||
if (list) playIndex = list.list.findIndex(m => m.songmid == state.playMusicInfo.musicInfo.songmid)
|
if (list) playIndex = list.list.findIndex(m => m.songmid == currentSongmid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (listPlayIndex > -1) prevPlayIndex = listPlayIndex
|
if (listPlayIndex >= 0) prevListPlayIndex = listPlayIndex
|
||||||
|
// if (listPlayIndex < 0) {
|
||||||
|
// let length = state.listInfo.list.length
|
||||||
|
// if (length) {
|
||||||
|
// let index = Math.min(prevListPlayIndex, 0)
|
||||||
|
// if (index > length - 1) index = length - 1
|
||||||
|
// listPlayIndex = prevListPlayIndex = index
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// prevListPlayIndex = listPlayIndex
|
||||||
|
// }
|
||||||
// console.log({
|
// console.log({
|
||||||
// listId,
|
// listId,
|
||||||
// playIndex,
|
// playIndex,
|
||||||
|
@ -249,12 +262,21 @@ const actions = {
|
||||||
async playPrev({ state, rootState, commit, getters }) {
|
async playPrev({ state, rootState, commit, getters }) {
|
||||||
const currentListId = state.listInfo.id
|
const currentListId = state.listInfo.id
|
||||||
const currentList = state.listInfo.list
|
const currentList = state.listInfo.list
|
||||||
|
const playInfo = getters.playInfo
|
||||||
if (state.playedList.length) {
|
if (state.playedList.length) {
|
||||||
|
let currentSongmid
|
||||||
|
if (state.playMusicInfo.isTempPlay) {
|
||||||
|
const musicInfo = playInfo.list[playInfo.listPlayIndex]
|
||||||
|
if (musicInfo) currentSongmid = musicInfo.songmid || musicInfo.musicInfo.songmid
|
||||||
|
} else {
|
||||||
|
currentSongmid = state.playMusicInfo.musicInfo.songmid || state.playMusicInfo.musicInfo.musicInfo.songmid
|
||||||
|
}
|
||||||
// 从已播放列表移除播放列表已删除的歌曲
|
// 从已播放列表移除播放列表已删除的歌曲
|
||||||
let index
|
let index
|
||||||
for (index = state.playedList.findIndex(m => m.musicInfo.songmid === state.playMusicInfo.musicInfo.songmid) - 1; index > -1; index--) {
|
for (index = state.playedList.findIndex(m => (m.musicInfo.songmid || m.musicInfo.musicInfo.songmid) === currentSongmid) - 1; index > -1; index--) {
|
||||||
const playMusicInfo = state.playedList[index]
|
const playMusicInfo = state.playedList[index]
|
||||||
if (playMusicInfo.listId == currentListId && !currentList.some(m => m.songmid === playMusicInfo.musicInfo.songmid)) {
|
const currentSongmid = playMusicInfo.musicInfo.songmid || playMusicInfo.musicInfo.musicInfo.songmid
|
||||||
|
if (playMusicInfo.listId == currentListId && !currentList.some(m => (m.songmid || m.musicInfo.songmid) === currentSongmid)) {
|
||||||
commit('removePlayedList', index)
|
commit('removePlayedList', index)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -274,21 +296,14 @@ const actions = {
|
||||||
commit,
|
commit,
|
||||||
})
|
})
|
||||||
if (!filteredList.length) return commit('setPlayMusicInfo', null)
|
if (!filteredList.length) return commit('setPlayMusicInfo', null)
|
||||||
const playInfo = getters.playInfo
|
|
||||||
let currentMusic
|
let listPlayIndex = playInfo.listPlayIndex
|
||||||
if (playInfo.listPlayIndex < 0) {
|
const currentListLength = state.listInfo.list.length - 1
|
||||||
let index = prevPlayIndex
|
if (listPlayIndex == -1 && currentListLength) {
|
||||||
if (index > currentList.length - 1) index = 0
|
listPlayIndex = prevListPlayIndex >= currentListLength ? 0 : prevListPlayIndex + 1
|
||||||
while (index > -1) {
|
|
||||||
currentMusic = currentList[index]
|
|
||||||
if (currentMusic) break
|
|
||||||
index--
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
currentMusic = currentList[playInfo.listPlayIndex]
|
|
||||||
}
|
}
|
||||||
let currentIndex = filteredList.findIndex(m => m.songmid == currentMusic.songmid)
|
let currentIndex = listPlayIndex
|
||||||
if (currentIndex == -1) currentIndex = 0
|
if (currentIndex < 0) currentIndex = 0
|
||||||
let nextIndex = currentIndex
|
let nextIndex = currentIndex
|
||||||
if (!playInfo.isTempPlay) {
|
if (!playInfo.isTempPlay) {
|
||||||
switch (rootState.setting.player.togglePlayMethod) {
|
switch (rootState.setting.player.togglePlayMethod) {
|
||||||
|
@ -322,13 +337,22 @@ const actions = {
|
||||||
}
|
}
|
||||||
const currentListId = state.listInfo.id
|
const currentListId = state.listInfo.id
|
||||||
const currentList = state.listInfo.list
|
const currentList = state.listInfo.list
|
||||||
console.log(currentListId)
|
const playInfo = getters.playInfo
|
||||||
|
|
||||||
if (state.playedList.length) {
|
if (state.playedList.length) {
|
||||||
|
let currentSongmid
|
||||||
|
if (state.playMusicInfo.isTempPlay) {
|
||||||
|
const musicInfo = currentList[playInfo.listPlayIndex]
|
||||||
|
if (musicInfo) currentSongmid = musicInfo.songmid || musicInfo.musicInfo.songmid
|
||||||
|
} else {
|
||||||
|
currentSongmid = state.playMusicInfo.musicInfo.songmid || state.playMusicInfo.musicInfo.musicInfo.songmid
|
||||||
|
}
|
||||||
// 从已播放列表移除播放列表已删除的歌曲
|
// 从已播放列表移除播放列表已删除的歌曲
|
||||||
let index
|
let index
|
||||||
for (index = state.playedList.findIndex(m => m.musicInfo.songmid === state.playMusicInfo.musicInfo.songmid) + 1; index < state.playedList.length; index++) {
|
for (index = state.playedList.findIndex(m => (m.musicInfo.songmid || m.musicInfo.musicInfo.songmid) === currentSongmid) + 1; index < state.playedList.length; index++) {
|
||||||
const playMusicInfo = state.playedList[index]
|
const playMusicInfo = state.playedList[index]
|
||||||
if (playMusicInfo.listId == currentListId && !currentList.some(m => m.songmid === playMusicInfo.musicInfo.songmid)) {
|
const currentSongmid = playMusicInfo.musicInfo.songmid || playMusicInfo.musicInfo.musicInfo.songmid
|
||||||
|
if (playMusicInfo.listId == currentListId && !currentList.some(m => (m.songmid || m.musicInfo.songmid) === currentSongmid)) {
|
||||||
commit('removePlayedList', index)
|
commit('removePlayedList', index)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -348,20 +372,12 @@ const actions = {
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!filteredList.length) return commit('setPlayMusicInfo', null)
|
if (!filteredList.length) return commit('setPlayMusicInfo', null)
|
||||||
const playInfo = getters.playInfo
|
let listPlayIndex = playInfo.listPlayIndex
|
||||||
let currentMusic
|
const currentListLength = state.listInfo.list.length - 1
|
||||||
if (playInfo.listPlayIndex < 0) {
|
if (listPlayIndex == -1 && currentListLength) {
|
||||||
let index = prevPlayIndex - 1
|
listPlayIndex = prevListPlayIndex > currentListLength ? currentListLength : prevListPlayIndex - 1
|
||||||
if (index < 0) index = currentList.length - 1
|
|
||||||
while (index > -1) {
|
|
||||||
currentMusic = currentList[index]
|
|
||||||
if (currentMusic) break
|
|
||||||
index--
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
currentMusic = currentList[playInfo.listPlayIndex]
|
|
||||||
}
|
}
|
||||||
let currentIndex = filteredList.findIndex(m => m.songmid == currentMusic.songmid)
|
const currentIndex = listPlayIndex
|
||||||
let nextIndex = currentIndex
|
let nextIndex = currentIndex
|
||||||
|
|
||||||
switch (rootState.setting.player.togglePlayMethod) {
|
switch (rootState.setting.player.togglePlayMethod) {
|
||||||
|
@ -461,7 +477,10 @@ const mutations = {
|
||||||
playIndex = -1
|
playIndex = -1
|
||||||
} else {
|
} else {
|
||||||
let listId = playMusicInfo.listId
|
let listId = playMusicInfo.listId
|
||||||
if (listId != '__temp__' && !playMusicInfo.isTempPlay && listId === state.listInfo.id) playIndex = state.listInfo.list.findIndex(m => m.songmid == playMusicInfo.musicInfo.songmid)
|
if (listId != '__temp__' && !playMusicInfo.isTempPlay && listId === state.listInfo.id) {
|
||||||
|
const currentSongmid = playMusicInfo.musicInfo.songmid || playMusicInfo.musicInfo.musicInfo.songmid
|
||||||
|
playIndex = state.listInfo.list.findIndex(m => (m.songmid || m.musicInfo.songmid) == currentSongmid)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
state.playMusicInfo = playMusicInfo
|
state.playMusicInfo = playMusicInfo
|
||||||
|
|
|
@ -182,7 +182,7 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions('download', ['removeTask', 'removeTasks', 'startTask', 'startTasks', 'pauseTask', 'pauseTasks']),
|
...mapActions('download', ['removeTask', 'removeTasks', 'startTask', 'startTasks', 'pauseTask', 'pauseTasks']),
|
||||||
...mapMutations('player', ['setList']),
|
...mapMutations('player', ['setList', 'setTempPlayList']),
|
||||||
listenEvent() {
|
listenEvent() {
|
||||||
window.eventHub.$on('key_shift_down', this.handle_key_shift_down)
|
window.eventHub.$on('key_shift_down', this.handle_key_shift_down)
|
||||||
window.eventHub.$on('key_shift_up', this.handle_key_shift_up)
|
window.eventHub.$on('key_shift_up', this.handle_key_shift_up)
|
||||||
|
@ -312,14 +312,6 @@ export default {
|
||||||
case 'remove':
|
case 'remove':
|
||||||
this.removeTask(item)
|
this.removeTask(item)
|
||||||
break
|
break
|
||||||
case 'playLater':
|
|
||||||
if (this.selectedData.length) {
|
|
||||||
this.setTempPlayList(this.selectedData.map(s => ({ listId: 'download', musicInfo: s })))
|
|
||||||
this.removeAllSelect()
|
|
||||||
} else {
|
|
||||||
this.setTempPlayList([{ listId: 'download', musicInfo: item }])
|
|
||||||
}
|
|
||||||
break
|
|
||||||
case 'file':
|
case 'file':
|
||||||
this.handleOpenFolder(item.filePath)
|
this.handleOpenFolder(item.filePath)
|
||||||
break
|
break
|
||||||
|
@ -472,6 +464,14 @@ export default {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
case 'playLater':
|
||||||
|
if (this.selectedData.length) {
|
||||||
|
this.setTempPlayList(this.selectedData.map(s => ({ listId: 'download', musicInfo: s })))
|
||||||
|
this.removeAllSelect()
|
||||||
|
} else {
|
||||||
|
this.setTempPlayList([{ listId: 'download', musicInfo: this.showList[index] }])
|
||||||
|
}
|
||||||
|
break
|
||||||
case 'sourceDetail':
|
case 'sourceDetail':
|
||||||
item = this.showList[index].musicInfo
|
item = this.showList[index].musicInfo
|
||||||
url = musicSdk[item.source].getMusicDetailPageUrl(item)
|
url = musicSdk[item.source].getMusicDetailPageUrl(item)
|
||||||
|
|
Loading…
Reference in New Issue