net.kolls.railworld
Class Sound

java.lang.Object
  extended by net.kolls.railworld.Sound
Direct Known Subclasses:
AppletSound, JSSound, NoSound, StreamSound

public abstract class Sound
extends java.lang.Object

Allows playback of sound. The behavior is designed for multiple requestors to be handled automatically and each treated as if they are the only requestor. The sound can also be frozen (paused), although requests by requestors must still be processed as if the sound was playing. The multiple requestors are handled via a "loop count" which is incremented whenever a requestor asks for a loop and decremented whenever a requestor says "stop". Thus, "stop" may not actually stop the sound.

Author:
Steve Kollmansberger

Field Summary
protected  boolean frozen
          Is the sound frozen
protected  int fzlc
          Frozen loop count
protected  int loopcnt
          Loop count
 
Constructor Summary
Sound()
           
 
Method Summary
abstract  boolean canPlay()
          Is the sound loaded and ready to play?
 void freeze()
          Freeze the sound.
abstract  void loop()
          Loop the sound.
abstract  void play()
          Play the sound.
abstract  boolean playing()
          Indicate if the sound is currently playing or looping.
abstract  void stop()
          Stop the sound.
 void unfreeze()
          Unfreeze the sound.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fzlc

protected int fzlc
Frozen loop count


frozen

protected boolean frozen
Is the sound frozen


loopcnt

protected int loopcnt
Loop count

Constructor Detail

Sound

public Sound()
Method Detail

canPlay

public abstract boolean canPlay()
Is the sound loaded and ready to play?

Returns:
true if the sound can be played.

play

public abstract void play()
Play the sound.


loop

public abstract void loop()
Loop the sound. If the sound is already looping, increment the loop counter.


stop

public abstract void stop()
Stop the sound. If multiple loops are in effect, simply decrement the loop counter.


playing

public abstract boolean playing()
Indicate if the sound is currently playing or looping.

Returns:
true if the sound is playing.

freeze

public void freeze()
Freeze the sound. Stops actual playing but maintains loop counts.


unfreeze

public void unfreeze()
Unfreeze the sound. Resume playing if any loops remain.