From d5c49fbf15bcef2a6b9c9db04c2674dca7c7d9a0 Mon Sep 17 00:00:00 2001 From: RaindropsSys Date: Tue, 31 Oct 2023 22:30:42 +0100 Subject: Updated 9 files and added 21 files (automated) --- app/index.php | 48 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-) (limited to 'app/index.php') diff --git a/app/index.php b/app/index.php index 601c974..6de3cdf 100644 --- a/app/index.php +++ b/app/index.php @@ -1,6 +1,21 @@ + + @@ -271,6 +286,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $_PROFI window.seekTo = (time) => { document.getElementById("player").contentDocument.getElementById("player-audio").currentTime = time; + updateAndroidNotification(); if (playingStella) { playerDocument.getElementById("player-audio-stella-side1").currentTime = playerDocument.getElementById("player-audio").currentTime; @@ -422,10 +438,16 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $_PROFI } playerDocument.getElementById("player-audio").onplay = () => { + updateAndroidNotification(); + if (window.preloadedGains[window.currentSongID]) { window.currentNormalizationSource.connect(window.preloadedGains[window.currentSongID]); - window.currentNormalizationSource2.connect(window.preloadedGainsBoosted1[window.currentSongID]); - window.currentNormalizationSource3.connect(window.preloadedGainsBoosted2[window.currentSongID]); + + if (playingStella) { + window.currentNormalizationSource2.connect(window.preloadedGainsBoosted1[window.currentSongID]); + window.currentNormalizationSource3.connect(window.preloadedGainsBoosted2[window.currentSongID]); + } + window.preloadedGains[window.currentSongID].connect(window.currentNormalizationContext.destination); } @@ -447,10 +469,25 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $_PROFI updateDisplay(); } + window.needsDurationChange = true; + + playerDocument.getElementById("player-audio").ondurationchange = () => { + if (window.needsDurationChange) { + updateAndroidNotification(); + window.needsDurationChange = false; + } + } + playerDocument.getElementById("player-audio").onpause = () => { if (window.preloadedGains[window.currentSongID]) { try { window.currentNormalizationSource.disconnect(window.preloadedGains[window.currentSongID]); + + if (playingStella) { + window.currentNormalizationSource2.disconnect(window.preloadedGainsBoosted1[window.currentSongID]); + window.currentNormalizationSource3.disconnect(window.preloadedGainsBoosted2[window.currentSongID]); + } + window.preloadedGains[window.currentSongID].disconnect(window.currentNormalizationContext.destination); } catch (e) { console.error(e); @@ -486,16 +523,19 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $_PROFI } updateDisplay(); + updateAndroidNotification(); } } initializePlayerDocument(); - function updateDisplay() { + function updateAndroidNotification() { if (window.MistAndroid && currentSong) { window.MistAndroid.setNotificationData(currentSong.title, currentSong.artist, currentSong.album, Math.round(playerDocument.getElementById("player-audio").currentTime * 1000), Math.round(playerDocument.getElementById("player-audio").duration * 1000), !playerDocument.getElementById("player-audio").paused, buffering); } + } + function updateDisplay() { if (playerDocument.getElementById("player-audio").paused) { document.title = "Mist"; } else if (currentSong) { @@ -853,6 +893,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $_PROFI window.currentSong = songs[id]; window.currentSongID = id; updateDisplay(); + updateAndroidNotification(); if (document.getElementById("ui").contentWindow.refreshQueue) document.getElementById("ui").contentWindow.refreshQueue(); let stellaCompatible = false; @@ -886,6 +927,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $_PROFI cleanupPreload(); preloadMore(); + window.needsDurationChange = true; if (!stellaCompatible) { if (!window.preloadedURLs[id]) { -- cgit