Interface AudioSource

    • 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 a PauseableAudioSource.
        Returns:
        This audio source as PauseableAudioSource.
      • asDownloadableAudioSource

        default java.util.Optional<DownloadableAudioSource> asDownloadableAudioSource()
        Gets this audio source as a DownloadableAudioSource.
        Returns:
        This audio source as DownloadableAudioSource.
      • asBufferableAudioSource

        default java.util.Optional<BufferableAudioSource> asBufferableAudioSource()
        Gets this audio source as a BufferableAudioSource.
        Returns:
        This audio source as BufferableAudioSource.
      • asSeekableAudioSource

        default java.util.Optional<SeekableAudioSource> asSeekableAudioSource()
        Gets this audio source as a SeekableAudioSource.
        Returns:
        This audio source as SeekableAudioSource.