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

java.lang.Object
  extended by net.sf.freecol.client.gui.sound.SoundPlayer

public class SoundPlayer
extends java.lang.Object

Class for playing sound. See the package description for net.sf.freecol.client.gui.sound for information on how to play sfx/music.


Nested Class Summary
(package private)  class SoundPlayer.SoundPlayerThread
          Thread for playing a Playlist.
 
Field Summary
private  SoundPlayer.SoundPlayerThread currentSoundPlayerThread
          Used with multipleSounds.
private  int defaultPickMode
          This is the default pick-mode for a playlist.
private  boolean defaultPlayContinues
          Should the player continue playing after it it finished with a sound-clip? This is the default used with the play(Playlist playlist).
private  int defaultRepeatMode
          This is the default repeat-mode for a playlist.
private static int FADE_UPDATE_MS
           
private static java.util.logging.Logger logger
           
private static int MAXIMUM_FADE_MS
           
private  javax.sound.sampled.Mixer mixer
           
private  boolean multipleSounds
          Should the SoundPlayer play multiple sounds at the same time, or only one? If it does not allow multiple sounds, then using play will stop the sound currently playing and play the new instead.
private  boolean soundPaused
          Is the sound paused?
private  java.lang.ThreadGroup soundPlayerThreads
          The thread-group containing all of the SoundPlayerThreads.
private  boolean soundStopped
          Is the sound stopped?
static int STANDARD_DELAY
           
private  PercentageOption volume
           
 
Constructor Summary
SoundPlayer(AudioMixerOption mixerOption, PercentageOption volume, boolean multipleSounds, boolean defaultPlayContinues)
          Use this constructor.
SoundPlayer(AudioMixerOption mixerOption, PercentageOption volume, boolean multipleSounds, boolean defaultPlayContinues, int defaultRepeatMode, int defaultPickMode)
          Or this.
 
Method Summary
 boolean isPaused()
          Are the sounds paused?
 boolean isStopped()
          Are the sounds stopped?
 void pause()
          Pauses all the sounds.
 void play(Playlist playlist)
          Plays a playlist using the default play-continues, repeat-mode and pick-mode for this SoundPlayer.
 void play(Playlist playlist, boolean playContinues, int repeatMode, int pickMode, int delay)
          Plays a playlist.
 void play(Playlist playlist, int delay)
          Plays a playlist using the default play-continues, repeat-mode and pick-mode for this SoundPlayer.
 void playOnce(Playlist playlist)
          Plays a single random sound from the given playlist.
 void playOnce(Playlist playlist, int delay)
          Plays a single random sound from the given playlist.
 void stop()
          Stop playing the sounds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static final java.util.logging.Logger logger

STANDARD_DELAY

public static final int STANDARD_DELAY
See Also:
Constant Field Values

MAXIMUM_FADE_MS

private static final int MAXIMUM_FADE_MS
See Also:
Constant Field Values

FADE_UPDATE_MS

private static final int FADE_UPDATE_MS
See Also:
Constant Field Values

soundPlayerThreads

private java.lang.ThreadGroup soundPlayerThreads
The thread-group containing all of the SoundPlayerThreads.


soundPaused

private boolean soundPaused
Is the sound paused?


soundStopped

private boolean soundStopped
Is the sound stopped?


multipleSounds

private boolean multipleSounds
Should the SoundPlayer play multiple sounds at the same time, or only one? If it does not allow multiple sounds, then using play will stop the sound currently playing and play the new instead.


currentSoundPlayerThread

private SoundPlayer.SoundPlayerThread currentSoundPlayerThread
Used with multipleSounds.


defaultPlayContinues

private boolean defaultPlayContinues
Should the player continue playing after it it finished with a sound-clip? This is the default used with the play(Playlist playlist).


defaultRepeatMode

private final int defaultRepeatMode
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

defaultPickMode

private final int defaultPickMode
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

mixer

private javax.sound.sampled.Mixer mixer

volume

private PercentageOption volume
Constructor Detail

SoundPlayer

public SoundPlayer(AudioMixerOption mixerOption,
                   PercentageOption volume,
                   boolean multipleSounds,
                   boolean defaultPlayContinues)
Use this constructor.

Parameters:
mixerOption - The option for setting the mixer used by this SoundPlayer.
volume - The volume to be used when playing audio.
multipleSounds - Should the SoundPlayer play multiple sounds at the same time, or only one? If it does not allow multiple sounds, then using play will stop the sound currently playing and play the new instead.
defaultPlayContinues - Should the player continue playing after it it finished with a sound-clip? This is the default used with the play(Playlist playlist).

SoundPlayer

public SoundPlayer(AudioMixerOption mixerOption,
                   PercentageOption volume,
                   boolean multipleSounds,
                   boolean defaultPlayContinues,
                   int defaultRepeatMode,
                   int defaultPickMode)
Or this.

Parameters:
mixerOption - The option for setting the mixer used by this SoundPlayer.
volume - The volume to be used when playing audio.
multipleSounds - Should the SoundPlayer play multiple sounds at the same time, or only one? If it does not allow multiple sounds, then using play will stop the sound currently playing and play the new instead.
defaultRepeatMode - This is the default repeat-mode for a playlist. Refer to the field summary of the Playlist-class to get the different values.
defaultPickMode - This is the default pick-mode for a playlist. Refer to the field summary of the Playlist-class to get the different values.
defaultPlayContinues - Should the player continue playing after it it finished with a sound-clip? This is the default used with the play(Playlist playlist).
Method Detail

play

public void play(Playlist playlist)
Plays a playlist using the default play-continues, repeat-mode and pick-mode for this SoundPlayer.

Parameters:
playlist - The Playlist to be played.

play

public void play(Playlist playlist,
                 int delay)
Plays a playlist using the default play-continues, repeat-mode and pick-mode for this SoundPlayer.

Parameters:
playlist - The Playlist to be played.
delay - A delay before playing the sound (ms).

playOnce

public void playOnce(Playlist playlist)
Plays a single random sound from the given playlist.

Parameters:
playlist - The Playlist to be played.

playOnce

public void playOnce(Playlist playlist,
                     int delay)
Plays a single random sound from the given playlist.

Parameters:
playlist - The Playlist to be played.
delay - A delay before playing the sound (ms).

play

public void play(Playlist playlist,
                 boolean playContinues,
                 int repeatMode,
                 int pickMode,
                 int delay)
Plays a playlist.

Parameters:
playlist - The Playlist to be played.
playContinues - true if the SoundPlayer should continue playing after playing the first entry on the playlist.
repeatMode - The method this PlayList should be repeated.
pickMode - The method to be used for picking the songs.
delay - A delay before playing the sound (ms).

stop

public void stop()
Stop playing the sounds.


isStopped

public boolean isStopped()
Are the sounds stopped?

Returns:
true is the sounds are stopped.

pause

public void pause()
Pauses all the sounds.


isPaused

public boolean isPaused()
Are the sounds paused?

Returns:
true is the sounds are paused.