An Overview of Java Audio Components

Applets

Developers who create games using applets have some limited but effective options for using sound in games. The primary interface designed to handle all applet-related audio work is the AudioClip(). This interface class is found in the standard applet toolkit. The AudioClip has the basic controls to play, loop, and stop a sound. If multiple sounds are played, the applet mixes them together to form a composite sound. The AudioClip can play audio clips stored in the .au format. This format is fairly low quality but is usually capable for most applets.

Loading and playing a sound with this class is as easy as passing a string to the class constructor. An example of how to load a sample into an AudioClip follows:

AudioClip sound; sound = getAudioClip(getCodeBase(), "sound.au");

To then control the audio clip, the user must only make calls to the AudioClip as follows:

sound.play();

For games that require more complete tools, there is also the option of using JavaSound in applets. This tool thoroughly extends the capabilities for games distributed as applets. An overview of JavaSound will be discussed in the next section.



Practical Java Game Programming
Practical Java Game Programming (Charles River Media Game Development)
ISBN: 1584503262
EAN: 2147483647
Year: 2003
Pages: 171

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net