forked from platypush/platypush
[media.mpv] Better synchronization on player stop/idle events.
This commit is contained in:
parent
5fac324b43
commit
8feee6ce39
1 changed files with 7 additions and 9 deletions
|
@ -152,15 +152,10 @@ class MediaMpvPlugin(MediaPlugin):
|
||||||
self._post_event(NewPlayingMediaEvent)
|
self._post_event(NewPlayingMediaEvent)
|
||||||
elif event_id == 21: # PLAYBACK_RESTART
|
elif event_id == 21: # PLAYBACK_RESTART
|
||||||
self._post_event(MediaPlayEvent)
|
self._post_event(MediaPlayEvent)
|
||||||
elif event_id in {1, 7, 11}: # SHUTDOWN, EOF, IDLE
|
elif event_id in {7, 11} and self._cur_player: # EOF, IDLE
|
||||||
|
self._cur_player.quit(code=0)
|
||||||
|
elif event_id == 1: # SHUTDOWN
|
||||||
self._post_event(MediaStopEvent)
|
self._post_event(MediaStopEvent)
|
||||||
if self._player:
|
|
||||||
try:
|
|
||||||
self._player.terminate()
|
|
||||||
except Exception as e:
|
|
||||||
self.logger.debug(
|
|
||||||
'Error terminating mpv instance: %s', e, exc_info=True
|
|
||||||
)
|
|
||||||
self._player = None
|
self._player = None
|
||||||
elif event_id == 20 and self._cur_player: # SEEK
|
elif event_id == 20 and self._cur_player: # SEEK
|
||||||
self._post_event(
|
self._post_event(
|
||||||
|
@ -257,8 +252,11 @@ class MediaMpvPlugin(MediaPlugin):
|
||||||
|
|
||||||
player.stop()
|
player.stop()
|
||||||
player.quit(code=0)
|
player.quit(code=0)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
player.wait_for_shutdown(timeout=10)
|
player.wait_for_shutdown(timeout=5)
|
||||||
|
except TimeoutError:
|
||||||
|
self.logger.warning('Timeout while waiting for mpv to shutdown')
|
||||||
except TypeError:
|
except TypeError:
|
||||||
# Older versions of python-mpv don't support the timeout argument
|
# Older versions of python-mpv don't support the timeout argument
|
||||||
player.wait_for_shutdown()
|
player.wait_for_shutdown()
|
||||||
|
|
Loading…
Reference in a new issue