Fehler bei Stay on first site
This commit is contained in:
7
app.py
7
app.py
@@ -737,7 +737,7 @@ def player(site, screen):
|
||||
@app.route("/playlist/<site>/<screen>/hash")
|
||||
def playlist_hash(site, screen):
|
||||
"""Berechnet einen MD5-Hash über die aktuelle Konfiguration (Screen + Priority).
|
||||
Ändert sich der Hash, lädt der Player automatisch neu."""
|
||||
Gibt JSON mit Hash und aktuellem stay_on_first-Wert zurück."""
|
||||
config = load_config()
|
||||
|
||||
relevant = {
|
||||
@@ -748,7 +748,10 @@ def playlist_hash(site, screen):
|
||||
}
|
||||
|
||||
blob = json.dumps(relevant, sort_keys=True).encode()
|
||||
return hashlib.md5(blob).hexdigest()
|
||||
h = hashlib.md5(blob).hexdigest()
|
||||
|
||||
screen_cfg = config.get("sites", {}).get(site, {}).get("screens", {}).get(screen, {})
|
||||
return {"hash": h, "stay_on_first": screen_cfg.get("stay_on_first", False)}
|
||||
|
||||
|
||||
# -------------------------------------------------
|
||||
|
||||
@@ -352,7 +352,7 @@ updateClock();
|
||||
const normalFiles = {{ normal_files | tojson }};
|
||||
const prioFiles = {{ prio_files | tojson }};
|
||||
const interval = {{ interval }} * 1000;
|
||||
const stayOnFirst = {{ "true" if stay_on_first else "false" }};
|
||||
let stayOnFirst = {{ "true" if stay_on_first else "false" }};
|
||||
const screen = "{{ screen }}";
|
||||
const site = "{{ site }}";
|
||||
// stayOnFirst: Player bleibt auf erstem Element (kein Timer/Advance)
|
||||
@@ -488,13 +488,27 @@ function playNext() {
|
||||
}
|
||||
}
|
||||
|
||||
// ─── Auto-Reload bei Playlist-Änderungen ───
|
||||
// ─── Auto-Reload bei Playlist-Änderungen + dynamisches stayOnFirst ───
|
||||
let lastHash = null;
|
||||
|
||||
async function checkForUpdates() {
|
||||
try {
|
||||
const res = await fetch(`/playlist/${site}/${screen}/hash`, { cache: "no-store" });
|
||||
const hash = await res.text();
|
||||
const data = await res.json();
|
||||
const hash = data.hash;
|
||||
const serverStayOnFirst = data.stay_on_first;
|
||||
|
||||
// Dynamisch stayOnFirst vom Server übernehmen
|
||||
const wasStopped = stayOnFirst === true;
|
||||
stayOnFirst = serverStayOnFirst;
|
||||
|
||||
// Wenn stayOnFirst gerade ausgeschaltet wurde → sofort weiterlaufen
|
||||
if (wasStopped && !stayOnFirst) {
|
||||
if (playerTimer) clearTimeout(playerTimer);
|
||||
playNext();
|
||||
}
|
||||
|
||||
// Hash-Änderung → Seite komplett neu laden
|
||||
if (lastHash && lastHash !== hash) {
|
||||
location.reload(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user