From 759b9701c379997cc37d1c128a83302863e7df4f Mon Sep 17 00:00:00 2001 From: jaseg Date: Thu, 16 Jul 2020 19:28:33 +0200 Subject: mpv.py: add wait_until_paused, wait_until_playing --- mpv.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'mpv.py') diff --git a/mpv.py b/mpv.py index 768a95f..dd2a611 100644 --- a/mpv.py +++ b/mpv.py @@ -886,6 +886,14 @@ class MPV(object): with self._playback_cond: self._playback_cond.wait() + def wait_until_paused(self): + """Waits until playback of the current title is paused or done.""" + self.wait_for_property('core-idle') + + def wait_until_playing(self): + """Waits until playback of the current title has started.""" + self.wait_for_property('core-idle', lambda idle: not idle) + def wait_for_property(self, name, cond=lambda val: val, level_sensitive=True): """Waits until ``cond`` evaluates to a truthy value on the named property. This can be used to wait for properties such as ``idle_active`` indicating the player is done with regular playback and just idling around -- cgit