From 3252392eb5c68bc05d12297a7ca33418cb5372ee Mon Sep 17 00:00:00 2001 From: j Date: Wed, 8 Nov 2023 11:01:02 +0100 Subject: [PATCH] reset player if stuck --- player/player.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/player/player.py b/player/player.py index 3ebb87c..497478f 100755 --- a/player/player.py +++ b/player/player.py @@ -35,6 +35,7 @@ class Sync(Thread): destination = "255.255.255.255" reload_check = None _pos = None + _tick = 0 def __init__(self, *args, **kwargs): self.is_main = kwargs.get('mode', 'main') == 'main' @@ -66,7 +67,6 @@ class Sync(Thread): self.sync_to_main() self.ready = True Thread.__init__(self) - self.daemon = True self.start() def run(self): @@ -77,6 +77,13 @@ class Sync(Thread): self.read_position_main() #self.adjust_position() self.reload_playlist() + if self._tick and abs(time.time() - self._tick) > 10: + logger.error("player is stuck") + self._tick = 0 + self.mpv.loadlist(self.playlist) + self.mpv.playlist_play_index(0) + self.mpv.pause = False + self.mpv.wait_until_playing() def q_binding(self, *args): self.stop() @@ -89,6 +96,7 @@ class Sync(Thread): self.sock = None def time_pos_cb(self, pos, *args, **kwargs): + self._tick = time.time() if self.is_main: self.send_position_local() elif self.ready: