From bca9d6b5e90d9ad8292a6eb694b5ed31d919099d Mon Sep 17 00:00:00 2001 From: mrwnslz Date: Tue, 29 Sep 2026 20:00:42 +0200 Subject: [PATCH] =?UTF-8?q?Radio:=20http-Streams=20in=20nativen=20H=C3=BCl?= =?UTF-8?q?len=20abspielen=20lassen;=20Play-Session=20nicht=20mehr=20verli?= =?UTF-8?q?eren=20(SW=20v49)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit playStation() öffnet http-Sender auf einer https-Seite in einem neuen Fenster. Native Hüllen (diora Android, diora desktop), die den Stream selbst abspielen, setzen window.DIORA_PLAYS_HTTP_STREAMS und überspringen das. stopPlaySession() wurde von playStation() ohne await aufgerufen und setzte currentPlayId erst nach dem fetch auf null – beim Senderwechsel also die frisch gesetzte ID der neuen Session. Die ID wird jetzt vor dem await übernommen. Co-Authored-By: Claude Opus 5.5 --- static/js/app.js | 13 +++++++++---- static/js/sw.js | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/static/js/app.js b/static/js/app.js index 21376a4..804775c 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -157,7 +157,9 @@ function customPrompt(message, defaultValue = '') { function playStation(url, name, stationId) { stopPlayback(false); - if (location.protocol === 'https:' && url.startsWith('http://')) { + // A secure page can't load plain-http streams (mixed content). Native shells + // that play the stream themselves set window.DIORA_PLAYS_HTTP_STREAMS. + if (location.protocol === 'https:' && url.startsWith('http://') && !window.DIORA_PLAYS_HTTP_STREAMS) { window.open(url, '_blank'); return; } @@ -280,15 +282,18 @@ async function startPlaySession(stationName, stationUrl) { } async function stopPlaySession() { - if (!currentPlayId) return; + // Take the id before awaiting: playStation() calls this without waiting and + // starts the next session right away, whose id must not be cleared here. + const playId = currentPlayId; + if (!playId) return; + currentPlayId = null; try { await fetch('/radio/play/stop/', { method: 'POST', headers: {'Content-Type': 'application/json', 'X-CSRFToken': getCsrfToken()}, - body: JSON.stringify({play_id: currentPlayId}) + body: JSON.stringify({play_id: playId}) }); } catch (e) {} - currentPlayId = null; } window.addEventListener('beforeunload', () => { diff --git a/static/js/sw.js b/static/js/sw.js index c36b133..e20bf19 100644 --- a/static/js/sw.js +++ b/static/js/sw.js @@ -2,7 +2,7 @@ * diora service worker — caches the app shell for offline use. */ -const CACHE = 'diora-v48'; +const CACHE = 'diora-v49'; const PODCAST_CACHE = 'diora-podcast-v1'; const SHELL = [ '/static/css/app.css',