修改对播放模块的调用

This commit is contained in:
lyswhut 2021-12-17 16:50:17 +08:00
parent 24bfe135e7
commit a9a5a4c2e0
2 changed files with 8 additions and 3 deletions

View File

@ -1,3 +1,7 @@
### 优化
- 修改对播放模块的调用,杜绝应用显示正在播放的歌曲与实际播放歌曲不一致的问题(这是播放模块歌曲队列与应用内歌曲队列在某些情况下出现不一致时导致的)
### 修复
- 修复kw源某些歌曲的歌词提取异常的问题

View File

@ -85,7 +85,8 @@ export const playMusic = async(tracks, time) => {
// await updateMusicInfo(track)
const currentTrackIndex = await TrackPlayer.getCurrentTrack()
await TrackPlayer.add(tracks).then(() => list.push(...tracks))
await TrackPlayer.skip(list.indexOf(track))
const queue = await TrackPlayer.getQueue()
await TrackPlayer.skip(queue.findIndex(t => t.id == track.id))
if (currentTrackIndex == null) {
if (!isTempTrack(track.id)) {
@ -105,8 +106,8 @@ export const playMusic = async(tracks, time) => {
}
}
if (list.length > 2) {
TrackPlayer.remove(Array(list.length - 2).fill(null).map((_, i) => i)).then(() => list.splice(0, list.length - 2))
if (queue.length > 2) {
TrackPlayer.remove(Array(queue.length - 2).fill(null).map((_, i) => i)).then(() => list.splice(0, list.length - 2))
}
}