From: Christian Heller Date: Thu, 5 Dec 2024 04:37:37 +0000 (+0100) Subject: Immediately start player after loading files. X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/decks/%7B%7Bprefix%7D%7D/add_free?a=commitdiff_plain;h=072a6fdd483d3aac70a62da73f9880a63cbb5b83;p=ytplom Immediately start player after loading files. --- diff --git a/src/ytplom/http.py b/src/ytplom/http.py index 6d7a085..2b85490 100644 --- a/src/ytplom/http.py +++ b/src/ytplom/http.py @@ -344,7 +344,7 @@ class _TaskHandler(BaseHTTPRequestHandler): filter_path = FilterStr(params.single_value('filter_path')) filter_tags = FilterStr(params.single_value('filter_tags')) if self.server.player.empty or filter_path or filter_tags: - self.server.player.load_files(filter_path, filter_tags) + self.server.player.load_files_and_start(filter_path, filter_tags) current_file, unused_tags = None, set() with DbConn() as conn: if self.server.player.current_file_digest: diff --git a/src/ytplom/misc.py b/src/ytplom/misc.py index a4021e2..45299bf 100644 --- a/src/ytplom/misc.py +++ b/src/ytplom/misc.py @@ -409,10 +409,10 @@ class Player: def __init__(self) -> None: self.last_update = PlayerUpdateId('') - self.load_files() self._mpv: Optional[MPV] = None self._kill_queue: Queue = Queue() self._monitoring_kill = False + self.load_files_and_start() def _monitor_kill(self) -> None: """Properly enforce mpv shutdown from direct interaction with mpv @@ -434,11 +434,11 @@ class Player: Thread(target=kill_on_queue_get, daemon=True).start() - def load_files(self, - filter_path: FilterStr = FilterStr(''), - filter_tags: FilterStr = FilterStr('') - ) -> None: - """Collect files in PATH_DOWNLOADS DB-known and of legal extension.""" + def load_files_and_start(self, + filter_path: FilterStr = FilterStr(''), + filter_tags: FilterStr = FilterStr('') + ) -> None: + """Collect filtered files into playlist, start player.""" with DbConn() as conn: known_files = { f.full_path: f for f @@ -449,6 +449,7 @@ class Player: and p.suffix[1:] in LEGAL_EXTENSIONS] shuffle(self.files) self._idx = 0 + self._start_mpv() def _signal_update(self) -> None: self.last_update = PlayerUpdateId(f'{self._idx}:{time()}')