From: Christian Heller Date: Thu, 28 Nov 2024 13:57:36 +0000 (+0100) Subject: Reduce reliance on mpv.py conveniences for raw libmpv command access. X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/%7B%7B%20web_path%20%7D%7D/static/todo?a=commitdiff_plain;h=3bab1ac8960e3d864681bf9633b78d3e6dc45aab;p=ytplom Reduce reliance on mpv.py conveniences for raw libmpv command access. --- diff --git a/src/ytplom/misc.py b/src/ytplom/misc.py index 59a9a93..b207d49 100644 --- a/src/ytplom/misc.py +++ b/src/ytplom/misc.py @@ -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."""