From d396ac44f11d542478d5212e060fbef3d462e2bf Mon Sep 17 00:00:00 2001 From: vveeps <54472340+vveeps@users.noreply.github.com> Date: Sun, 7 Nov 2021 14:34:09 +0200 Subject: [PATCH] use current.original in internal logic --- pomice/player.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pomice/player.py b/pomice/player.py index 2ec037e..a042516 100644 --- a/pomice/player.py +++ b/pomice/player.py @@ -66,25 +66,26 @@ class Player(VoiceProtocol): @property def position(self) -> float: """Property which returns the player's position in a track in milliseconds""" + current = self._current.original - if not self.is_playing or not self.current: + if not self.is_playing or not self._current: return 0 if self.is_paused: - return min(self._last_position, self.current.length) + return min(self._last_position, current.length) difference = (time.time() * 1000) - self._last_update position = self._last_position + difference - if position > self.current.length: + if position > current.length: return 0 - return min(position, self.current.length) + return min(position, current.length) @property def is_playing(self) -> bool: """Property which returns whether or not the player is actively playing a track.""" - return self._is_connected and self.current is not None + return self._is_connected and self._current is not None @property def is_connected(self) -> bool: @@ -271,7 +272,7 @@ class Player(VoiceProtocol): async def seek(self, position: float) -> float: """Seeks to a position in the currently playing track milliseconds""" - if position < 0 or position > self.current.length: + if position < 0 or position > self._current.original.length: raise TrackInvalidPosition( f"Seek position must be between 0 and the track length" )