jfreerails.client.common
Class SoundManager
java.lang.Object
jfreerails.client.common.SoundManager
- All Implemented Interfaces:
- java.util.EventListener, javax.sound.sampled.LineListener, ModelRootListener
public class SoundManager
- extends java.lang.Object
- implements ModelRootListener, javax.sound.sampled.LineListener
This class is responsible for loading and playing sounds. Samples are read
into a byte arrays so that they don't need to be loaded from disk each time
they are played.
- Author:
- Luke
Nested Class Summary |
private static class |
SoundManager.Sample
Stores the audio data and properties of a sample. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
logger
private static final java.util.logging.Logger logger
soundManager
private static final SoundManager soundManager
maxLines
private int maxLines
mixer
private javax.sound.sampled.Mixer mixer
playSounds
private boolean playSounds
samples
private java.util.HashMap<java.lang.String,SoundManager.Sample> samples
voices
private final java.util.LinkedList<javax.sound.sampled.Clip> voices
SoundManager
private SoundManager()
getSoundManager
public static SoundManager getSoundManager()
main
public static void main(java.lang.String[] args)
addClip
public void addClip(java.lang.String s)
throws java.io.IOException,
javax.sound.sampled.UnsupportedAudioFileException,
javax.sound.sampled.LineUnavailableException
- Throws:
java.io.IOException
javax.sound.sampled.UnsupportedAudioFileException
javax.sound.sampled.LineUnavailableException
loadStream
private java.io.ByteArrayInputStream loadStream(java.io.InputStream inputstream)
throws java.io.IOException
- Throws:
java.io.IOException
playSound
public void playSound(java.lang.String s,
int loops)
propertyChange
public void propertyChange(ModelRoot.Property p,
java.lang.Object before,
java.lang.Object after)
- Specified by:
propertyChange
in interface ModelRootListener
update
public void update(javax.sound.sampled.LineEvent event)
- Specified by:
update
in interface javax.sound.sampled.LineListener