Skip to content

Commit df20e97

Browse files
committed
添加媒体播放进度条的信息设置
1 parent fd764a2 commit df20e97

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

publish/changeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- 优化我的列表、下载列表等列表的滚动流畅度
44
- 优化下载功能的批量添加、删除、暂停任务时的流畅度,现在进行这些操作应该不会再觉得卡顿了
55
- 支持启动软件时恢复播放下载列表里的歌曲
6+
- 添加媒体播放进度条的信息设置
67

78
### 修复
89

src/renderer/components/core/Player.vue

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,8 @@ export default {
417417
if (!this.targetSong.interval && this.listId != 'download') {
418418
this.updateMusicInfo({ listId: this.listId, id: this.targetSong.songmid, musicInfo: this.targetSong, data: { interval: formatPlayTime2(this.maxPlayTime) } })
419419
}
420+
421+
this.updatePositionState()
420422
})
421423
audio.addEventListener('loadstart', () => {
422424
console.log('loadstart')
@@ -431,6 +433,7 @@ export default {
431433
audio.currentTime = playTime
432434
}
433435
this.clearBufferTimeout()
436+
this.updatePositionState()
434437
435438
// if (this.musicInfo.lrc) window.lrc.play(audio.currentTime * 1000)
436439
this.status = this.statusText = ''
@@ -484,7 +487,6 @@ export default {
484487
},
485488
async play() {
486489
this.clearDelayNextTimeout()
487-
this.updateMediaSessionInfo()
488490
489491
let targetSong = this.targetSong
490492
@@ -514,6 +516,8 @@ export default {
514516
this.musicInfo.album = targetSong.albumName
515517
this.setUrl(targetSong)
516518
}
519+
520+
this.updateMediaSessionInfo()
517521
this.setImg(targetSong)
518522
this.setLrc(targetSong)
519523
this.handleUpdateWinLyricInfo('music_info', {
@@ -972,6 +976,13 @@ export default {
972976
if (this.currentMusicInfo.img) mediaMetadata.artwork = [{ src: this.currentMusicInfo.img }]
973977
navigator.mediaSession.metadata = new window.MediaMetadata(mediaMetadata)
974978
},
979+
updatePositionState() {
980+
navigator.mediaSession.setPositionState({
981+
duration: audio.duration,
982+
playbackRate: audio.playbackRate,
983+
position: audio.currentTime,
984+
})
985+
},
975986
registerMediaSessionHandler() {
976987
// navigator.mediaSession.setActionHandler('play', () => {
977988
// if (this.isPlay || !this.playMusicInfo) return

0 commit comments

Comments
 (0)