de.htwdd.rosenkoenig.util
Class SoundList

java.lang.Object
  extended by de.htwdd.rosenkoenig.util.SoundList

public class SoundList
extends java.lang.Object

Utility class that works as a container for sound clips. Every clip has an identifier to access it. SoundList is designed as a singleton.


Field Summary
private  java.util.Hashtable<java.lang.String,javax.sound.sampled.Clip> clips
           
private static SoundList instance
           
private  org.apache.log4j.Logger log
           
 
Constructor Summary
private SoundList()
           
 
Method Summary
 void addSound(java.lang.String filename, java.lang.String identifier)
          adds a soundfile to the list
protected  void finalize()
           
static SoundList getInstance()
           
 void loadFromFile(java.lang.String filename)
          loads a number of sound files at once.
 void play(java.lang.String name)
          plays a soundfile
 void removeSound(java.lang.String name)
          remove a soundfile from the list
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instance

private static SoundList instance

log

private org.apache.log4j.Logger log

clips

private java.util.Hashtable<java.lang.String,javax.sound.sampled.Clip> clips
Constructor Detail

SoundList

private SoundList()
Method Detail

getInstance

public static SoundList getInstance()

loadFromFile

public void loadFromFile(java.lang.String filename)
loads a number of sound files at once. The filenames and identifiers have to be specified in a property file as follows:

identifier1 sounds/example.wav
nextIdentifier sounds/example2.wav

Parameters:
filename - a property file containing filenames and identifiers

addSound

public void addSound(java.lang.String filename,
                     java.lang.String identifier)
adds a soundfile to the list

Parameters:
filename - the name of the soundfile
identifier - the identifier that is needed to play the sound

removeSound

public void removeSound(java.lang.String name)
remove a soundfile from the list

Parameters:
name - identifier of the clip to be removed

play

public void play(java.lang.String name)
plays a soundfile

Parameters:
name - identifier of the clip to be played

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable