mirror of
https://github.com/imsyy/home.git
synced 2025-06-05 05:10:15 +09:00
FIX:修复 AMLL 逐行歌词加载(修了个peach)
This commit is contained in:
parent
ea29f12c01
commit
8019bf5b94
@ -367,47 +367,63 @@ function syncYrcLrc() {
|
|||||||
if (response.status === 404 || !response.ok) {
|
if (response.status === 404 || !response.ok) {
|
||||||
lrc = "歌词加载失败";
|
lrc = "歌词加载失败";
|
||||||
} else {
|
} else {
|
||||||
lrc = response.text();
|
// 加载 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);
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
})
|
};
|
||||||
.catch(() => {
|
};
|
||||||
lrc = "歌词加载失败";
|
const output = [[true, 1, playerLyricIndex, 0, lrc]];
|
||||||
});
|
if (store.playerLrc.toString() != output.toString()) {
|
||||||
|
store.setPlayerLrc(output);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
} else {
|
||||||
const output = [[true, 1, playerLyricIndex, 0, lrc]];
|
// 逐字模块
|
||||||
if (store.playerLrc.toString() != output.toString()) {
|
const now = player.value.audioStatus.playedTime * 1000;
|
||||||
store.setPlayerLrc(output);
|
const yrcFiltered = store.yrcTemp.filter((i) => i[0] < now);
|
||||||
|
const yrcLyric =
|
||||||
|
yrcFiltered.length > 0
|
||||||
|
? yrcFiltered.slice(-1)[0][2].map((it) => {
|
||||||
|
const [[start, duration], word, line, row] = it;
|
||||||
|
const isCurrent = now >= start && now <= start + duration;
|
||||||
|
const isSungLyrics = start + duration < now;
|
||||||
|
const lessdur = start + duration - now;
|
||||||
|
return [isCurrent, isSungLyrics, line, row, word, duration, lessdur, "auto"];
|
||||||
|
})
|
||||||
|
: [[true, 1, 0, 0, `${store.playerTitle} - ${store.playerArtist}`]];
|
||||||
|
if (store.playerLrc.toString() != yrcLyric.toString()) {
|
||||||
|
store.setPlayerLrc(yrcLyric);
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
} else {
|
} catch (error) {
|
||||||
// 逐字模块
|
console.error(error);
|
||||||
const now = player.value.audioStatus.playedTime * 1000;
|
|
||||||
const yrcFiltered = store.yrcTemp.filter((i) => i[0] < now);
|
|
||||||
const yrcLyric =
|
|
||||||
yrcFiltered.length > 0
|
|
||||||
? yrcFiltered.slice(-1)[0][2].map((it) => {
|
|
||||||
const [[start, duration], word, line, row] = it;
|
|
||||||
const isCurrent = now >= start && now <= start + duration;
|
|
||||||
const isSungLyrics = start + duration < now;
|
|
||||||
const lessdur = start + duration - now;
|
|
||||||
return [isCurrent, isSungLyrics, line, row, word, duration, lessdur, "auto"];
|
|
||||||
})
|
|
||||||
: [[true, 1, 0, 0, `${store.playerTitle} - ${store.playerArtist}`]];
|
|
||||||
if (store.playerLrc.toString() != yrcLyric.toString()) {
|
|
||||||
store.setPlayerLrc(yrcLyric);
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
return requestAnimationFrame(syncYrcLrc);
|
||||||
};
|
};
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
};
|
|
||||||
return requestAnimationFrame(syncYrcLrc);
|
|
||||||
};
|
|
||||||
|
|
||||||
// 暴露子组件方法
|
// 暴露子组件方法
|
||||||
defineExpose({ playToggle, changeVolume, changeSong, toggleList });
|
defineExpose({ playToggle, changeVolume, changeSong, toggleList });
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
Loading…
Reference in New Issue
Block a user