修复首句歌词被提前播放的问题
parent
e1646a3127
commit
c2789312ba
|
@ -19,6 +19,7 @@
|
||||||
- 修复搜索框在某些情况下输入内容后搜索时会自动清空的问题(#1472)
|
- 修复搜索框在某些情况下输入内容后搜索时会自动清空的问题(#1472)
|
||||||
- 修复某些tx源歌词因数据异常解析失败的问题
|
- 修复某些tx源歌词因数据异常解析失败的问题
|
||||||
- 修复windows平台下隐藏窗口后再显示时任务栏按钮丢失的问题
|
- 修复windows平台下隐藏窗口后再显示时任务栏按钮丢失的问题
|
||||||
|
- 修复首句歌词被提前播放的问题
|
||||||
|
|
||||||
### 其他
|
### 其他
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ export default class Lyric {
|
||||||
_handleLinePlayerOnPlay = (num, text, curTime) => {
|
_handleLinePlayerOnPlay = (num, text, curTime) => {
|
||||||
if (this.isLineMode) {
|
if (this.isLineMode) {
|
||||||
if (num < this.playingLineNum + 1) {
|
if (num < this.playingLineNum + 1) {
|
||||||
for (let i = this.playingLineNum; i > num - 1; i--) {
|
for (let i = this.playingLineNum, minNum = Math.max(num, 0); i > minNum - 1; i--) {
|
||||||
const font = this._lineFonts[i]
|
const font = this._lineFonts[i]
|
||||||
font.reset()
|
font.reset()
|
||||||
font.lineContent.classList.remove(this.activeLineClassName)
|
font.lineContent.classList.remove(this.activeLineClassName)
|
||||||
|
@ -86,7 +86,7 @@ export default class Lyric {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (num < this.playingLineNum + 1) {
|
if (num < this.playingLineNum + 1) {
|
||||||
for (let i = this.playingLineNum; i > num - 1; i--) {
|
for (let i = this.playingLineNum, minNum = Math.max(num, 0); i > minNum - 1; i--) {
|
||||||
const font = this._lineFonts[i]
|
const font = this._lineFonts[i]
|
||||||
font.lineContent.classList.remove(this.activeLineClassName)
|
font.lineContent.classList.remove(this.activeLineClassName)
|
||||||
font.reset()
|
font.reset()
|
||||||
|
@ -103,10 +103,12 @@ export default class Lyric {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.playingLineNum = num
|
this.playingLineNum = num
|
||||||
|
if (num > -1) {
|
||||||
const font = this._lineFonts[num]
|
const font = this._lineFonts[num]
|
||||||
font.lineContent.classList.add(this.activeLineClassName)
|
font.lineContent.classList.add(this.activeLineClassName)
|
||||||
font.play(curTime - this._lines[num].time)
|
font.play(curTime - this._lines[num].time)
|
||||||
this.onPlay(num, this._lines[num].text)
|
}
|
||||||
|
this.onPlay(num, this._lines[num]?.text ?? '')
|
||||||
}
|
}
|
||||||
|
|
||||||
_initLines = (lyricLines, offset, isUpdate) => {
|
_initLines = (lyricLines, offset, isUpdate) => {
|
||||||
|
|
|
@ -148,7 +148,7 @@ export default class LinePlayer {
|
||||||
const currentTime = this._currentTime()
|
const currentTime = this._currentTime()
|
||||||
const driftTime = currentTime - curLine.time
|
const driftTime = currentTime - curLine.time
|
||||||
|
|
||||||
if (driftTime >= 0 || this.curLineNum === 0) {
|
if (driftTime >= 0) {
|
||||||
let nextLine = this.lines[this.curLineNum + 1]
|
let nextLine = this.lines[this.curLineNum + 1]
|
||||||
const delay = (nextLine.time - curLine.time - driftTime) / this._rate
|
const delay = (nextLine.time - curLine.time - driftTime) / this._rate
|
||||||
|
|
||||||
|
@ -167,6 +167,17 @@ export default class LinePlayer {
|
||||||
this._refresh()
|
this._refresh()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
} else if (this.curLineNum == 0) {
|
||||||
|
let firstLine = this.lines[0]
|
||||||
|
const delay = (firstLine.time - currentTime) / this._rate
|
||||||
|
if (this.isPlay) {
|
||||||
|
timeoutTools.start(() => {
|
||||||
|
if (!this.isPlay) return
|
||||||
|
this._refresh()
|
||||||
|
}, delay)
|
||||||
|
}
|
||||||
|
this.onPlay(-1, '', currentTime)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.curLineNum = this._findCurLineNum(currentTime, this.curLineNum) - 1
|
this.curLineNum = this._findCurLineNum(currentTime, this.curLineNum) - 1
|
||||||
|
|
|
@ -12,7 +12,7 @@ export const init = () => {
|
||||||
rate: setting['player.playbackRate'],
|
rate: setting['player.playbackRate'],
|
||||||
isVertical: setting['desktopLyric.direction'] == 'vertical',
|
isVertical: setting['desktopLyric.direction'] == 'vertical',
|
||||||
onPlay(line, text) {
|
onPlay(line, text) {
|
||||||
setText(text, line)
|
setText(text, Math.max(line, 0))
|
||||||
// console.log(line, text)
|
// console.log(line, text)
|
||||||
},
|
},
|
||||||
onSetLyric(lines, offset) { // listening lyrics seting event
|
onSetLyric(lines, offset) { // listening lyrics seting event
|
||||||
|
|
|
@ -85,7 +85,7 @@ export const init = () => {
|
||||||
lrc = new Lyric({
|
lrc = new Lyric({
|
||||||
shadowContent: false,
|
shadowContent: false,
|
||||||
onPlay(line, text) {
|
onPlay(line, text) {
|
||||||
setText(text, line)
|
setText(text, Math.max(line, 0))
|
||||||
setStatusText(text)
|
setStatusText(text)
|
||||||
// console.log(line, text)
|
// console.log(line, text)
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue