From 6779fd7ae5df05fc4285350dcbf5d01567ac6b87 Mon Sep 17 00:00:00 2001 From: lyswhut Date: Tue, 15 Mar 2022 10:23:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=AD=8C=E8=AF=8D=E5=81=8F?= =?UTF-8?q?=E7=A7=BB=E6=97=B6=E9=97=B4=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../utils/lyric-font-player/line-player.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/renderer/utils/lyric-font-player/line-player.js b/src/renderer/utils/lyric-font-player/line-player.js index 1da2dbc9..94e1ace7 100644 --- a/src/renderer/utils/lyric-font-player/line-player.js +++ b/src/renderer/utils/lyric-font-player/line-player.js @@ -24,10 +24,8 @@ module.exports = class LinePlayer { this.curLineNum = 0 this.maxLine = 0 this.offset = offset - this.isOffseted = false this._performanceTime = 0 this._startTime = 0 - this._offset = 0 this._init() } @@ -105,6 +103,7 @@ module.exports = class LinePlayer { } _findCurLineNum(curTime, startIndex = 0) { + if (curTime <= 0) return 0 const length = this.lines.length for (let index = startIndex; index < length; index++) if (curTime <= this.lines[index].time) return index === 0 ? 0 : index - 1 return length - 1 @@ -130,11 +129,6 @@ module.exports = class LinePlayer { this.delay = nextLine.time - curLine.time - driftTime if (this.delay > 0) { - if (!this.isOffseted && this.delay >= this._offset) { - this._startTime += this._offset - this.delay -= this._offset - this.isOffseted = true - } if (this.isPlay) { timeoutTools.start(() => { if (!this.isPlay) return @@ -160,11 +154,10 @@ module.exports = class LinePlayer { this.pause() this.isPlay = true - this._performanceTime = getNow() + this._performanceTime = getNow() - parseInt(this.tags.offset + this.offset) this._startTime = curTime - this._offset = this.tags.offset + this.offset - this.curLineNum = this._findCurLineNum(curTime) - 1 + this.curLineNum = this._findCurLineNum(this._currentTime()) - 1 this._refresh() } @@ -172,7 +165,6 @@ module.exports = class LinePlayer { pause() { if (!this.isPlay) return this.isPlay = false - this.isOffseted = false timeoutTools.clear() if (this.curLineNum === this.maxLine) return const currentTime = this._currentTime()