avoid recursion
This commit is contained in:
parent
e221626191
commit
45e2acbbb8
1 changed files with 25 additions and 21 deletions
|
@ -302,30 +302,34 @@ class Sync(Thread):
|
||||||
|
|
||||||
def read_position_main(self):
|
def read_position_main(self):
|
||||||
self.sock.settimeout(5)
|
self.sock.settimeout(5)
|
||||||
try:
|
while True:
|
||||||
data = self.sock.recvfrom(1024)[0].decode().split(" ", 1)
|
try:
|
||||||
except socket.timeout:
|
data = self.sock.recvfrom(1024)[0].decode().split(" ", 1)
|
||||||
if self._last_ping != "pause":
|
except socket.timeout:
|
||||||
logger.error("failed to receive data from main")
|
if self._last_ping != "pause":
|
||||||
except OSError:
|
logger.error("failed to receive data from main")
|
||||||
logger.error("socket closed")
|
return
|
||||||
else:
|
except OSError:
|
||||||
|
logger.error("socket closed")
|
||||||
|
return
|
||||||
if CONFIG.get("sync_group"):
|
if CONFIG.get("sync_group"):
|
||||||
if data[0] != str(CONFIG["sync_group"]):
|
if data[0] == str(CONFIG["sync_group"]):
|
||||||
return self.read_position_main()
|
|
||||||
else:
|
|
||||||
data = data[1:]
|
data = data[1:]
|
||||||
self._last_ping = data[0]
|
break
|
||||||
if data[0] == "pause":
|
|
||||||
self.is_paused = True
|
|
||||||
self.mpv.pause = True
|
|
||||||
elif data[0] == "play":
|
|
||||||
self.is_paused = False
|
|
||||||
self._tick = 0
|
|
||||||
self.mpv.pause = False
|
|
||||||
else:
|
else:
|
||||||
self.main.time_pos = float(data[0])
|
break
|
||||||
self.main.playlist_current_pos = int(data[1])
|
|
||||||
|
self._last_ping = data[0]
|
||||||
|
if data[0] == "pause":
|
||||||
|
self.is_paused = True
|
||||||
|
self.mpv.pause = True
|
||||||
|
elif data[0] == "play":
|
||||||
|
self.is_paused = False
|
||||||
|
self._tick = 0
|
||||||
|
self.mpv.pause = False
|
||||||
|
else:
|
||||||
|
self.main.time_pos = float(data[0])
|
||||||
|
self.main.playlist_current_pos = int(data[1])
|
||||||
|
|
||||||
def adjust_position(self):
|
def adjust_position(self):
|
||||||
if self.mpv.time_pos is not None:
|
if self.mpv.time_pos is not None:
|
||||||
|
|
Loading…
Reference in a new issue