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