org.PingOO.DLAI.lib.util
Class SoundManager

java.lang.Object
  |
  +--org.PingOO.DLAI.lib.util.Manager
        |
        +--org.PingOO.DLAI.lib.util.SoundManager

public final class SoundManager
extends Manager

Manages the sounds for the DLAI

Since:
PingOO 2.0
Version:
2.0
Author:
Fabrice Bouyé (bouye@cur-archamps.fr)

Field Summary
private static java.lang.String DEFAULT_MODULE
          Default module.
private static java.lang.String[] SOUND_EXTENSION
          By default all audio clips are au files.
private static java.util.Hashtable SOUND_TABLE
          Cache for sounds.
 
Fields inherited from class org.PingOO.DLAI.lib.util.Manager
classLoader
 
Constructor Summary
private SoundManager()
          Hides the constructor from the outside.
 
Method Summary
static void clearCache()
          Clears the cache used in this manager.
private static java.applet.AudioClip findAudioClip(java.lang.String baseDirectory, java.lang.String module, java.lang.String fileName, java.lang.String extension)
          Returns an audio clip from a file.
private static java.util.Hashtable getCache(java.lang.String module, java.util.Hashtable parentTable)
          Return the correct cache.
static java.applet.AudioClip getSound(java.lang.String identifier)
          Returns a audio clip from the default set.
static java.applet.AudioClip getSound(java.lang.String module, java.lang.String identifier)
          Returns an audio clip from a different set.
private static void initialize()
          Initializes caches.
protected static java.applet.AudioClip loadAudioClip(java.lang.String baseDirectory, java.lang.String module, java.lang.String fileName)
          Tries to find an audio clip scanning various file extension.
 
Methods inherited from class org.PingOO.DLAI.lib.util.Manager
findFile, findFile, findFile, findFile
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

SOUND_EXTENSION

private static final java.lang.String[] SOUND_EXTENSION
By default all audio clips are au files.

SOUND_TABLE

private static java.util.Hashtable SOUND_TABLE
Cache for sounds.

DEFAULT_MODULE

private static final java.lang.String DEFAULT_MODULE
Default module.
Constructor Detail

SoundManager

private SoundManager()
Hides the constructor from the outside.
Method Detail

initialize

private static final void initialize()
Initializes caches.

getCache

private static final java.util.Hashtable getCache(java.lang.String module,
                                                  java.util.Hashtable parentTable)
Return the correct cache.
Parameters:
module - The module to use.
parentTable - The parent cache of the desired cache.
Returns:
The correct cache.

clearCache

public static void clearCache()
Clears the cache used in this manager.

getSound

public static final java.applet.AudioClip getSound(java.lang.String identifier)
Returns a audio clip from the default set.
In case the audio clip is not found the program will then try to retrieve it by removing the default extension.
By default the search occurs in the sound directory, then if the audio clip is still not found it will take place in the big audio clip and then in the mini audio clip directory.
Parameters:
identifier - The identifier need to get the audio clip from its file. You do not need to provide the .au extension.
Returns:
The expected audio clip, or null if the file was not found.

getSound

public static final java.applet.AudioClip getSound(java.lang.String module,
                                                   java.lang.String identifier)
Returns an audio clip from a different set.
In case the audio clip is not found the program will then try to retrieve it by removing the default extension.
If the audio clip is still not found then the search will continue in the default set, using the same way as with the specific module.
By default the search occurs in the sound directory, then if the audio clip is still not found it will take place in the big audio clip and then in the mini audio clip directory.
Parameters:
module - The appli's name.
identifier - The identifier need to get the audio clip from its file. You do not need to provide the .au extension.
Returns:
The expected audio clip, or null if the file was not found.

loadAudioClip

protected static final java.applet.AudioClip loadAudioClip(java.lang.String baseDirectory,
                                                           java.lang.String module,
                                                           java.lang.String fileName)
Tries to find an audio clip scanning various file extension.
Parameters:
baseDirectory - The sound directory..
module - The appli's name.
fileName - The name of the audioClip's file.
Returns:
The expected audioClip, or null if the file was not found.

findAudioClip

private static java.applet.AudioClip findAudioClip(java.lang.String baseDirectory,
                                                   java.lang.String module,
                                                   java.lang.String fileName,
                                                   java.lang.String extension)
Returns an audio clip from a file.
Parameters:
baseDirectory - The sound directory..
module - The appli's name.
fileName - The name of the audio clip's file.
extension - One of the existing extension for this file.
Returns:
The expected audioClip, or null if the file was not found.