public class URLPlayer extends Player
Modifier and Type | Field and Description |
---|---|
protected JDA |
api |
protected java.io.BufferedInputStream |
bufferedResourceStream |
static int |
DEFAULT_BUFFER_SIZE
The default buffer size.
|
protected boolean |
paused |
protected boolean |
playing |
protected java.io.InputStream |
resourceStream |
protected boolean |
started |
protected boolean |
stopped |
protected java.net.URL |
urlOfResource |
protected java.lang.String |
userAgent |
amplitude, amplitudeAudioStream, audioFormat, audioSource
Constructor and Description |
---|
URLPlayer(JDA api)
Creates a new
URLPlayer . |
URLPlayer(JDA api,
java.net.URL urlOfResource)
Creates a new
URLPlayer with the given URL as resource. |
URLPlayer(JDA api,
java.net.URL urlOfResource,
int bufferSize)
Creates a new
URLPlayer with the given URL as resource and a buffer with the given size. |
Modifier and Type | Method and Description |
---|---|
boolean |
isPaused() |
boolean |
isPlaying() |
boolean |
isStarted() |
boolean |
isStopped() |
void |
pause() |
void |
play() |
protected void |
reset() |
void |
restart() |
void |
setAudioUrl(java.net.URL urlOfResource) |
void |
setAudioUrl(java.net.URL urlOfResource,
int bufferSize) |
void |
stop() |
canProvide, provide20MsAudio, setAudioSource, setVolume
public static final int DEFAULT_BUFFER_SIZE
protected final JDA api
protected java.lang.String userAgent
protected java.net.URL urlOfResource
protected java.io.InputStream resourceStream
protected java.io.BufferedInputStream bufferedResourceStream
protected boolean started
protected boolean playing
protected boolean paused
protected boolean stopped
public URLPlayer(JDA api, java.net.URL urlOfResource) throws java.io.IOException, javax.sound.sampled.UnsupportedAudioFileException
URLPlayer
with the given URL
as resource. URLPlayer(JDA, URL, int)
using the DEFAULT_BUFFER_SIZE
of 8192.api
- The JDA instanceurlOfResource
- The URL of the resourcejava.io.IOException
javax.sound.sampled.UnsupportedAudioFileException
public URLPlayer(JDA api, java.net.URL urlOfResource, int bufferSize) throws java.io.IOException, javax.sound.sampled.UnsupportedAudioFileException
URLPlayer
with the given URL
as resource and a buffer with the given size.api
- The JDA instanceurlOfResource
- The URL of the resourcebufferSize
- The buffer size in bytesjava.io.IOException
javax.sound.sampled.UnsupportedAudioFileException
public void setAudioUrl(java.net.URL urlOfResource) throws java.io.IOException, javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException
javax.sound.sampled.UnsupportedAudioFileException
public void setAudioUrl(java.net.URL urlOfResource, int bufferSize) throws java.io.IOException, javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException
javax.sound.sampled.UnsupportedAudioFileException
protected void reset()