FIX:修复 AMLL 逐行歌词加载(修了个peach)

This commit is contained in:
NanoRocky 2025-01-15 22:48:47 +08:00
parent ea29f12c01
commit 8019bf5b94

View File

@ -367,11 +367,27 @@ function syncYrcLrc() {
if (response.status === 404 || !response.ok) {
lrc = "歌词加载失败";
} else {
lrc = response.text();
};
})
.catch(() => {
lrc = "歌词加载失败";
// AMLL [,,,...!]
response.text().then((text) => {
const lines = text.split('\n');
const lyrics = lines.map((line) => {
const match = line.match(/\[(\d{2}):(\d{2}\.\d{3})\](.*)/);
if (match) {
const minutes = parseInt(match[1], 10);
const seconds = parseFloat(match[2]);
const time = minutes * 60 + seconds;
const lyric = match[3];
return [time, lyric];
}
return null;
}).filter(line => line !== null);
player.value.aplayer.lyrics[playIndex.value] = lyrics;
const playerLyricIndex = player.value.aplayer.lyricIndex;
const lrc = lyrics[playerLyricIndex][1];
const output = [[true, 1, playerLyricIndex, 0, lrc]];
if (store.playerLrc.toString() != output.toString()) {
store.setPlayerLrc(output);
}
});
};
};
@ -404,10 +420,10 @@ function syncYrcLrc() {
console.error(error);
};
return requestAnimationFrame(syncYrcLrc);
};
};
//
defineExpose({ playToggle, changeVolume, changeSong, toggleList });
//
defineExpose({ playToggle, changeVolume, changeSong, toggleList });
</script>
<style lang="scss" scoped>