@@ -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