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 void
addTransformer(AudioTransformer transformer)
Adds a transformer to the audio source.default java.util.Optional<BufferableAudioSource>
asBufferableAudioSource()
Gets this audio source as aBufferableAudioSource
.default java.util.Optional<DownloadableAudioSource>
asDownloadableAudioSource()
Gets this audio source as aDownloadableAudioSource
.default java.util.Optional<PauseableAudioSource>
asPauseableAudioSource()
Gets this audio source as aPauseableAudioSource
.default java.util.Optional<SeekableAudioSource>
asSeekableAudioSource()
Gets this audio source as aSeekableAudioSource
.AudioSource
copy()
Creates a copy of the audio source that can be reused for another audio connection.DiscordApi
getApi()
Gets the discord api instance for this audio source.byte[]
getNextFrame()
Polls for the next 20ms of audio from the source.java.util.List<AudioTransformer>
getTransformers()
Gets a list of all transformers of this audio source.boolean
hasFinished()
Checks whether the audio source has finished and can be dequeued.boolean
hasNextFrame()
Checks whether there is 20ms of audio available to be polled.boolean
isMuted()
Checks whether the audio source is muted.default void
mute()
Mutes the audio source.boolean
removeTransformer(AudioTransformer transformer)
Removes a transformer from the audio source.void
removeTransformers()
Removes all transformers from the audio source.void
setMuted(boolean muted)
Sets whether the audio source should be muted.default void
unmute()
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
java.util.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 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 java.util.Optional<PauseableAudioSource> asPauseableAudioSource()
Gets this audio source as aPauseableAudioSource
.- Returns:
- This audio source as
PauseableAudioSource
.
-
asDownloadableAudioSource
default java.util.Optional<DownloadableAudioSource> asDownloadableAudioSource()
Gets this audio source as aDownloadableAudioSource
.- Returns:
- This audio source as
DownloadableAudioSource
.
-
asBufferableAudioSource
default java.util.Optional<BufferableAudioSource> asBufferableAudioSource()
Gets this audio source as aBufferableAudioSource
.- Returns:
- This audio source as
BufferableAudioSource
.
-
asSeekableAudioSource
default java.util.Optional<SeekableAudioSource> asSeekableAudioSource()
Gets this audio source as aSeekableAudioSource
.- Returns:
- This audio source as
SeekableAudioSource
.
-
-