diff --git a/package.json b/package.json index 2c06aed1..611bbe48 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/renderer/main/vueapp.js b/src/renderer/main/vueapp.js index 4f1d4afd..039faaf5 100644 --- a/src/renderer/main/vueapp.js +++ b/src/renderer/main/vueapp.js @@ -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) { diff --git a/src/renderer/views/components/lyrics-view.ejs b/src/renderer/views/components/lyrics-view.ejs index ec5cf02d..b3ea0062 100644 --- a/src/renderer/views/components/lyrics-view.ejs +++ b/src/renderer/views/components/lyrics-view.ejs @@ -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");