From 0dbde712415af8e7f7b1424c47e47b569f1779ce Mon Sep 17 00:00:00 2001 From: gnattu Date: Tue, 1 Oct 2024 17:02:50 +0800 Subject: [PATCH 1/4] Only add gain node when normalization enabled --- src/plugins/htmlAudioPlayer/plugin.js | 11 +++++++++-- src/strings/en-us.json | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/plugins/htmlAudioPlayer/plugin.js b/src/plugins/htmlAudioPlayer/plugin.js index 067d94c48c..99ecb2b4c9 100644 --- a/src/plugins/htmlAudioPlayer/plugin.js +++ b/src/plugins/htmlAudioPlayer/plugin.js @@ -121,6 +121,13 @@ class HtmlAudioPlayer { normalizationGain = options.mediaSource.albumNormalizationGain ?? options.item.NormalizationGain; + } else { + console.debug('normalization disabled') + return; + } + + if (!self.gainNode) { + addGainElement(elem); } if (normalizationGain) { @@ -276,7 +283,7 @@ class HtmlAudioPlayer { self._mediaElement = elem; - addGainElement(elem); + // addGainElement(elem); return elem; } @@ -317,7 +324,7 @@ class HtmlAudioPlayer { function onVolumeChange() { if (!self._isFadingOut) { htmlMediaHelper.saveVolume(this.volume); - if (browser.safari) { + if (browser.safari && self.gainNode) { self.gainNode.gain.value = this.volume * self.normalizationGain; } Events.trigger(self, 'volumechange'); diff --git a/src/strings/en-us.json b/src/strings/en-us.json index d2e32a1ff4..5cd78810ef 100644 --- a/src/strings/en-us.json +++ b/src/strings/en-us.json @@ -156,7 +156,7 @@ "ChannelNumber": "Channel number", "Channels": "Channels", "CinemaModeConfigurationHelp": "Cinema mode brings the theater experience straight to your living room with the ability to play trailers and custom intros before the main feature.", - "SelectAudioNormalizationHelp": "Track gain - adjusts the volume of each track so they playback with the same loudness. Album gain - adjusts the volume of all the tracks in an album only, keeping the album's dynamic range.", + "SelectAudioNormalizationHelp": "Track gain - adjusts the volume of each track so they playback with the same loudness. Album gain - adjusts the volume of all the tracks in an album only, keeping the album's dynamic range. Switching between \"Off\" and other options requires restarting the current playback.", "ClearQueue": "Clear queue", "ClientSettings": "Client Settings", "Collections": "Collections", From 6b52358b57ec80bb822838b764194709d65273be Mon Sep 17 00:00:00 2001 From: gnattu Date: Tue, 1 Oct 2024 17:13:52 +0800 Subject: [PATCH 2/4] Remove commented code --- src/plugins/htmlAudioPlayer/plugin.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/plugins/htmlAudioPlayer/plugin.js b/src/plugins/htmlAudioPlayer/plugin.js index 99ecb2b4c9..2be98b40aa 100644 --- a/src/plugins/htmlAudioPlayer/plugin.js +++ b/src/plugins/htmlAudioPlayer/plugin.js @@ -283,8 +283,6 @@ class HtmlAudioPlayer { self._mediaElement = elem; - // addGainElement(elem); - return elem; } From 75d21a81403bc76ee5a61d09333230122df3b705 Mon Sep 17 00:00:00 2001 From: gnattu Date: Tue, 1 Oct 2024 17:18:26 +0800 Subject: [PATCH 3/4] Fix lint Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- src/plugins/htmlAudioPlayer/plugin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/htmlAudioPlayer/plugin.js b/src/plugins/htmlAudioPlayer/plugin.js index 2be98b40aa..a211aba276 100644 --- a/src/plugins/htmlAudioPlayer/plugin.js +++ b/src/plugins/htmlAudioPlayer/plugin.js @@ -122,7 +122,7 @@ class HtmlAudioPlayer { options.mediaSource.albumNormalizationGain ?? options.item.NormalizationGain; } else { - console.debug('normalization disabled') + console.debug('normalization disabled'); return; } From 24c30dc96d577610cd4650f397c995bd6b2116c7 Mon Sep 17 00:00:00 2001 From: gnattu Date: Tue, 1 Oct 2024 18:25:09 +0800 Subject: [PATCH 4/4] Handle addGainElement failure Co-authored-by: Dmitry Lyzo <56478732+dmitrylyzo@users.noreply.github.com> --- src/plugins/htmlAudioPlayer/plugin.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/htmlAudioPlayer/plugin.js b/src/plugins/htmlAudioPlayer/plugin.js index a211aba276..029cdeca82 100644 --- a/src/plugins/htmlAudioPlayer/plugin.js +++ b/src/plugins/htmlAudioPlayer/plugin.js @@ -128,6 +128,7 @@ class HtmlAudioPlayer { if (!self.gainNode) { addGainElement(elem); + if (!self.gainNode) return; } if (normalizationGain) {