Interface AudioProvider
public interface AudioProvider
Interface for providing audio data to Discord voice connections.
Plugins implementing audio playback functionality should implement this interface.
Audio data must be in Opus format for Discord compatibility.
-
Method Details
-
canProvide
boolean canProvide()Check if there is audio data available to send. This is called before provide20MsAudio() to avoid unnecessary processing.- Returns:
- true if audio data can be provided
-
provide20MsAudio
byte[] provide20MsAudio()Provide 20ms of audio data. This method is called roughly every 20ms when audio is being sent.The returned byte array should contain Opus-encoded audio data.
- Returns:
- Opus-encoded audio data, or null if no data is available
-
isOpus
default boolean isOpus()Check if the audio data is already Opus encoded. If false, JDA will attempt to encode the audio.- Returns:
- true if the data from provide20MsAudio() is Opus-encoded
-
close
default void close()Called when the audio provider is being closed. Clean up any resources here.
-