Package org.javacord.api.audio
Interface AudioSource
-
- All Superinterfaces:
AudioSourceAttachableListenerManager,Specializable<AudioSource>
- All Known Subinterfaces:
AudioSourceBaseDelegate,BufferableAudioSource,DownloadableAudioSource,PauseableAudioSource,SeekableAudioSource
- All Known Implementing Classes:
AudioSourceBase,SilentAudioSource
public interface AudioSource extends AudioSourceAttachableListenerManager, Specializable<AudioSource>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidaddTransformer(AudioTransformer transformer)Adds a transformer to the audio source.default Optional<BufferableAudioSource>asBufferableAudioSource()Gets this audio source as aBufferableAudioSource.default Optional<DownloadableAudioSource>asDownloadableAudioSource()Gets this audio source as aDownloadableAudioSource.default Optional<PauseableAudioSource>asPauseableAudioSource()Gets this audio source as aPauseableAudioSource.default Optional<SeekableAudioSource>asSeekableAudioSource()Gets this audio source as aSeekableAudioSource.AudioSourcecopy()Creates a copy of the audio source that can be reused for another audio connection.DiscordApigetApi()Gets the discord api instance for this audio source.byte[]getNextFrame()Polls for the next 20ms of audio from the source.List<AudioTransformer>getTransformers()Gets a list of all transformers of this audio source.booleanhasFinished()Checks whether the audio source has finished and can be dequeued.booleanhasNextFrame()Checks whether there is 20ms of audio available to be polled.booleanisMuted()Checks whether the audio source is muted.default voidmute()Mutes the audio source.booleanremoveTransformer(AudioTransformer transformer)Removes a transformer from the audio source.voidremoveTransformers()Removes all transformers from the audio source.voidsetMuted(boolean muted)Sets whether the audio source should be muted.default voidunmute()Unmutes the audio source.-
Methods inherited from interface org.javacord.api.listener.audio.AudioSourceAttachableListenerManager
addAudioSourceAttachableListener, addAudioSourceFinishedListener, getAudioSourceAttachableListeners, getAudioSourceFinishedListeners, removeAudioSourceAttachableListener, removeListener
-
Methods inherited from interface org.javacord.api.util.Specializable
as
-
-
-
-
Method Detail
-
getApi
DiscordApi getApi()
Gets the discord api instance for this audio source.- Returns:
- The discord api instance.
-
addTransformer
void addTransformer(AudioTransformer transformer)
Adds a transformer to the audio source.- Parameters:
transformer- The transformer.
-
removeTransformer
boolean removeTransformer(AudioTransformer transformer)
Removes a transformer from the audio source.- Parameters:
transformer- The transformer.- Returns:
- If the audio source contained the specified transformer.
-
getTransformers
List<AudioTransformer> getTransformers()
Gets a list of all transformers of this audio source.- Returns:
- A list with all transformers.
-
removeTransformers
void removeTransformers()
Removes all transformers from the audio source.
-
getNextFrame
byte[] getNextFrame()
Polls for the next 20ms of audio from the source.- Returns:
- A byte array containing 20ms of audio, or null if
hasNextFrame()is false.
-
hasNextFrame
boolean hasNextFrame()
Checks whether there is 20ms of audio available to be polled.If there is no frame available, but the source has not been finished, it will play a silent sound instead.
- Returns:
- Whether or not there is a frame available to be polled.
-
hasFinished
boolean hasFinished()
Checks whether the audio source has finished and can be dequeued.This should not be confused with
hasNextFrame()which only indicated if there is a frame available right now. An audio source might have no frame available, but is still not finished, e.g. because it's streaming something but downloads it too slowly.- Returns:
- Whether the audio source has finished and can be dequeued.
-
mute
default void mute()
Mutes the audio source.Equivalent to calling
setMuted(true).- See Also:
setMuted(boolean)
-
unmute
default void unmute()
Unmutes the audio source.Equivalent to calling
setMuted(false).- See Also:
setMuted(boolean)
-
setMuted
void setMuted(boolean muted)
Sets whether the audio source should be muted.A muted audio source will still continue. This means, that after unmuting the audio source will be at a different "position".
- Parameters:
muted- Whether the audio source should be muted.
-
isMuted
boolean isMuted()
Checks whether the audio source is muted.- Returns:
- Whether the audio source is muted.
-
copy
AudioSource copy()
Creates a copy of the audio source that can be reused for another audio connection.Does not copy the state of the audio source, e.g. if it is muted, it's transformers, etc.
- Returns:
- A copy of the audio source.
-
asPauseableAudioSource
default Optional<PauseableAudioSource> asPauseableAudioSource()
Gets this audio source as aPauseableAudioSource.- Returns:
- This audio source as
PauseableAudioSource.
-
asDownloadableAudioSource
default Optional<DownloadableAudioSource> asDownloadableAudioSource()
Gets this audio source as aDownloadableAudioSource.- Returns:
- This audio source as
DownloadableAudioSource.
-
asBufferableAudioSource
default Optional<BufferableAudioSource> asBufferableAudioSource()
Gets this audio source as aBufferableAudioSource.- Returns:
- This audio source as
BufferableAudioSource.
-
asSeekableAudioSource
default Optional<SeekableAudioSource> asSeekableAudioSource()
Gets this audio source as aSeekableAudioSource.- Returns:
- This audio source as
SeekableAudioSource.
-
-