From eea27c5f8c64d1403e85b3bde38bd3017d6d526b Mon Sep 17 00:00:00 2001 From: j Date: Sun, 5 Nov 2023 09:26:02 +0100 Subject: [PATCH] don't crash just skip adjustment if player is still loading --- player/player.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/player/player.py b/player/player.py index be06cf7..f53795f 100755 --- a/player/player.py +++ b/player/player.py @@ -142,7 +142,10 @@ class Sync(Thread): def adjust_position(self): if self.mpv.time_pos is not None: - deviation = self.main.time_pos - self.mpv.time_pos + try: + deviation = self.main.time_pos - self.mpv.time_pos + except: + return self.deviations.append(deviation) median_deviation = self.median(list(self.deviations)) frames = deviation / 0.04 @@ -163,7 +166,7 @@ class Sync(Thread): if self.main.playlist_current_pos != self.mpv.playlist_current_pos: self.mpv.playlist_play_index(self.main.playlist_current_pos) self.mpv.pause = False - time.sleep(0.1) + self.mpv.wait_until_playing() self.mpv.pause = True pos = self.main.time_pos + SYNC_JUMP_AHEAD #print(pos, self.mpv.playlist_current_pos, self.mpv.time_pos)