|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.Thread group1.view.audio.AudioChannel
public class AudioChannel
A thread used to play audio. This thread stays around even after the audio finishes, and can be used over and over. (It is recommended that the view create several of these channels, perhaps 4-8, and use them as they are available.)
Supports pausing, unpausing, looping, and stopping audio.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Field Summary |
---|
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
AudioChannel(javax.sound.sampled.AudioFormat format)
Constructor. |
Method Summary | |
---|---|
boolean |
hasAudioData()
Returns whether or not this thread is busy playing audio (or cleaning it up). |
void |
pause()
Pause the thread. |
void |
playAudio(AudioCache cache,
boolean looping)
Play the requested audio from a cache. |
void |
run()
A method called by the system to run the thread. |
void |
stopAudio()
Stop the current audio. |
void |
stopThread()
Stop the thread. |
void |
unpause()
Unpause the audio. |
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public AudioChannel(javax.sound.sampled.AudioFormat format)
format
- The audio format to use.Method Detail |
---|
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public void playAudio(AudioCache cache, boolean looping) throws BusyAudioChannelException
cache
- The AudioCache where the audio data to be played is stored.looping
- Whether or not this audio should be looped.
BusyAudioChannelException
- If the channel is already busy playing (or still cleaning up) audio.public void stopThread()
public void stopAudio()
public void pause()
Note that this pauses the THREAD, not just the audio! To unpause the thread, the thread that hold's the object for this thread needs to call this thread's notify method, and should do use syncronized. See unpause for an example.
public void unpause()
Note that this only part of the unpausing procedure! To correctly unpause the audio, use something like: synchronized (thisAudioChannel) { thisAudioChannel.unpause(); thisAudioChannel.notify(); }
public boolean hasAudioData()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |