Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ These changes are available on the `master` branch, but have not yet been releas
([#2577](https://github.com/Pycord-Development/pycord/pull/2577))
- Fixed `codec` option for `FFmpegOpusAudio` class to make it in line with
documentation. ([#2581](https://github.com/Pycord-Development/pycord/pull/2581))
- Fixed a possible bug where audio would play too fast at the beginning of audio files.
([#2584](https://github.com/Pycord-Development/pycord/pull/2584))

### Changed

Expand Down
11 changes: 10 additions & 1 deletion discord/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,9 @@ def __init__(self, source: AudioSource, client: VoiceClient, *, after=None):
raise TypeError('Expected a callable for the "after" parameter.')

def _do_run(self) -> None:
# attempt to read first audio segment from source before starting
# some sources can take a few seconds and may cause problems
first_data = self.source.read()
self.loops = 0
self._start = time.perf_counter()

Expand All @@ -752,7 +755,13 @@ def _do_run(self) -> None:
self._start = time.perf_counter()

self.loops += 1
data = self.source.read()
# Send the data read from the start of the function if it is not None
if first_data is not None:
data = first_data
first_data = None
# Else read the next bit from the source
else:
data = self.source.read()

if not data:
self.stop()
Expand Down