通过歌词调整进度时添加对偏移时间的计算

This commit is contained in:
lyswhut
2022-03-23 17:49:34 +08:00
parent e0e65e4374
commit 469832a598
4 changed files with 12 additions and 7 deletions
+5 -1
View File
@@ -4,7 +4,8 @@ export const lyric = reactive({
lines: [],
text: '',
line: 0,
offset: 0, // 临时延迟
offset: 0, // 歌词延迟
tempOffset: 0, // 歌词临时延迟
})
export const setLines = lines => {
@@ -17,3 +18,6 @@ export const setText = (text, line) => {
export const setOffset = 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 { setDesktopLyricInfo, onGetDesktopLyricInfo } from '@renderer/utils/tools'
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'
export default ({ setting }) => {
@@ -17,11 +17,12 @@ export default ({ setting }) => {
setStatusText(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
setLines(markRawList([...lines]))
setText(lines[0] ?? '', 0)
setOffset(0) // 重置临时延迟
setOffset(offset) // 歌词延迟
setTempOffset(0) // 重置临时延迟
},
// offset: 80,
})
@@ -58,7 +59,7 @@ export default ({ setting }) => {
}
const setLyricOffset = offset => {
setOffset(offset)
setTempOffset(offset)
if (isPlay.value && (musicInfo.url || playMusicInfo.listId == 'download')) {
setTimeout(() => {
const time = getCurrentTime()