From 83304c197d1bd4d93b0fc543c7e76bdd6f1d0f1b Mon Sep 17 00:00:00 2001 From: marwin Date: Sat, 21 Mar 2026 17:22:51 +0100 Subject: [PATCH] Try HTTPS upgrade for HTTP streams, show error on failure Browsers block HTTP (mixed content) audio from HTTPS pages. On playStation, if the URL is http:// and page is https://, try the https:// version first. If the stream fails to load, show a clear error in the track display instead of silently doing nothing. Co-Authored-By: Claude Sonnet 4.6 --- static/js/app.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/static/js/app.js b/static/js/app.js index 7b27abe..c91f6e4 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -70,7 +70,25 @@ function playStation(url, name, stationId) { currentStation = { url, name, id: stationId || null }; isPlaying = true; - audio.src = url; + // If page is HTTPS and stream is HTTP, try upgrading to HTTPS first. + // Browsers block mixed content (HTTP media on HTTPS pages). + const playUrl = (location.protocol === 'https:' && url.startsWith('http://')) + ? url.replace('http://', 'https://') + : url; + + audio.onerror = () => { + const wasUpgraded = playUrl !== url; + if (wasUpgraded) { + $('now-playing-track').textContent = 'Stream nicht erreichbar (HTTP-only, kein HTTPS-Fallback)'; + } else { + $('now-playing-track').textContent = 'Stream konnte nicht geladen werden'; + } + isPlaying = false; + $('play-stop-btn').textContent = '▶ Play'; + $('play-stop-btn').classList.remove('playing'); + }; + + audio.src = playUrl; const volSlider = document.getElementById('volume'); if (volSlider) audio.volume = volSlider.value / 255; audio.play().catch(() => { @@ -113,6 +131,7 @@ function stopPlayback(clearStation = true) { audio.src = ''; audio.ontimeupdate = null; audio.onended = null; + audio.onerror = null; isPlaying = false; podcastMode = false; if ('mediaSession' in navigator) navigator.mediaSession.playbackState = 'none';