home · contact · privacy
Reduce reliance on mpv.py conveniences for raw libmpv command access.
authorChristian Heller <c.heller@plomlompom.de>
Thu, 28 Nov 2024 13:57:36 +0000 (14:57 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Thu, 28 Nov 2024 13:57:36 +0000 (14:57 +0100)
src/ytplom/misc.py

index 59a9a934983f67107ad582a4a4a4cd6e2cace157..b207d4903abcb5fb60c96a36f5843a96e67a4de2 100644 (file)
@@ -515,8 +515,8 @@ class Player:
             self._signal_update()
 
         for path in [f.full_path for f in self._files]:
-            self._mpv.playlist_append(path)
-        self._mpv.playlist_play_index(self._idx)
+            self._mpv.command('loadfile', path, 'append')
+        self._mpv.command('playlist-play-index', self._idx)
 
     @_if_mpv_available
     def _kill_mpv(self) -> None:
@@ -574,19 +574,19 @@ class Player:
         """Move player to previous item in playlist."""
         assert self._mpv is not None
         if self._mpv.playlist_pos > 0:
-            self._mpv.playlist_prev()
+            self._mpv.command('playlist-prev')
         else:
-            self._mpv.playlist_play_index(0)
+            self._mpv.command('playlist-play-index', 0)
 
     @_if_mpv_available
     def next(self) -> None:
         """Move player to next item in playlist."""
         assert self._mpv is not None
-        max_idx: int = len(self._mpv.playlist_filenames) - 1
-        if self._mpv.playlist_pos < len(self._mpv.playlist_filenames) - 1:
-            self._mpv.playlist_next()
+        max_idx = len(self._mpv.playlist) - 1
+        if self._mpv.playlist_pos < max_idx:
+            self._mpv.command('playlist-next')
         else:
-            self._mpv.playlist_play_index(max_idx)
+            self._mpv.command('playlist-play-index', max_idx)
 
     def reload(self) -> None:
         """Close MPV, re-read (and re-shuffle) filenames, then re-start MPV."""