Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.

Commit

Permalink
Fix skip bug
Browse files Browse the repository at this point in the history
  • Loading branch information
kijk2869 committed Jan 2, 2021
1 parent 15f6bca commit 24d374f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
6 changes: 3 additions & 3 deletions discodo/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)

Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down
16 changes: 16 additions & 0 deletions discodo/source/AudioSource.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}

Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion discodo/voice_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down

0 comments on commit 24d374f

Please sign in to comment.