Class AudioPlayerInputStream
- java.lang.Object
-
- java.io.InputStream
-
- com.sedmelluq.discord.lavaplayer.format.AudioPlayerInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class AudioPlayerInputStream extends java.io.InputStreamProvides an audio player as an input stream. When nothing is playing, it returns silence instead of blocking.
-
-
Constructor Summary
Constructors Constructor Description AudioPlayerInputStream(AudioDataFormat format, AudioPlayer player, long timeout, boolean provideSilence)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()voidclose()static javax.sound.sampled.AudioInputStreamcreateStream(AudioPlayer player, AudioDataFormat format, long stuckTimeout, boolean provideSilence)Create an instance of AudioInputStream using an AudioPlayer as a source.intread()intread(byte[] buffer, int offset, int length)
-
-
-
Constructor Detail
-
AudioPlayerInputStream
public AudioPlayerInputStream(AudioDataFormat format, AudioPlayer player, long timeout, boolean provideSilence)
- Parameters:
format- Format of the frames expected from the playerplayer- The player to read frames fromtimeout- Timeout till track stuck event is sent. Each time a new frame is required from the player, it asks for a frame with the specified timeout. In case that timeout is reached, the track stuck event is sent and if providing silence is enabled, silence is provided as the next frame.provideSilence- True if the stream should return silence instead of blocking in case nothing is playing or read times out.
-
-
Method Detail
-
read
public int read() throws java.io.IOException- Specified by:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
read
public int read(byte[] buffer, int offset, int length) throws java.io.IOException- Overrides:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
available
public int available() throws java.io.IOException- Overrides:
availablein classjava.io.InputStream- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.InputStream- Throws:
java.io.IOException
-
createStream
public static javax.sound.sampled.AudioInputStream createStream(AudioPlayer player, AudioDataFormat format, long stuckTimeout, boolean provideSilence)
Create an instance of AudioInputStream using an AudioPlayer as a source.- Parameters:
player- Format of the frames expected from the playerformat- The player to read frames fromstuckTimeout- Timeout till track stuck event is sent and silence is returned on readingprovideSilence- Returns true if the stream should provide silence if no track is being played or when getting track frames times out.- Returns:
- An audio input stream usable with JDK sound system
-
-