From 150880028b8d546119e727d4fa07ab6fedc46c02 Mon Sep 17 00:00:00 2001 From: Matthew Stratford Date: Sat, 24 Apr 2021 19:32:43 +0100 Subject: [PATCH] Fix seek/cue point jumping. --- player.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/player.py b/player.py index c2724a8..10b23e3 100644 --- a/player.py +++ b/player.py @@ -226,9 +226,7 @@ class Player: self.seek(self.state.get()["loaded_item"].cue) else: # Otherwise, let's go to 0. - self.state.update("pos", 0) - self.state.update("pos_offset", 0) - self.state.update("pos_true", 0) + self.seek(0) return True @@ -242,7 +240,8 @@ class Player: return True else: self.stopped_manually = True # Don't trigger _ended() on seeking. - self.state.update("paused", True) + if pos > 0: + self.state.update("paused", True) self._updateState(pos=pos) return True @@ -605,15 +604,14 @@ class Player: self.state.update("initialised", self.isInit) if self.isInit: - if pos: - self.state.update("pos", max(0, pos)) + if pos is not None: + #self.state.update("pos_true", max(0, pos)) + self.state.update("pos", pos) # Reset back to 0 if stopped. + self.state.update("pos_offset", 0) elif self.isPlaying: + # This is the bit that makes the time actually progress during playback. # Get one last update in, incase we're about to pause/stop it. self.state.update("pos", max(0, mixer.music.get_pos() / 1000)) - # TODO this is wrong now we don't pause the mixer. - elif not self.isPaused: - self.state.update("pos", 0) # Reset back to 0 if stopped. - self.state.update("pos_offset", 0) # If the state is changing from playing to not playing, and the user didn't stop it, the item must have ended. if (