From 3cb0a56647ff8a2c7caacfac223e5f8a5dab436f Mon Sep 17 00:00:00 2001 From: lyswhut Date: Mon, 23 Nov 2020 10:18:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=AD=8C=E6=9B=B2URL?= =?UTF-8?q?=E8=BF=87=E6=9C=9F=E6=97=B6=EF=BC=8C=E7=AD=89=E5=BE=85=E5=88=B7?= =?UTF-8?q?=E6=96=B0URL=E7=9A=84=E8=87=AA=E5=8A=A8=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E6=AD=8C=E6=9B=B2=E6=97=B6=E9=97=B4=E9=97=B4=E9=9A=94=E5=A4=AA?= =?UTF-8?q?=E7=9F=AD=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- publish/changeLog.md | 1 + src/renderer/components/core/Player.vue | 27 ++++++++++++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/publish/changeLog.md b/publish/changeLog.md index d74ebb0a..4086670b 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -2,3 +2,4 @@ ### 修复 - 修复有歌词翻译与无歌词的音乐间切换会导致歌词翻译残留显示的问题 +- 修复歌曲URL过期时,等待刷新URL的自动切换歌曲时间间隔太短的问题 diff --git a/src/renderer/components/core/Player.vue b/src/renderer/components/core/Player.vue index 6ec7aca0..88b5adc8 100644 --- a/src/renderer/components/core/Player.vue +++ b/src/renderer/components/core/Player.vue @@ -373,7 +373,8 @@ export default { this.addDelayNextTimeout() }) audio.addEventListener('loadeddata', () => { - // console.log('loadeddata') + console.log('loadeddata') + this.clearLoadingTimeout() this.status = this.statusText = this.$t('core.player.loading') this.maxPlayTime = audio.duration if (window.restorePlayInfo) { @@ -388,8 +389,8 @@ export default { if (!this.targetSong.interval && this.listId != 'download') this.updateMusicInfo({ id: this.listId, index: this.playIndex, data: { interval: formatPlayTime2(this.maxPlayTime) } }) }) audio.addEventListener('loadstart', () => { - // console.log('loadstart') - this.startBuffering() + console.log('loadstart') + this.startLoadingTimeout() this.status = this.statusText = this.$t('core.player.loading') }) audio.addEventListener('canplay', () => { @@ -399,9 +400,8 @@ export default { this.mediaBuffer.playTime = 0 audio.currentTime = playTime } - if (this.mediaBuffer.timeout) { - this.clearBufferTimeout() - } + this.clearBufferTimeout() + // if (this.musicInfo.lrc) window.lrc.play(audio.currentTime * 1000) this.status = this.statusText = '' }) @@ -412,6 +412,7 @@ export default { // }) audio.addEventListener('emptied', () => { this.mediaBuffer.playTime = 0 + this.clearLoadingTimeout() this.clearBufferTimeout() // console.log('媒介资源元素突然为空,网络错误 or 切换歌曲?') @@ -796,8 +797,20 @@ export default { // console.log(e) this.isActiveTransition = false }, + startLoadingTimeout() { + // console.log('start load timeout') + this.loadingTimeout = setTimeout(() => { + this.handleNext() + }, 10000) + }, + clearLoadingTimeout() { + if (!this.loadingTimeout) return + // console.log('clear load timeout') + clearTimeout(this.loadingTimeout) + this.loadingTimeout = null + }, startBuffering() { - console.log('start t') + console.error('start t') if (this.mediaBuffer.timeout) return this.mediaBuffer.timeout = setTimeout(() => { this.mediaBuffer.timeout = null