gamingtools
Class AudioSource

java.lang.Object
  |
  +--gamingtools.AudioSource

public final class AudioSource
extends Object

The AudioSource class provides methods for loading music and sound effect files. The following file formats are supported: AIFF-C, AIFF, AU, MIDI, MP3, SND, and WAVE. MP3 files should end in ".mp3" and MIDI files should end in ".mid" or ".midi" for proper identification.

Note: To play MP3 files, the Java Media Framework must be installed and jmf.jar must be in the classpath.

See Also:
SoundEffect, MidiMusic, JMFSound

Field Summary
static String SOUNDS_DIR
          Location of the audio files relative to the root package.
 
Method Summary
static Audio getAudio(String fileName)
          Loads an audio file with the specified name from the sounds directory.
static Audio getAudio(String fileName, AudioListener audioListener)
          Loads an audio file with the specified name from the sounds directory and associates it with an AudioListener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SOUNDS_DIR

public static final String SOUNDS_DIR
Location of the audio files relative to the root package.

See Also:
Constant Field Values
Method Detail

getAudio

public static Audio getAudio(String fileName)
Loads an audio file with the specified name from the sounds directory.

Parameters:
fileName - Include a path relative to the sounds directory.
Returns:
The loaded audio.

getAudio

public static Audio getAudio(String fileName,
                             AudioListener audioListener)
Loads an audio file with the specified name from the sounds directory and associates it with an AudioListener.

Parameters:
fileName - Include a path relative to the sounds directory.
audioListener - Called back when the sound effect or the music stops playing.
Returns:
The loaded audio.