From 441a6b76dc6f7886091e0a5dc4dd1e1dadf8c05a Mon Sep 17 00:00:00 2001 From: felix920506 Date: Fri, 20 Sep 2024 16:43:15 -0400 Subject: [PATCH 1/4] Read first segment from source before starting playback --- discord/player.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/discord/player.py b/discord/player.py index b76fe7b366..2f27725d28 100644 --- a/discord/player.py +++ b/discord/player.py @@ -717,6 +717,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() @@ -740,7 +743,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() From bfe032120d5979f3d72eb38532b4882895afca33 Mon Sep 17 00:00:00 2001 From: felix920506 Date: Fri, 20 Sep 2024 17:29:08 -0400 Subject: [PATCH 2/4] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd4df136c6..1ba7758791 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,8 @@ These changes are available on the `master` branch, but have not yet been releas - Fixed `Enum` options not setting the correct type when only one choice is available. ([#2577](https://github.com/Pycord-Development/pycord/pull/2577)) +- Fixed audio playing back in fast forward for the first few seconds sometimes. + ([#2584](https://github.com/Pycord-Development/pycord/pull/2584)) ### Changed From 5b912d8fdbd6bd442e8905edcdcdfa66e0d11866 Mon Sep 17 00:00:00 2001 From: felix920506 Date: Sat, 21 Sep 2024 16:04:16 -0400 Subject: [PATCH 3/4] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea88bead28..4cf0d85d6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,7 +29,7 @@ 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 audio playing back in fast forward for the first few seconds sometimes. +- Fixed audio plays in fast forward at beginning of audio files. ([#2584](https://github.com/Pycord-Development/pycord/pull/2584)) ### Changed From e07fd8f8bd02638e5fffedd4a5ce84512f788350 Mon Sep 17 00:00:00 2001 From: Lala Sabathil Date: Sun, 22 Sep 2024 00:23:24 +0200 Subject: [PATCH 4/4] Update CHANGELOG.md Signed-off-by: Lala Sabathil --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cf0d85d6f..4f74299ba1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,7 +29,7 @@ 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 audio plays in fast forward at beginning of audio files. +- 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