net.sf.freecol.client.gui.sound
Class SoundPlayer.SoundPlayerThread

java.lang.Object
  extended by java.lang.Thread
      extended by net.sf.freecol.client.gui.sound.SoundPlayer.SoundPlayerThread
All Implemented Interfaces:
java.lang.Runnable
Enclosing class:
SoundPlayer

 class SoundPlayer.SoundPlayerThread
extends java.lang.Thread

Thread for playing a Playlist.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
private  int delay
           
private  int pickMode
          This is the default pick-mode for a playlist.
private  boolean playContinues
          Should the SoundPlayer continue to play when it is finished with a sound-clip?
private  Playlist playlist
          An array containing the currently selected playlist.
private  int repeatMode
          This is the default repeat-mode for a playlist.
private  boolean repeatSound
          Should the sound be played again when it is finished?
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
SoundPlayer.SoundPlayerThread(Playlist playlist, boolean playContinues, int repeatMode, int pickMode, int delay)
          The constructor to use.
 
Method Summary
private  javax.sound.sampled.SourceDataLine getLine(javax.sound.sampled.AudioFormat audioFormat)
           
 void playSound(java.io.File file)
           
private  void rawplay(javax.sound.sampled.AudioFormat targetFormat, javax.sound.sampled.AudioInputStream din)
           
 void run()
          This thread loads and plays the sound.
private  boolean shouldStopThread()
           
private  void updateVolume(javax.sound.sampled.FloatControl c, int volume)
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

playlist

private Playlist playlist
An array containing the currently selected playlist. The numbers in the array is used as an index in the soundFiles-array.


playContinues

private boolean playContinues
Should the SoundPlayer continue to play when it is finished with a sound-clip?


repeatMode

private int repeatMode
This is the default repeat-mode for a playlist. Refer to the field summary of the Playlist-class to get the different values.

See Also:
Playlist

pickMode

private int pickMode
This is the default pick-mode for a playlist. Refer to the field summary of the Playlist-class to get the different values.

See Also:
Playlist

repeatSound

private boolean repeatSound
Should the sound be played again when it is finished?


delay

private int delay
Constructor Detail

SoundPlayer.SoundPlayerThread

public SoundPlayer.SoundPlayerThread(Playlist playlist,
                                     boolean playContinues,
                                     int repeatMode,
                                     int pickMode,
                                     int delay)
The constructor to use.

Parameters:
playlist - A Playlist containing sound-files.
playContinues - Should the player continue playing after it it finished with a sound-clip?
repeatMode - This is the default repeat-mode for a playlist. Refer to the field summary of the Playlist-class to get the different values.
pickMode - This is the default pick-mode for a playlist. Refer to the field summary of the Playlist-class to get the different values.
delay - A delay before playing the sound (ms).
Method Detail

shouldStopThread

private boolean shouldStopThread()

run

public void run()
This thread loads and plays the sound.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

playSound

public void playSound(java.io.File file)

updateVolume

private void updateVolume(javax.sound.sampled.FloatControl c,
                          int volume)

rawplay

private void rawplay(javax.sound.sampled.AudioFormat targetFormat,
                     javax.sound.sampled.AudioInputStream din)
              throws java.io.IOException,
                     javax.sound.sampled.LineUnavailableException
Throws:
java.io.IOException
javax.sound.sampled.LineUnavailableException

getLine

private javax.sound.sampled.SourceDataLine getLine(javax.sound.sampled.AudioFormat audioFormat)
                                            throws javax.sound.sampled.LineUnavailableException
Throws:
javax.sound.sampled.LineUnavailableException