group1.view.audio
Class AudioFacade

java.lang.Object
  extended by group1.view.audio.AudioFacade

public class AudioFacade
extends java.lang.Object

A facade class for the audio system. Takes care of channel creation, data caching, and audio playback. (Also, this class is carefully written so that, no matter what goes wrong, nothing breaks. The worst that can happen in such a case is that any unavailable audio doesn't play, or we wait a tiny bit.)


Constructor Summary
AudioFacade()
          Constructor.
 
Method Summary
static void main(java.lang.String[] args)
          Main for testing.
 void pauseAll()
          Pause all audio channels.
 void pauseChannel(AudioChannel channel)
          Pause the specified audio channel.
 AudioChannel playAudio(Audio a)
          Play an audio file.
 AudioChannel playMusic(Audio a)
          Play music.
 AudioChannel playSound(Audio a)
          Play a sound effect.
 void stopAllAudio()
          Stop all audio channels' audio.
 void stopAllThreads()
          Stop all audio channels' threads, and remove all channels from this class.
 void stopChannelAudio(AudioChannel channel)
          Stop the specified audio channel's audio.
 void stopChannelThread(AudioChannel channel)
          Pause the specified audio channel's thread, and remove that thread from this class.
 void unpauseAll()
          Unpause all audio channels.
 void unpauseChannel(AudioChannel channel)
          Unpause the specified audio channel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AudioFacade

public AudioFacade()
Constructor. Sets up all of the caches and channels.

Method Detail

main

public static void main(java.lang.String[] args)
Main for testing.


playMusic

public AudioChannel playMusic(Audio a)
Play music. Music is assumed to be uncached and looped, and to be deleted after playback. We set up the cache, then play it. (There is typically a very small delay.)

Parameters:
a - The Audio enum type representing the music to be played.
Returns:
The audio channel the requested audio will be played on, or null if the data is not found, or the wrong type.

playSound

public AudioChannel playSound(Audio a)
Play a sound effect. SFX are assumed to be cached and unlooped. Thus, these play instantly.

Parameters:
a - The Audio enum type representing the sound to be played.
Returns:
The audio channel the requested audio will be played on, or null if the data is not in memory, or the wrong type.

playAudio

public AudioChannel playAudio(Audio a)
Play an audio file. Any particular details (such as whether the file is audio or music) are handled automatically.

Parameters:
a - The Audio enum type representing the audio to be played.
Returns:
The audio channel the requested audio will be played on, or null if the data is not in memory, or an unknown type.

pauseAll

public void pauseAll()
Pause all audio channels.


pauseChannel

public void pauseChannel(AudioChannel channel)
Pause the specified audio channel.

Parameters:
channel - The audio channel.

unpauseAll

public void unpauseAll()
Unpause all audio channels.


unpauseChannel

public void unpauseChannel(AudioChannel channel)
Unpause the specified audio channel.

Parameters:
channel - The audio channel.

stopAllAudio

public void stopAllAudio()
Stop all audio channels' audio.


stopChannelAudio

public void stopChannelAudio(AudioChannel channel)
Stop the specified audio channel's audio.

Parameters:
channel - The audio channel.

stopAllThreads

public void stopAllThreads()
Stop all audio channels' threads, and remove all channels from this class.


stopChannelThread

public void stopChannelThread(AudioChannel channel)
Pause the specified audio channel's thread, and remove that thread from this class.

Parameters:
channel - The audio channel.