From df20e97d60b117ede7909f72c8afed7123aecfb5 Mon Sep 17 00:00:00 2001 From: lyswhut Date: Tue, 9 Nov 2021 09:17:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AA=92=E4=BD=93=E6=92=AD?= =?UTF-8?q?=E6=94=BE=E8=BF=9B=E5=BA=A6=E6=9D=A1=E7=9A=84=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE?= 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 | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/publish/changeLog.md b/publish/changeLog.md index 1d24dce9..04ccd3b0 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -3,6 +3,7 @@ - 优化我的列表、下载列表等列表的滚动流畅度 - 优化下载功能的批量添加、删除、暂停任务时的流畅度,现在进行这些操作应该不会再觉得卡顿了 - 支持启动软件时恢复播放下载列表里的歌曲 +- 添加媒体播放进度条的信息设置 ### 修复 diff --git a/src/renderer/components/core/Player.vue b/src/renderer/components/core/Player.vue index 611e6c14..5ee46b86 100644 --- a/src/renderer/components/core/Player.vue +++ b/src/renderer/components/core/Player.vue @@ -417,6 +417,8 @@ export default { if (!this.targetSong.interval && this.listId != 'download') { this.updateMusicInfo({ listId: this.listId, id: this.targetSong.songmid, musicInfo: this.targetSong, data: { interval: formatPlayTime2(this.maxPlayTime) } }) } + + this.updatePositionState() }) audio.addEventListener('loadstart', () => { console.log('loadstart') @@ -431,6 +433,7 @@ export default { audio.currentTime = playTime } this.clearBufferTimeout() + this.updatePositionState() // if (this.musicInfo.lrc) window.lrc.play(audio.currentTime * 1000) this.status = this.statusText = '' @@ -484,7 +487,6 @@ export default { }, async play() { this.clearDelayNextTimeout() - this.updateMediaSessionInfo() let targetSong = this.targetSong @@ -514,6 +516,8 @@ export default { this.musicInfo.album = targetSong.albumName this.setUrl(targetSong) } + + this.updateMediaSessionInfo() this.setImg(targetSong) this.setLrc(targetSong) this.handleUpdateWinLyricInfo('music_info', { @@ -972,6 +976,13 @@ export default { if (this.currentMusicInfo.img) mediaMetadata.artwork = [{ src: this.currentMusicInfo.img }] navigator.mediaSession.metadata = new window.MediaMetadata(mediaMetadata) }, + updatePositionState() { + navigator.mediaSession.setPositionState({ + duration: audio.duration, + playbackRate: audio.playbackRate, + position: audio.currentTime, + }) + }, registerMediaSessionHandler() { // navigator.mediaSession.setActionHandler('play', () => { // if (this.isPlay || !this.playMusicInfo) return