This commit is contained in:
2026-04-14 20:20:46 +02:00
parent cd3ed811f6
commit 4a206f2f19
3 changed files with 89 additions and 16 deletions

View File

@@ -1073,6 +1073,8 @@ class MainWindow(QMainWindow):
self._btn_play.setText("")
def _stop(self):
# Annuller evt. igangværende demo_then_play
self._demo_then_play_pending = False
# Annuller evt. igangværende countdown
if getattr(self, "_waiting_for_auto", False):
self._waiting_for_auto = False
@@ -1154,6 +1156,10 @@ class MainWindow(QMainWindow):
self._btn_play.setText("")
self._vu.reset()
# Hvis demo_then_play venter på at starte sang — lad timeren klare det
if getattr(self, "_demo_then_play_pending", False):
return
# Synkroniser current_idx til playlist_panel
self._playlist_panel._current_idx = self._current_idx
@@ -1178,12 +1184,12 @@ class MainWindow(QMainWindow):
self._waiting_for_auto = False
self._set_status(f"Klar: {next_song.get('title','')} — tryk ▶ for at starte")
elif mode in ("auto_demo", "auto_play"):
elif mode in ("auto_demo", "auto_play", "demo_then_play"):
self._waiting_for_auto = True
self._countdown_secs = delay
self._countdown_mode = mode
self._countdown_title = next_song.get("title", "")
label = "Auto-demo" if mode == "auto_demo" else "Auto-play"
label = "Auto-demo" if mode in ("auto_demo", "demo_then_play") else "Auto-play"
self._set_status(f"{label} om {delay}s — {self._countdown_title}")
if not hasattr(self, "_countdown_timer"):
@@ -1208,20 +1214,20 @@ class MainWindow(QMainWindow):
self._countdown_timer.stop()
return
self._countdown_secs -= 1
label = "Auto-demo" if self._countdown_mode == "auto_demo" else "Auto-play"
label = "Auto-play" if self._countdown_mode == "auto_play" else "Auto-demo"
if self._countdown_secs > 0:
self._set_status(f"{label} om {self._countdown_secs}s — {self._countdown_title}")
else:
self._countdown_timer.stop()
if self._countdown_mode == "auto_demo":
self._auto_demo_next()
else:
if self._countdown_mode == "auto_play":
self._auto_play_next()
else:
self._auto_demo_next() # auto_demo og demo_then_play starter begge med demo
def _auto_demo_next(self):
"""Afspil demo af den næste klargjorte sang automatisk."""
if not getattr(self, "_waiting_for_auto", False):
return # Brugeren har allerede trykket ▶ manuelt
return
self._waiting_for_auto = False
self._playlist_panel.set_current(self._current_idx)
self._player.play_demo(self._demo_seconds, self._demo_fade_seconds)
@@ -1230,6 +1236,24 @@ class MainWindow(QMainWindow):
self._btn_play.setText("")
self._song_ended = False
# Hvis demo_then_play: start sangen automatisk når demo er færdig
if getattr(self, "_countdown_mode", "") == "demo_then_play":
delay = self._settings.get("after_song_delay", 2)
total = self._demo_seconds + self._demo_fade_seconds + delay
self._demo_then_play_pending = True
QTimer.singleShot(total * 1000, self._auto_play_after_demo)
def _auto_play_after_demo(self):
"""Start sangen efter demo er færdig (bruges af demo_then_play)."""
self._demo_then_play_pending = False
self._song_ended = False
self._player.stop()
self._demo_active = False
self._btn_demo.setChecked(False)
self._playlist_panel.set_current(self._current_idx)
self._player.play()
self._btn_play.setText("")
def _auto_play_next(self):
"""Start næste sang automatisk."""
if not getattr(self, "_waiting_for_auto", False):