diff --git a/discodo/player.py b/discodo/player.py index 6bd38270..cc4762fa 100644 --- a/discodo/player.py +++ b/discodo/player.py @@ -82,7 +82,7 @@ def current(self, _: None) -> None: def next(self) -> AudioSource: is_load_condition = ( not self._current - or self._current.stopped + or self._current.skipped or self._current.remain <= (Config.PRELOAD_TIME + self.crossfade) ) @@ -188,7 +188,7 @@ def read(self) -> bytes: is_live = self.current.AudioData and self.current.AudioData.is_live is_crossfade_timing = self.next and ( - self.current.remain <= self.crossfade or self.current.stopped + self.current.remain <= self.crossfade or self.current.skipped ) if is_crossfade_timing and not is_live and self.next.AudioFifo.samples >= 960: @@ -204,7 +204,7 @@ def read(self) -> bytes: elif self.next: self.next.volume = 1.0 - if not self.next and self.current.stopped and not self.client.Queue: + if not self.next and self.current.skipped and not self.client.Queue: if self.current.volume > 0.0: self.current.volume = round(self.current.volume - 0.01, 3) elif not is_crossfade_timing: diff --git a/discodo/source/AudioSource.py b/discodo/source/AudioSource.py index d25ac0f2..dcef4a7c 100644 --- a/discodo/source/AudioSource.py +++ b/discodo/source/AudioSource.py @@ -11,6 +11,8 @@ def __init__(self, *args, AudioData=None, **kwargs) -> None: self.AudioData = AudioData self.address = self.AudioData.address if self.AudioData else None + self._skipped: bool = False + def __dict__(self) -> dict: Value = self.AudioData.__dict__() if self.AudioData else {} @@ -60,3 +62,17 @@ def filter(self, value: dict) -> dict: raise ValueError("Cannot use `atempo` filter in live streaming.") self._filter = value + + @property + def skipped(self) -> bool: + return self._skipped + + @skipped.setter + def skipped(self, Value: bool) -> None: + if Value: + self.stop() + + self._skipped = Value + + def skip(self) -> None: + self.skipped = True diff --git a/discodo/voice_client.py b/discodo/voice_client.py index 1154f333..b81f846c 100644 --- a/discodo/voice_client.py +++ b/discodo/voice_client.py @@ -318,7 +318,7 @@ def skip(self, offset: int = 1) -> None: if offset > 1: del self.Queue[0 : (offset - 1)] - self.player.current.stop() + self.player.current.skip() def pause(self) -> bool: """