mirror of
https://github.com/qier222/YesPlayMusic.git
synced 2025-03-05 10:15:26 +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 min = 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 !== "") {
|
||||
lrcObj.push({ time: time, content });
|
||||
lrcObj.push({ time: time, rawTime: timeRegExpArr[0], content });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ export default {
|
||||
lyricsInterval: null,
|
||||
lyric: [],
|
||||
tlyric: [],
|
||||
highlightLyricIndex: 0,
|
||||
highlightLyricIndex: -1,
|
||||
minimize: true,
|
||||
};
|
||||
},
|
||||
@ -195,10 +195,10 @@ export default {
|
||||
// content统一转换数组形式
|
||||
if (lyricFiltered.length) {
|
||||
lyricFiltered.forEach((l) => {
|
||||
const { time, content } = l;
|
||||
const { rawTime, time, content } = l;
|
||||
const lyricItem = { time, content, contents: [content] };
|
||||
const sameTimeTLyric = this.tlyric.find(
|
||||
({ time: tLyricTime }) => tLyricTime === time
|
||||
({ rawTime: tLyricRawTime }) => tLyricRawTime === rawTime
|
||||
);
|
||||
if (sameTimeTLyric) {
|
||||
const { content: tLyricContent } = sameTimeTLyric;
|
||||
@ -267,12 +267,12 @@ export default {
|
||||
},
|
||||
setLyricsInterval() {
|
||||
this.lyricsInterval = setInterval(() => {
|
||||
const progress = this.player.seek() ?? 0;
|
||||
let oldHighlightLyricIndex = this.highlightLyricIndex;
|
||||
this.highlightLyricIndex = this.lyric.findIndex((l, index) => {
|
||||
const nextLyric = this.lyric[index + 1];
|
||||
return (
|
||||
this.progress >= l.time &&
|
||||
(nextLyric ? this.progress < nextLyric.time : true)
|
||||
progress >= l.time && (nextLyric ? progress < nextLyric.time : true)
|
||||
);
|
||||
});
|
||||
if (oldHighlightLyricIndex !== this.highlightLyricIndex) {
|
||||
@ -283,7 +283,7 @@ export default {
|
||||
block: "center",
|
||||
});
|
||||
}
|
||||
}, 500);
|
||||
}, 50);
|
||||
},
|
||||
formatLine(line) {
|
||||
const showLyricsTranslation = this.$store.state.settings
|
||||
|
Loading…
x
Reference in New Issue
Block a user