com.jmex.audio.openal
Class OpenALStreamedAudioPlayer

java.lang.Object
  extended by com.jmex.audio.player.AudioPlayer
      extended by com.jmex.audio.player.StreamedAudioPlayer
          extended by com.jmex.audio.openal.OpenALStreamedAudioPlayer

public class OpenALStreamedAudioPlayer
extends StreamedAudioPlayer

Version:
$Id: OpenALStreamedAudioPlayer.java 4342 2009-05-13 00:45:51Z mulova $
Author:
Joshua Slack
See Also:
StreamedAudioPlayer

Nested Class Summary
(package private)  class OpenALStreamedAudioPlayer.PlayerThread
          The thread that updates the sound.
 
Constructor Summary
OpenALStreamedAudioPlayer(AudioInputStream stream, AudioTrack parent)
           
 
Method Summary
 void applyTrackProperties()
           
 void cleanup()
          cleanup the used resources
protected  void empty()
          empties the queue
 int getBitRate()
           
 int getChannels()
           
 int getDepth()
           
 void init()
           
 boolean isActive()
           
 boolean isPlaying()
          check if the source is playing
 boolean isStopped()
           
protected  void onFinish()
          Called when the stream reached end of file.
 void pause()
           
 void play()
           
 boolean playInNewThread(long updateIntervalMillis)
          Plays the track in a newly created thread.
 boolean playStream()
          Plays the stream.
 void setMaxAudibleDistance(float maxDistance)
           
 void setMaxVolume(float maxVolume)
           
 void setMinVolume(float minVolume)
           
 void setPitch(float pitch)
           
 void setReferenceDistance(float refDistance)
           
 void setRolloff(float rolloff)
           
 void setVolume(float volume)
           
 void stop()
           
protected  boolean stream(int buffer)
          reloads a buffer
 boolean update()
          Copies data from the ogg stream to openAL10.
 void updateTrackPlacement()
           
 
Methods inherited from class com.jmex.audio.player.StreamedAudioPlayer
getLength, getStream, setStream
 
Methods inherited from class com.jmex.audio.player.AudioPlayer
getCurrentTime, getMaxDistance, getMaxVolume, getMinVolume, getPauseTime, getPitch, getRefDistance, getRolloff, getStartTime, getTrack, getVolume, isLoop, loop, setMaxDistance, setPauseTime, setRefDistance, setStartTime
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OpenALStreamedAudioPlayer

public OpenALStreamedAudioPlayer(AudioInputStream stream,
                                 AudioTrack parent)
Method Detail

init

public void init()
Specified by:
init in class AudioPlayer

cleanup

public void cleanup()
cleanup the used resources

Specified by:
cleanup in class AudioPlayer

stop

public void stop()
Specified by:
stop in class AudioPlayer

onFinish

protected void onFinish()
Called when the stream reached end of file.


play

public void play()
Specified by:
play in class AudioPlayer

pause

public void pause()
Specified by:
pause in class AudioPlayer

playStream

public boolean playStream()
Plays the stream. update() must be called regularly so that the data is copied to OpenAl


playInNewThread

public boolean playInNewThread(long updateIntervalMillis)
Plays the track in a newly created thread.

Parameters:
updateInterval - at which interval should the thread call update, in milliseconds.

isPlaying

public boolean isPlaying()
check if the source is playing

Specified by:
isPlaying in class AudioPlayer

isActive

public boolean isActive()
Specified by:
isActive in class AudioPlayer

isStopped

public boolean isStopped()
Specified by:
isStopped in class AudioPlayer

update

public boolean update()
               throws java.io.IOException
Copies data from the ogg stream to openAL10. Must be called often to prevent the buffers from starving.

Returns:
true if sound is still playing, false if the end of file is reached.
Throws:
java.io.IOException

stream

protected boolean stream(int buffer)
reloads a buffer

Returns:
true if success, false if read failed or end of file.

empty

protected void empty()
empties the queue


applyTrackProperties

public void applyTrackProperties()
Specified by:
applyTrackProperties in class AudioPlayer

updateTrackPlacement

public void updateTrackPlacement()
Specified by:
updateTrackPlacement in class AudioPlayer

setVolume

public void setVolume(float volume)
Overrides:
setVolume in class AudioPlayer

setPitch

public void setPitch(float pitch)
Overrides:
setPitch in class AudioPlayer

setMaxAudibleDistance

public void setMaxAudibleDistance(float maxDistance)
Overrides:
setMaxAudibleDistance in class AudioPlayer

setMaxVolume

public void setMaxVolume(float maxVolume)
Overrides:
setMaxVolume in class AudioPlayer

setMinVolume

public void setMinVolume(float minVolume)
Overrides:
setMinVolume in class AudioPlayer

setReferenceDistance

public void setReferenceDistance(float refDistance)
Overrides:
setReferenceDistance in class AudioPlayer

setRolloff

public void setRolloff(float rolloff)
Overrides:
setRolloff in class AudioPlayer

getBitRate

public int getBitRate()
Specified by:
getBitRate in class AudioPlayer

getChannels

public int getChannels()
Specified by:
getChannels in class AudioPlayer

getDepth

public int getDepth()
Specified by:
getDepth in class AudioPlayer