use current.original in internal logic

This commit is contained in:
vveeps 2021-11-07 14:34:09 +02:00
parent 81bf0b9756
commit d396ac44f1
1 changed files with 7 additions and 6 deletions

View File

@ -66,25 +66,26 @@ class Player(VoiceProtocol):
@property @property
def position(self) -> float: def position(self) -> float:
"""Property which returns the player's position in a track in milliseconds""" """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 return 0
if self.is_paused: 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 difference = (time.time() * 1000) - self._last_update
position = self._last_position + difference position = self._last_position + difference
if position > self.current.length: if position > current.length:
return 0 return 0
return min(position, self.current.length) return min(position, current.length)
@property @property
def is_playing(self) -> bool: def is_playing(self) -> bool:
"""Property which returns whether or not the player is actively playing a track.""" """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 @property
def is_connected(self) -> bool: def is_connected(self) -> bool:
@ -271,7 +272,7 @@ class Player(VoiceProtocol):
async def seek(self, position: float) -> float: async def seek(self, position: float) -> float:
"""Seeks to a position in the currently playing track milliseconds""" """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( raise TrackInvalidPosition(
f"Seek position must be between 0 and the track length" f"Seek position must be between 0 and the track length"
) )