diff options
Diffstat (limited to 'discord/voice_client.py')
| -rw-r--r-- | discord/voice_client.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/discord/voice_client.py b/discord/voice_client.py index b014de53..4b679158 100644 --- a/discord/voice_client.py +++ b/discord/voice_client.py @@ -68,11 +68,10 @@ class VoiceClient: Warning -------- - In order to play audio, you must have loaded the opus library - through :func:`opus.load_opus`. - - If you don't do this then the library will not be able to - transmit audio. + In order to use PCM based AudioSources, you must have the opus library + installed on your system and loaded through :func:`opus.load_opus`. + Otherwise, your AudioSources must be opus encoded (e.g. using :class:`FFmpegOpusAudio`) + or the library will not be able to transmit audio. Attributes ----------- @@ -111,7 +110,7 @@ class VoiceClient: self.timestamp = 0 self._runner = None self._player = None - self.encoder = opus.Encoder() + self.encoder = None warn_nacl = not has_nacl supported_modes = ( @@ -356,7 +355,9 @@ class VoiceClient: ClientException Already playing audio or not connected. TypeError - source is not a :class:`AudioSource` or after is not a callable. + Source is not a :class:`AudioSource` or after is not a callable. + OpusNotLoaded + Source is not opus encoded and opus is not loaded. """ if not self.is_connected(): @@ -368,6 +369,9 @@ class VoiceClient: if not isinstance(source, AudioSource): raise TypeError('source must an AudioSource not {0.__class__.__name__}'.format(source)) + if not self.encoder and not source.is_opus(): + self.encoder = opus.Encoder() + self._player = AudioPlayer(source, self, after=after) self._player.start() @@ -444,4 +448,4 @@ class VoiceClient: except BlockingIOError: log.warning('A packet has been dropped (seq: %s, timestamp: %s)', self.sequence, self.timestamp) - self.checked_add('timestamp', self.encoder.SAMPLES_PER_FRAME, 4294967295) + self.checked_add('timestamp', opus.Encoder.SAMPLES_PER_FRAME, 4294967295) |