home · contact · privacy
Immediately start player after loading files. master
authorChristian Heller <c.heller@plomlompom.de>
Thu, 5 Dec 2024 04:37:37 +0000 (05:37 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Thu, 5 Dec 2024 04:37:37 +0000 (05:37 +0100)
src/ytplom/http.py
src/ytplom/misc.py

index 6d7a085626623a5ceba42678d03490dac28a9292..2b85490cafba259153d640bda24ea4efeeb8c843 100644 (file)
@@ -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:
index a4021e2fda3fa2e2f23236ce7918a02a449a4519..45299bf13d550c75fcce55b676c26bb6e7f1ab85 100644 (file)
@@ -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()}')