use am lyrics as def, fix airplay lyrics delay

This commit is contained in:
vapormusic 2022-10-06 09:40:10 +07:00
parent c876369b88
commit db285b8a8a
3 changed files with 15 additions and 14 deletions

View file

@ -45,7 +45,7 @@
"@sentry/electron": "^4.0.2",
"@sentry/integrations": "^7.14.1",
"adm-zip": "0.4.10",
"airtunes2": "github:ciderapp/node_airtunes2",
"airtunes2": "git+https://github.com/ciderapp/node_airtunes2.git",
"castv2-client": "^1.2.0",
"chokidar": "^3.5.3",
"discord-auto-rpc": "^1.0.17",

View file

@ -3263,21 +3263,22 @@ const app = new Vue({
if (musicType === "musicVideo") {
this.loadYTLyrics();
} else {
// if (app.cfg.lyrics.enable_mxm) {
this.loadMXM();
// } else {
// this.loadAMLyrics();
// }
// only load MXM lyrics if AM lyrics failed to load
this.loadAMLyrics();
}
},
loadAMLyrics() {
async loadAMLyrics() {
const songID = this.mk.nowPlayingItem != null ? this.mk.nowPlayingItem["_songId"] ?? this.mk.nowPlayingItem["songId"] ?? -1 : -1;
// this.getMXM( trackName, artistName, 'en', duration);
if (songID != -1) {
this.mk.api.v3.music(`v1/catalog/${this.mk.storefrontId}/songs/${songID}/lyrics`).then((response) => {
this.lyricsMediaItem = response.data?.data[0]?.attributes["ttml"];
this.parseTTML();
});
try{
let response = await this.mk.api.v3.music(`v1/catalog/${this.mk.storefrontId}/songs/${songID}/lyrics`)
this.lyricsMediaItem = response.data?.data[0]?.attributes["ttml"];
this.parseTTML();
} catch (_)
{this.loadMXM();};
} else {
this.loadMXM();
}
},
addToLibrary(id) {

View file

@ -120,10 +120,10 @@
if (startTime != 9999999) this.app.seekTo(startTime, false);
},
getActiveLyric() {
const delayfix = 0.1
const delayfix = app.activeCasts[0]?.hasOwnProperty('airplay2') ? -2.5 : 0.1
const prevLine = app.currentLyricsLine;
for (var i = 0; i < this.lyrics.length; i++) {
if (this.time + delayfix >= this.lyrics[i].startTime && this.time + delayfix <= app.lyrics[i].endTime) {
if ((this.time + delayfix >= this.lyrics[i].startTime) && (this.time + delayfix <= app.lyrics[i].endTime)) {
if (app.currentLyricsLine != i) {
app.currentLyricsLine = i;
if (((app.lyricon && app.drawer.open) || app.appMode == 'fullscreen') && this.$refs.lyricsview.querySelector(`.lyric-line[line-index="${i}"]`)) {
@ -172,7 +172,7 @@
} catch (e) {
}
for (child of this.$refs.lyricsview.querySelector(`.lyric-line[line-index="${app.currentLyricsLine}"]`).querySelectorAll(".verse")) {
if (this.time + 0.1 >= child.getAttribute("lyricstart") * 1 + child.getAttribute("versestart") * 1) {
if (this.time + delayfix >= child.getAttribute("lyricstart") * 1 + child.getAttribute("versestart") * 1) {
child.classList.add("verse-active");
} else {
child.classList.remove("verse-active");