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")
|
@app.route("/playlist/<site>/<screen>/hash")
|
||||||
def playlist_hash(site, screen):
|
def playlist_hash(site, screen):
|
||||||
"""Berechnet einen MD5-Hash über die aktuelle Konfiguration (Screen + Priority).
|
"""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()
|
config = load_config()
|
||||||
|
|
||||||
relevant = {
|
relevant = {
|
||||||
@@ -748,7 +748,10 @@ def playlist_hash(site, screen):
|
|||||||
}
|
}
|
||||||
|
|
||||||
blob = json.dumps(relevant, sort_keys=True).encode()
|
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,10 +352,10 @@ updateClock();
|
|||||||
const normalFiles = {{ normal_files | tojson }};
|
const normalFiles = {{ normal_files | tojson }};
|
||||||
const prioFiles = {{ prio_files | tojson }};
|
const prioFiles = {{ prio_files | tojson }};
|
||||||
const interval = {{ interval }} * 1000;
|
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 screen = "{{ screen }}";
|
||||||
const site = "{{ site }}";
|
const site = "{{ site }}";
|
||||||
// stayOnFirst: Player bleibt auf erstem Element (kein Timer/Advance)
|
// stayOnFirst: Player bleibt auf erstem Element (kein Timer/Advance)
|
||||||
|
|
||||||
// ─── Player-Status ───
|
// ─── Player-Status ───
|
||||||
let normalIndex = 0;
|
let normalIndex = 0;
|
||||||
@@ -488,13 +488,27 @@ function playNext() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── Auto-Reload bei Playlist-Änderungen ───
|
// ─── Auto-Reload bei Playlist-Änderungen + dynamisches stayOnFirst ───
|
||||||
let lastHash = null;
|
let lastHash = null;
|
||||||
|
|
||||||
async function checkForUpdates() {
|
async function checkForUpdates() {
|
||||||
try {
|
try {
|
||||||
const res = await fetch(`/playlist/${site}/${screen}/hash`, { cache: "no-store" });
|
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) {
|
if (lastHash && lastHash !== hash) {
|
||||||
location.reload(true);
|
location.reload(true);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user