Skip to content

Commit

Permalink
修复快速切换歌曲时, 会出现播放的歌曲和界面展示的歌曲不一致的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
lyswhut committed Jan 23, 2021
1 parent c4ae0dd commit f2fb37d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
4 changes: 4 additions & 0 deletions publish/changeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

- 优化播放歌曲换源匹配

### 修复

- 修复快速切换歌曲时, 会出现播放的歌曲和界面展示的歌曲不一致的问题

### 其他

- 更新electron到9.4.1
5 changes: 3 additions & 2 deletions src/renderer/components/core/Player.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions src/renderer/store/modules/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f2fb37d

Please sign in to comment.