mirror of
https://github.com/qier222/YesPlayMusic.git
synced 2025-03-06 02:05:20 +08:00
fix: lyrics issues
This commit is contained in:
parent
cfc42be2db
commit
3822b498a1
@ -22,9 +22,10 @@ export function parseLyric(lrc) {
|
|||||||
const t = timeRegExpArr[k];
|
const t = timeRegExpArr[k];
|
||||||
const min = Number(String(t.match(/\[\d*/i)).slice(1));
|
const min = Number(String(t.match(/\[\d*/i)).slice(1));
|
||||||
const sec = Number(String(t.match(/:\d*/i)).slice(1));
|
const sec = Number(String(t.match(/:\d*/i)).slice(1));
|
||||||
const time = min * 60 + sec;
|
const ms = Number(t.match(/\d*\]/i)[0].slice(0, 2)) / 100;
|
||||||
|
const time = min * 60 + sec + ms;
|
||||||
if (content !== "") {
|
if (content !== "") {
|
||||||
lrcObj.push({ time: time, content });
|
lrcObj.push({ time: time, rawTime: timeRegExpArr[0], content });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,7 @@ export default {
|
|||||||
lyricsInterval: null,
|
lyricsInterval: null,
|
||||||
lyric: [],
|
lyric: [],
|
||||||
tlyric: [],
|
tlyric: [],
|
||||||
highlightLyricIndex: 0,
|
highlightLyricIndex: -1,
|
||||||
minimize: true,
|
minimize: true,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -195,10 +195,10 @@ export default {
|
|||||||
// content统一转换数组形式
|
// content统一转换数组形式
|
||||||
if (lyricFiltered.length) {
|
if (lyricFiltered.length) {
|
||||||
lyricFiltered.forEach((l) => {
|
lyricFiltered.forEach((l) => {
|
||||||
const { time, content } = l;
|
const { rawTime, time, content } = l;
|
||||||
const lyricItem = { time, content, contents: [content] };
|
const lyricItem = { time, content, contents: [content] };
|
||||||
const sameTimeTLyric = this.tlyric.find(
|
const sameTimeTLyric = this.tlyric.find(
|
||||||
({ time: tLyricTime }) => tLyricTime === time
|
({ rawTime: tLyricRawTime }) => tLyricRawTime === rawTime
|
||||||
);
|
);
|
||||||
if (sameTimeTLyric) {
|
if (sameTimeTLyric) {
|
||||||
const { content: tLyricContent } = sameTimeTLyric;
|
const { content: tLyricContent } = sameTimeTLyric;
|
||||||
@ -267,12 +267,12 @@ export default {
|
|||||||
},
|
},
|
||||||
setLyricsInterval() {
|
setLyricsInterval() {
|
||||||
this.lyricsInterval = setInterval(() => {
|
this.lyricsInterval = setInterval(() => {
|
||||||
|
const progress = this.player.seek() ?? 0;
|
||||||
let oldHighlightLyricIndex = this.highlightLyricIndex;
|
let oldHighlightLyricIndex = this.highlightLyricIndex;
|
||||||
this.highlightLyricIndex = this.lyric.findIndex((l, index) => {
|
this.highlightLyricIndex = this.lyric.findIndex((l, index) => {
|
||||||
const nextLyric = this.lyric[index + 1];
|
const nextLyric = this.lyric[index + 1];
|
||||||
return (
|
return (
|
||||||
this.progress >= l.time &&
|
progress >= l.time && (nextLyric ? progress < nextLyric.time : true)
|
||||||
(nextLyric ? this.progress < nextLyric.time : true)
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
if (oldHighlightLyricIndex !== this.highlightLyricIndex) {
|
if (oldHighlightLyricIndex !== this.highlightLyricIndex) {
|
||||||
@ -283,7 +283,7 @@ export default {
|
|||||||
block: "center",
|
block: "center",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, 500);
|
}, 50);
|
||||||
},
|
},
|
||||||
formatLine(line) {
|
formatLine(line) {
|
||||||
const showLyricsTranslation = this.$store.state.settings
|
const showLyricsTranslation = this.$store.state.settings
|
||||||
|
Loading…
x
Reference in New Issue
Block a user