don't reset player if its paused

This commit is contained in:
j 2024-04-04 23:24:56 +01:00
parent 569c72ee8b
commit 3c9f200fdd

View file

@ -51,6 +51,7 @@ class Main:
class Sync(Thread): class Sync(Thread):
active = True active = True
is_main = True is_main = True
is_paused = False
ready = False ready = False
destination = "255.255.255.255" destination = "255.255.255.255"
reload_check = None reload_check = None
@ -158,7 +159,7 @@ class Sync(Thread):
else: else:
self.read_position_main() self.read_position_main()
self.reload_playlist() self.reload_playlist()
if self._tick and abs(time.time() - self._tick) > 60: if not self.is_paused and self._tick and abs(time.time() - self._tick) > 60:
logger.error("player is stuck") logger.error("player is stuck")
self._tick = 0 self._tick = 0
self.stop() self.stop()
@ -181,6 +182,7 @@ class Sync(Thread):
def s_binding(self, *args): def s_binding(self, *args):
if args[0] != 'd-': if args[0] != 'd-':
return return
self.is_paused = True
self.mpv.pause = True self.mpv.pause = True
if self.sax: if self.sax:
self.sax.pause = True self.sax.pause = True
@ -189,6 +191,7 @@ class Sync(Thread):
def p_binding(self, *args): def p_binding(self, *args):
if args[0] != 'd-': if args[0] != 'd-':
return return
self.is_paused = False
self.mpv.pause = False self.mpv.pause = False
if self.sax: if self.sax:
self.sax.pause = False self.sax.pause = False
@ -305,8 +308,10 @@ class Sync(Thread):
else: else:
self._last_ping = data[0] self._last_ping = data[0]
if data[0] == "pause": if data[0] == "pause":
self.is_paused = True
self.mpv.pause = True self.mpv.pause = True
elif data[0] == "play": elif data[0] == "play":
self.is_paused = False
self.mpv.pause = False self.mpv.pause = False
else: else:
self.main.time_pos = float(data[0]) self.main.time_pos = float(data[0])