From 0d610c45a7a502de9041ef9f531a4c34b130506c Mon Sep 17 00:00:00 2001 From: qier222 Date: Wed, 2 Jun 2021 17:51:53 +0800 Subject: [PATCH] fix: #729 #678 --- src/utils/Player.js | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/utils/Player.js b/src/utils/Player.js index 74b7242..6109023 100644 --- a/src/utils/Player.js +++ b/src/utils/Player.js @@ -147,19 +147,12 @@ export default class { // 恢复当前播放歌曲 this._replaceCurrentTrack(this._currentTrack.id, false).then(() => { this._howler?.seek(localStorage.getItem('playerCurrentTrackTime') ?? 0); - setInterval( - () => - localStorage.setItem( - 'playerCurrentTrackTime', - this._howler?.seek() - ), - 1000 - ); }); // update audio source and init howler this._initMediaSession(); - this._setIntervals(); } + this._setIntervals(); + // 初始化私人FM if (this._personalFMTrack.id === 0 || this._personalFMNextTrack.id === 0) { personalFM().then(result => { @@ -173,7 +166,9 @@ export default class { // 同步播放进度 // TODO: 如果 _progress 在别的地方被改变了,这个定时器会覆盖之前改变的值,是bug setInterval(() => { - this._progress = this._howler === null ? 0 : this._howler.seek(); + if (this._howler === null) return; + this._progress = this._howler.seek(); + localStorage.setItem('playerCurrentTrackTime', this._progress); }, 1000); } _getNextTrack() {