reset player if stuck

This commit is contained in:
j 2023-11-08 11:01:02 +01:00
parent 7e4c062a13
commit 3252392eb5

View file

@ -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: