mirror of
https://github.com/ikun0014/lx-music-mobile.git
synced 2025-07-05 21:58:56 +08:00
修复删除列表中正在播放的歌曲时会自动跳到第一首的问题
This commit is contained in:
parent
e61a2d2744
commit
bb9d260dfa
@ -5,3 +5,4 @@
|
|||||||
### 修复
|
### 修复
|
||||||
|
|
||||||
- 修复某些情况下出现恢复播放信息失败的问题
|
- 修复某些情况下出现恢复播放信息失败的问题
|
||||||
|
- 修复删除列表中正在播放的歌曲时会自动跳到第一首的问题
|
||||||
|
@ -18,6 +18,7 @@ global.isScreenKeepAwake = false
|
|||||||
// 是否播放完后退出应用
|
// 是否播放完后退出应用
|
||||||
global.isPlayedExit = false
|
global.isPlayedExit = false
|
||||||
|
|
||||||
|
global.prevPlayIndex = -1
|
||||||
|
|
||||||
global.syncKeyInfo = {}
|
global.syncKeyInfo = {}
|
||||||
global.isSyncEnableing = false
|
global.isSyncEnableing = false
|
||||||
|
@ -583,9 +583,9 @@ export const playPrev = () => async(dispatch, getState) => {
|
|||||||
if (player.playedList.length) {
|
if (player.playedList.length) {
|
||||||
// 从已播放列表移除播放列表已删除的歌曲
|
// 从已播放列表移除播放列表已删除的歌曲
|
||||||
let index
|
let index
|
||||||
for (index = player.playedList.indexOf(player.playMusicInfo) - 1; index > -1; index--) {
|
for (index = player.playedList.findIndex(m => m.songmid === player.playMusicInfo.musicInfo.songmid) - 1; index > -1; index--) {
|
||||||
const playMusicInfo = player.playedList[index]
|
const playMusicInfo = player.playedList[index]
|
||||||
if (playMusicInfo.listId == currentListId && !currentList.includes(playMusicInfo.musicInfo)) {
|
if (playMusicInfo.listId == currentListId && !currentList.some(m => m.songmid === playMusicInfo.musicInfo.songmid)) {
|
||||||
dispatch({ type: TYPES.removeMusicFormPlayedList, payload: index })
|
dispatch({ type: TYPES.removeMusicFormPlayedList, payload: index })
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -607,7 +607,19 @@ export const playPrev = () => async(dispatch, getState) => {
|
|||||||
|
|
||||||
if (!filteredList.length) return dispatch(playMusic(null))
|
if (!filteredList.length) return dispatch(playMusic(null))
|
||||||
const playInfo = playInfoGetter(getState())
|
const playInfo = playInfoGetter(getState())
|
||||||
let currentIndex = filteredList.indexOf(currentList[playInfo.listPlayIndex])
|
let currentMusic
|
||||||
|
if (playInfo.listPlayIndex < 0) {
|
||||||
|
let index = global.prevPlayIndex
|
||||||
|
if (index > currentList.length - 1) index = 0
|
||||||
|
while (index > -1) {
|
||||||
|
currentMusic = currentList[index]
|
||||||
|
if (currentMusic) break
|
||||||
|
index--
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
currentMusic = currentList[playInfo.listPlayIndex]
|
||||||
|
}
|
||||||
|
let currentIndex = filteredList.findIndex(m => m.songmid == currentMusic.songmid)
|
||||||
if (currentIndex == -1) currentIndex = 0
|
if (currentIndex == -1) currentIndex = 0
|
||||||
let nextIndex = currentIndex
|
let nextIndex = currentIndex
|
||||||
if (!playInfo.isTempPlay) {
|
if (!playInfo.isTempPlay) {
|
||||||
@ -647,9 +659,9 @@ export const playNext = () => async(dispatch, getState) => {
|
|||||||
if (player.playedList.length) {
|
if (player.playedList.length) {
|
||||||
// 从已播放列表移除播放列表已删除的歌曲
|
// 从已播放列表移除播放列表已删除的歌曲
|
||||||
let index
|
let index
|
||||||
for (index = player.playedList.indexOf(player.playMusicInfo) + 1; index < player.playedList.length; index++) {
|
for (index = player.playedList.findIndex(m => m.songmid === player.playMusicInfo.musicInfo.songmid) + 1; index < player.playedList.length; index++) {
|
||||||
const playMusicInfo = player.playedList[index]
|
const playMusicInfo = player.playedList[index]
|
||||||
if (playMusicInfo.listId == currentListId && !currentList.includes(playMusicInfo.musicInfo)) {
|
if (playMusicInfo.listId == currentListId && !currentList.some(m => m.songmid === playMusicInfo.musicInfo.songmid)) {
|
||||||
dispatch({ type: TYPES.removeMusicFormPlayedList, payload: index })
|
dispatch({ type: TYPES.removeMusicFormPlayedList, payload: index })
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -672,7 +684,19 @@ export const playNext = () => async(dispatch, getState) => {
|
|||||||
// console.log(filteredList)
|
// console.log(filteredList)
|
||||||
if (!filteredList.length) return dispatch(playMusic(null))
|
if (!filteredList.length) return dispatch(playMusic(null))
|
||||||
const playInfo = playInfoGetter(getState())
|
const playInfo = playInfoGetter(getState())
|
||||||
const currentIndex = filteredList.indexOf(currentList[playInfo.listPlayIndex])
|
let currentMusic
|
||||||
|
if (playInfo.listPlayIndex < 0) {
|
||||||
|
let index = global.prevPlayIndex - 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)
|
||||||
let nextIndex = currentIndex
|
let nextIndex = currentIndex
|
||||||
switch (common.setting.player.togglePlayMethod) {
|
switch (common.setting.player.togglePlayMethod) {
|
||||||
case 'listLoop':
|
case 'listLoop':
|
||||||
@ -776,12 +800,13 @@ export const checkPlayList = listIds => async(dispatch, getState) => {
|
|||||||
|
|
||||||
const list = listInfo.list
|
const list = listInfo.list
|
||||||
|
|
||||||
if (player.playMusicInfo.listId == LIST_ID_PLAY_LATER) {
|
if (isChnagedList) dispatch(setListInfo(listInfo))
|
||||||
if (player.playIndex > listInfo.list.length) {
|
if (player.playMusicInfo.isTempPlay) return
|
||||||
dispatch(setPlayIndex(listInfo.list.length))
|
if (player.playMusicInfo.listId != LIST_ID_PLAY_LATER) {
|
||||||
}
|
// if (player.playIndex > listInfo.list.length) {
|
||||||
if (isChnagedList) dispatch(setListInfo(listInfo))
|
// dispatch(setPlayIndex(listInfo.list.length))
|
||||||
} else {
|
// }
|
||||||
|
// } else {
|
||||||
let songmid = _playMusicInfo.songmid
|
let songmid = _playMusicInfo.songmid
|
||||||
let index = list.findIndex(m => m.songmid == songmid)
|
let index = list.findIndex(m => m.songmid == songmid)
|
||||||
// console.log(index)
|
// console.log(index)
|
||||||
@ -789,15 +814,15 @@ export const checkPlayList = listIds => async(dispatch, getState) => {
|
|||||||
// console.log(this.playIndex)
|
// console.log(this.playIndex)
|
||||||
if (list.length) {
|
if (list.length) {
|
||||||
dispatch(setPlayIndex(Math.min(player.playIndex - 1, list.length - 1)))
|
dispatch(setPlayIndex(Math.min(player.playIndex - 1, list.length - 1)))
|
||||||
if (isChnagedList) dispatch(setListInfo(listInfo))
|
// if (isChnagedList) dispatch(setListInfo(listInfo))
|
||||||
await dispatch(playNext())
|
await dispatch(playNext())
|
||||||
} else {
|
} else {
|
||||||
if (isChnagedList) dispatch(setListInfo(listInfo))
|
// if (isChnagedList) dispatch(setListInfo(listInfo))
|
||||||
await dispatch(stopMusic())
|
await dispatch(stopMusic())
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// console.log(isChnagedList)
|
// console.log(isChnagedList)
|
||||||
if (isChnagedList) dispatch(setListInfo(listInfo))
|
// if (isChnagedList) dispatch(setListInfo(listInfo))
|
||||||
dispatch(setPlayIndex(index))
|
dispatch(setPlayIndex(index))
|
||||||
}
|
}
|
||||||
// console.log(this.playIndex)
|
// console.log(this.playIndex)
|
||||||
|
@ -50,6 +50,7 @@ export const playInfo = createSelector([playMusicInfo, listInfo, playIndex], (pl
|
|||||||
if (list) newPlayIndex = list.list.findIndex(m => m.songmid == songmid)
|
if (list) newPlayIndex = list.list.findIndex(m => m.songmid == songmid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (listPlayIndex > -1) global.prevPlayIndex = listPlayIndex
|
||||||
|
|
||||||
return {
|
return {
|
||||||
listId,
|
listId,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user