net.jinx.audio
Class StreamSource

java.lang.Object
  extended by net.jinx.audio.Source
      extended by net.jinx.audio.StreamSource
All Implemented Interfaces:
java.lang.Runnable

public class StreamSource
extends Source
implements java.lang.Runnable

Extension of Source that uses buffers to stream audio from a java.net.URL, instead of loading the entire file into memory. This uses an extra Thread to read the audio data in the background (stream, not channel based).

API Stability: Alpha; this is subject to change at any time.


Constructor Summary
StreamSource(net.java.games.joal.AL al, net.java.games.joal.ALC alc, java.io.File file)
          Constructs a new StreamSource that will stream from the given File.
StreamSource(net.java.games.joal.AL al, net.java.games.joal.ALC alc, java.net.URL url)
          Constructs a new StreamSource that will stream from the given URL.
 
Method Summary
 void delete()
          Frees the resources that this Source consumes.
 boolean isLooping()
          Indicates if this Source will loop.
 boolean isStreaming()
          Indicates if the stream thread is currently running.
 void pause()
          Pauses this source.
 void play()
          Begins playing this Source.
 void rewind()
          Rewinds this source.
 void run()
           
 void setLooping(boolean loop)
          Sets wether or not this Source loops back to the beginning when it finishes.
 void stop()
          Stops this Source.
 
Methods inherited from class net.jinx.audio.Source
buffersProcessed, buffersQueued, getAL, getALC, getBooleanInt, getBuffer, getConeOuterGain, getDirection, getFloat, getGain, getInt, getMaxDistance, getMaxGain, getMinGain, getPitch, getPosition, getReferenceDistance, getRolloffFactor, getSourceID, getVelocity, isInitialized, isSourceRelative, queueBuffer, queueBuffers, setBooleanInt, setBuffer, setConeOuterGain, setDirection, setDirection, setFloat, setGain, setInt, setMaxDistance, setMaxGain, setMinGain, setPitch, setPosition, setPosition, setReferenceDistance, setRolloffFactor, setSourceRelative, setVelocity, setVelocity, unqueueBuffer, unqueueBuffers
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamSource

public StreamSource(net.java.games.joal.AL al,
                    net.java.games.joal.ALC alc,
                    java.io.File file)
             throws java.net.MalformedURLException
Constructs a new StreamSource that will stream from the given File. If the file is not understandable, the streaming thread will exit and this StreamSource will not function.

Parameters:
file - the File to stream from.
al - the AL object to use for audio rendering.
alc - the ALC object to use for audio rendering.
Throws:
java.lang.NullPointerException - will be thrown if any of the parameters are null.
java.net.MalformedURLException

StreamSource

public StreamSource(net.java.games.joal.AL al,
                    net.java.games.joal.ALC alc,
                    java.net.URL url)
Constructs a new StreamSource that will stream from the given URL. If the file at the given URL is not understandable, the streaming thread will exit and this StreamSource will not function.

Parameters:
url - the URL to stream from.
al - the AL object to use for audio rendering.
alc - the ALC object to use for audio rendering.
Throws:
java.lang.NullPointerException - will be thrown if any of the parameters are null.
Method Detail

play

public void play()
Description copied from class: Source
Begins playing this Source.

Overrides:
play in class Source

pause

public void pause()
Description copied from class: Source
Pauses this source.

Overrides:
pause in class Source

stop

public void stop()
Description copied from class: Source
Stops this Source.

Overrides:
stop in class Source

rewind

public void rewind()
Description copied from class: Source
Rewinds this source.

Overrides:
rewind in class Source

setLooping

public void setLooping(boolean loop)
Description copied from class: Source
Sets wether or not this Source loops back to the beginning when it finishes.

Overrides:
setLooping in class Source
Parameters:
loop - boolean value for setting this option.

isLooping

public boolean isLooping()
Description copied from class: Source
Indicates if this Source will loop.

Overrides:
isLooping in class Source
Returns:
true if this Source will loop.

isStreaming

public boolean isStreaming()
Indicates if the stream thread is currently running.

Returns:
true if the stream thread is running.

run

public void run()
Specified by:
run in interface java.lang.Runnable

delete

public void delete()
Description copied from class: Source
Frees the resources that this Source consumes.

Overrides:
delete in class Source