From: Christian Heller Date: Tue, 17 Dec 2024 00:29:34 +0000 (+0100) Subject: Restart playlist after ending of last file. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/%7B%7B%20web_path%20%7D%7D/%7B%7Bdb.prefix%7D%7D/%7B%7Bprefix%7D%7D?a=commitdiff_plain;h=8af6e6b1b45835c20cb3040855b753664c882d8f;p=ytplom Restart playlist after ending of last file. --- diff --git a/src/ytplom/misc.py b/src/ytplom/misc.py index 3a0be6d..81406d0 100644 --- a/src/ytplom/misc.py +++ b/src/ytplom/misc.py @@ -568,6 +568,7 @@ class Player: - build MPV's internal playlist from .playlist - bind starting of files to ._signal_update and setting ._idx to MPV's own playlist position index + - bind ending last file to re-starting at playlist start - start playing """ self._mpv = MPV(input_default_bindings=True, @@ -582,6 +583,13 @@ class Player: self._idx = self._mpv.playlist_pos self._signal_update() + @self._mpv.event_callback('end-file') + def on_end_file(event) -> None: + if (b'eof' == event.as_dict()['reason'] + and self._idx + 1 == len(self.playlist)): + self._idx = 0 + self._play_at_index() + @self._mpv.event_callback('shutdown') def on_shutdown(_) -> None: self._kill_queue.put(True)