com.cloudgarden.audio
Class AudioMediaURLSource
java.lang.Object
|
+--com.cloudgarden.audio.DefaultAudioObject
|
+--com.cloudgarden.audio.DefaultAudioSource
|
+--com.cloudgarden.audio.AudioMediaURLSource
- All Implemented Interfaces:
- AudioObject, AudioSource
- public class AudioMediaURLSource
- extends DefaultAudioSource
AudioSource wrapper for a URL, enabling audio data to be read from a URL.
Constructor Summary |
AudioMediaURLSource(java.net.URL url,
javax.sound.sampled.AudioFormat format)
Creates new AudioMediaFileSource. |
Method Summary |
int |
read(byte[] data,
int offset,
int len)
Used to read data from this source - called by the AudioSink which this
source is connected to (if its startGetting method is used) so need
not be called explicitly by an application. |
void |
startSending()
Starts a thread which reads audio data from the file. |
Methods inherited from class com.cloudgarden.audio.DefaultAudioObject |
addTransferListener, blockWhilePaused, blockWhileWaiting, bytesTransferred, canSetAudioFormat, getAudioFormat, getContentType, getLastException, isPaused, isWaiting, removeTransferListener, setPaused |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AudioMediaURLSource
public AudioMediaURLSource(java.net.URL url,
javax.sound.sampled.AudioFormat format)
throws javax.sound.sampled.UnsupportedAudioFileException,
java.io.IOException
- Creates new AudioMediaFileSource. Reads data from the file (which can be in any
format readable by the JMF) and converts it to the format determined by the 'format' parameter.
read
public int read(byte[] data,
int offset,
int len)
throws java.io.IOException
- Description copied from interface:
AudioSource
- Used to read data from this source - called by the AudioSink which this
source is connected to (if its startGetting method is used) so need
not be called explicitly by an application. Blocks if this source is paused.
Returns the number of bytes read, or END_OF_DATA if all the available
data has been read - eg if the end of a file has been reached, or if
the stopSending() method has been called.
- Following copied from interface:
com.cloudgarden.audio.AudioSource
- See Also:
AudioSource.setSink(com.cloudgarden.audio.AudioSink)
,
AudioSink#startGetting
,
AudioObject.setPaused(boolean)
startSending
public void startSending()
throws java.io.IOException
- Starts a thread which reads audio data from the file.
- Overrides:
startSending
in class DefaultAudioSource
- Throws:
an
- IOException if the file cannot be opened for reading