修复歌词偏移处理问题
parent
bb5de056d4
commit
128039d678
|
@ -28,7 +28,9 @@ export default ({ isPlay, lyric, isShowLyricProgressSetting }) => {
|
||||||
if (time == -1) return
|
if (time == -1) return
|
||||||
handleSkipMouseLeave()
|
handleSkipMouseLeave()
|
||||||
isStopScroll.value = false
|
isStopScroll.value = false
|
||||||
window.eventHub.emit(eventPlayerNames.setProgress, Math.max(time + lyric.offset + lyric.tempOffset, 0))
|
let offset = lyric.offset + lyric.tempOffset
|
||||||
|
if (offset) offset = offset / 1000
|
||||||
|
window.eventHub.emit(eventPlayerNames.setProgress, Math.max(time + offset, 0))
|
||||||
if (!isPlay.value) window.eventHub.emit(eventPlayerNames.setPlay)
|
if (!isPlay.value) window.eventHub.emit(eventPlayerNames.setPlay)
|
||||||
}
|
}
|
||||||
const handleSkipMouseEnter = () => {
|
const handleSkipMouseEnter = () => {
|
||||||
|
|
|
@ -34,23 +34,19 @@ module.exports = class Lyric {
|
||||||
|
|
||||||
this.playingLineNum = -1
|
this.playingLineNum = -1
|
||||||
this.isLineMode = false
|
this.isLineMode = false
|
||||||
|
|
||||||
|
this.linePlayer = new LinePlayer({
|
||||||
|
offset: this.offset,
|
||||||
|
onPlay: this._handleLinePlayerOnPlay,
|
||||||
|
onSetLyric: this._handleLinePlayerOnSetLyric,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
_init() {
|
_init() {
|
||||||
this.playingLineNum = -1
|
this.playingLineNum = -1
|
||||||
this.isLineMode = false
|
this.isLineMode = false
|
||||||
|
|
||||||
if (this.linePlayer) {
|
this.linePlayer.setLyric(this.lyric, this.translationLyric)
|
||||||
this.linePlayer.setLyric(this.lyric, this.translationLyric)
|
|
||||||
} else {
|
|
||||||
this.linePlayer = new LinePlayer({
|
|
||||||
lyric: this.lyric,
|
|
||||||
translationLyric: this.translationLyric,
|
|
||||||
offset: this.offset,
|
|
||||||
onPlay: this._handleLinePlayerOnPlay,
|
|
||||||
onSetLyric: this._handleLinePlayerOnSetLyric,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_handleLinePlayerOnPlay = (num, text, curTime) => {
|
_handleLinePlayerOnPlay = (num, text, curTime) => {
|
||||||
|
@ -148,6 +144,10 @@ module.exports = class Lyric {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 如果是逐行歌词,则添加 60ms 的偏移
|
||||||
|
let newOffset = this.isLineMode ? this.offset + 60 : this.offset
|
||||||
|
offset = offset - this.linePlayer.offset + newOffset
|
||||||
|
this.linePlayer.offset = newOffset
|
||||||
this.onSetLyric(this._lines, offset)
|
this.onSetLyric(this._lines, offset)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,6 +166,5 @@ module.exports = class Lyric {
|
||||||
this.lyric = lyric
|
this.lyric = lyric
|
||||||
this.translationLyric = translationLyric
|
this.translationLyric = translationLyric
|
||||||
this._init()
|
this._init()
|
||||||
this.linePlayer.offset = this.isLineMode ? this.offset + 90 : this.offset
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,9 +12,7 @@ const tagRegMap = {
|
||||||
const timeoutTools = new TimeoutTools()
|
const timeoutTools = new TimeoutTools()
|
||||||
|
|
||||||
module.exports = class LinePlayer {
|
module.exports = class LinePlayer {
|
||||||
constructor({ lyric = '', translationLyric = '', offset = 0, onPlay = function() { }, onSetLyric = function() { } } = {}) {
|
constructor({ offset = 0, onPlay = function() { }, onSetLyric = function() { } } = {}) {
|
||||||
this.lyric = lyric
|
|
||||||
this.translationLyric = translationLyric
|
|
||||||
this.tags = {}
|
this.tags = {}
|
||||||
this.lines = null
|
this.lines = null
|
||||||
this.translationLines = null
|
this.translationLines = null
|
||||||
|
@ -26,7 +24,6 @@ module.exports = class LinePlayer {
|
||||||
this.offset = offset
|
this.offset = offset
|
||||||
this._performanceTime = 0
|
this._performanceTime = 0
|
||||||
this._startTime = 0
|
this._startTime = 0
|
||||||
this._init()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_init() {
|
_init() {
|
||||||
|
|
Loading…
Reference in New Issue