通过歌词调整进度时添加对偏移时间的计算
parent
e0e65e4374
commit
469832a598
|
@ -4,7 +4,8 @@ export const lyric = reactive({
|
||||||
lines: [],
|
lines: [],
|
||||||
text: '',
|
text: '',
|
||||||
line: 0,
|
line: 0,
|
||||||
offset: 0, // 临时延迟
|
offset: 0, // 歌词延迟
|
||||||
|
tempOffset: 0, // 歌词临时延迟
|
||||||
})
|
})
|
||||||
|
|
||||||
export const setLines = lines => {
|
export const setLines = lines => {
|
||||||
|
@ -17,3 +18,6 @@ export const setText = (text, line) => {
|
||||||
export const setOffset = offset => {
|
export const setOffset = offset => {
|
||||||
lyric.offset = offset
|
lyric.offset = offset
|
||||||
}
|
}
|
||||||
|
export const setTempOffset = offset => {
|
||||||
|
lyric.tempOffset = offset
|
||||||
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import Lyric from '@renderer/utils/lyric-font-player'
|
||||||
import { getCurrentTime as getPlayerCurrentTime } from '@renderer/plugins/player'
|
import { getCurrentTime as getPlayerCurrentTime } from '@renderer/plugins/player'
|
||||||
import { setDesktopLyricInfo, onGetDesktopLyricInfo } from '@renderer/utils/tools'
|
import { setDesktopLyricInfo, onGetDesktopLyricInfo } from '@renderer/utils/tools'
|
||||||
import { player as eventPlayerNames } from '@renderer/event/names'
|
import { player as eventPlayerNames } from '@renderer/event/names'
|
||||||
import { lyric, setText, setLines, setOffset } from '@renderer/core/share/lyric'
|
import { lyric, setText, setLines, setOffset, setTempOffset } from '@renderer/core/share/lyric'
|
||||||
import { musicInfo, setStatusText, isPlay, playMusicInfo } from '@renderer/core/share/player'
|
import { musicInfo, setStatusText, isPlay, playMusicInfo } from '@renderer/core/share/player'
|
||||||
|
|
||||||
export default ({ setting }) => {
|
export default ({ setting }) => {
|
||||||
|
@ -17,11 +17,12 @@ export default ({ setting }) => {
|
||||||
setStatusText(text)
|
setStatusText(text)
|
||||||
// console.log(line, text)
|
// console.log(line, text)
|
||||||
},
|
},
|
||||||
onSetLyric(lines) { // listening lyrics seting event
|
onSetLyric(lines, offset) { // listening lyrics seting event
|
||||||
// console.log(lines) // lines is array of all lyric text
|
// console.log(lines) // lines is array of all lyric text
|
||||||
setLines(markRawList([...lines]))
|
setLines(markRawList([...lines]))
|
||||||
setText(lines[0] ?? '', 0)
|
setText(lines[0] ?? '', 0)
|
||||||
setOffset(0) // 重置临时延迟
|
setOffset(offset) // 歌词延迟
|
||||||
|
setTempOffset(0) // 重置临时延迟
|
||||||
},
|
},
|
||||||
// offset: 80,
|
// offset: 80,
|
||||||
})
|
})
|
||||||
|
@ -58,7 +59,7 @@ export default ({ setting }) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const setLyricOffset = offset => {
|
const setLyricOffset = offset => {
|
||||||
setOffset(offset)
|
setTempOffset(offset)
|
||||||
if (isPlay.value && (musicInfo.url || playMusicInfo.listId == 'download')) {
|
if (isPlay.value && (musicInfo.url || playMusicInfo.listId == 'download')) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const time = getCurrentTime()
|
const time = getCurrentTime()
|
||||||
|
|
|
@ -28,7 +28,7 @@ export default ({ isPlay, lyric }) => {
|
||||||
if (time == -1) return
|
if (time == -1) return
|
||||||
handleSkipMouseLeave()
|
handleSkipMouseLeave()
|
||||||
isStopScroll.value = false
|
isStopScroll.value = false
|
||||||
window.eventHub.emit(eventPlayerNames.setProgress, time)
|
window.eventHub.emit(eventPlayerNames.setProgress, Math.max(time + lyric.offset + lyric.tempOffset, 0))
|
||||||
if (!isPlay.value) window.eventHub.emit(eventPlayerNames.setPlay)
|
if (!isPlay.value) window.eventHub.emit(eventPlayerNames.setPlay)
|
||||||
}
|
}
|
||||||
const handleSkipMouseEnter = () => {
|
const handleSkipMouseEnter = () => {
|
||||||
|
|
|
@ -34,7 +34,7 @@ module.exports = class LinePlayer {
|
||||||
if (this.translationLyric == null) this.translationLyric = ''
|
if (this.translationLyric == null) this.translationLyric = ''
|
||||||
this._initTag()
|
this._initTag()
|
||||||
this._initLines()
|
this._initLines()
|
||||||
this.onSetLyric(this.lines)
|
this.onSetLyric(this.lines, this.tags.offset + this.offset)
|
||||||
}
|
}
|
||||||
|
|
||||||
_initTag() {
|
_initTag() {
|
||||||
|
|
Loading…
Reference in New Issue