|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecttipgame.util.Sound
public class Sound
This class handles playing, pausing, and muting sounds.
| Nested Class Summary | |
|---|---|
(package private) static class |
Sound.CurrentlyPlayingListener
This class removes finished clips from the currentlyPlaying collection. |
| Field Summary | |
|---|---|
private static java.util.HashSet<javax.sound.sampled.Clip> |
currentlyPlaying
the sounds not currently at the end position of the track |
private static Sound.CurrentlyPlayingListener |
lineListener
removes clips from currentlyPlaying when they finish |
private static long |
muted
determines if the advancing of sounds should be audible |
private static boolean |
paused
determines if the currently playing sounds should advance |
private java.net.URL |
soundFile
the location of the sound file |
private java.util.LinkedList<javax.sound.sampled.Clip> |
sounds
the sound clips cached (both playing and done playing) |
| Constructor Summary | |
|---|---|
Sound(java.net.URL soundFile)
Makes a sound clip. |
|
| Method Summary | |
|---|---|
private static void |
advanceSounds(long millis)
advances the time of the track while muted |
private static boolean |
clipIsDone(javax.sound.sampled.Clip clip)
determines if the clip is within 1 millisecond of finishing |
private javax.sound.sampled.Clip |
getClip()
makes a new sound clip positioned at the end of the track |
static void |
mute()
makes the advancing of tracks not audible |
static void |
pause()
stops the current playing of the tracks in the current location |
void |
play()
plays the sound clip, getting it from the cache of done playing clips if possible, making a new clip if all cached are currently playing |
static void |
resume()
resumes playing the tracks from their current location |
static void |
turnSoundOn()
makes the advancement of tracks audible |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static java.util.HashSet<javax.sound.sampled.Clip> currentlyPlaying
private java.util.LinkedList<javax.sound.sampled.Clip> sounds
private java.net.URL soundFile
private static boolean paused
private static long muted
private static Sound.CurrentlyPlayingListener lineListener
| Constructor Detail |
|---|
public Sound(java.net.URL soundFile)
soundFile - the url of the sound clip| Method Detail |
|---|
private javax.sound.sampled.Clip getClip()
public void play()
private static boolean clipIsDone(javax.sound.sampled.Clip clip)
clip - the clip to determine if it is done
public static void pause()
public static void resume()
public static void mute()
private static void advanceSounds(long millis)
millis - the amount of time to advance in millisecondspublic static void turnSoundOn()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||