diff --git a/publish/changeLog.md b/publish/changeLog.md index 5d80a4af..0e10af2c 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -7,6 +7,10 @@ - 优化播放歌曲换源匹配 +### 修复 + +- 修复快速切换歌曲时, 会出现播放的歌曲和界面展示的歌曲不一致的问题 + ### 其他 - 更新electron到9.4.1 diff --git a/src/renderer/components/core/Player.vue b/src/renderer/components/core/Player.vue index 64459c61..88c3d6c9 100644 --- a/src/renderer/components/core/Player.vue +++ b/src/renderer/components/core/Player.vue @@ -581,8 +581,9 @@ export default { this.musicInfo.url = targetSong.typeUrl[type] this.status = this.statusText = this.$t('core.player.geting_url') - return this.getUrl({ musicInfo: targetSong, originMusic, type, isRefresh }).then(() => { - audio.src = this.musicInfo.url = targetSong.typeUrl[type] + return this.getUrl({ musicInfo: targetSong, originMusic, type, isRefresh }).then(url => { + if ((targetSong !== this.targetSong && originMusic !== this.targetSong) || this.isPlay) return + audio.src = this.musicInfo.url = url }).catch(err => { // console.log('err', err.message) if (err.message == requestMsg.cancelRequest) return diff --git a/src/renderer/store/modules/player.js b/src/renderer/store/modules/player.js index 86ea430f..9d23766d 100644 --- a/src/renderer/store/modules/player.js +++ b/src/renderer/store/modules/player.js @@ -119,12 +119,13 @@ const actions = { // return Promise.reject(new Error('该歌曲没有可播放的音频')) } if (urlRequest && urlRequest.cancelHttp) urlRequest.cancelHttp() - if (musicInfo.typeUrl[type] && !isRefresh) return Promise.resolve() + if (musicInfo.typeUrl[type] && !isRefresh) return Promise.resolve(musicInfo.typeUrl[type]) urlRequest = music[musicInfo.source].getMusicUrl(musicInfo, type) - return urlRequest.promise.then(result => { - if (originMusic) commit('setUrl', { musicInfo: originMusic, url: result.url, type }) - commit('setUrl', { musicInfo, url: result.url, type }) + return urlRequest.promise.then(({ url }) => { + if (originMusic) commit('setUrl', { musicInfo: originMusic, url, type }) + commit('setUrl', { musicInfo, url, type }) urlRequest = null + return url }).catch(err => { urlRequest = null return Promise.reject(err)