Interface BufferableAudioSource

    • Method Detail

      • setBufferSize

        void setBufferSize​(long size,
                           java.util.concurrent.TimeUnit unit)
        Sets the buffer size of the audio source.

        The audio source will pre-download audio frames for the specified buffer size to allow for a smooth playback without stuttering.

        As audio frames always have a fixed 20ms duration, the buffer size will be rounded down to the closest multiple of 20ms. E.g. when calling setBufferSize(79, TimeUnit.MILLISECONDS), the buffer size will instead be set to 60ms.

        Depending on the audio source, it might not be possible to buffer in 20ms accuracy. In this case, it will try to get as close to the actual buffer size as possible.

        Negative buffer sizes will be interpreted as 0.

        Parameters:
        size - The size of the buffer.
        unit - A TimeUnit determining how to interpret the size parameter. As audio frames have a fixed size of 20ms, units bellow TimeUnit.MILLISECONDS are not recommended.
      • getBufferSize

        java.time.Duration getBufferSize()
        Gets the size of the buffer.
        Returns:
        The buffer size of the audio source.
      • getUsedBufferSize

        java.time.Duration getUsedBufferSize()
        Gets the current used size of the buffer.

        Unlike getBufferSize(), this method does not return how much can be buffered, but what's currently buffered.

        Notice, that it's possible, that the used buffer might exceed the allowed buffer size in some cases.

        Returns:
        The used buffer size of the audio source.