Previous | Next | Trail Map | Writing Applets | Creating an Applet User Interface


Playing Sounds

In the Java Applet package (java.applet), the Applet class and AudioClip interface provide basic support for playing sounds. Currently, the Java API supports only one sound format: 8 bit, µlaw, 8000Hz, one-channel, Sun ".au" files. You can create these on a Sun workstation using the audiotool application. You can convert files from other sound formats using an audio format conversion program.

Here are the sound-related Applet methods:

getAudioClip(URL), getAudioClip(URL, String)
Given a URL, these methods return an object that implements the AudioClip interface.
play(URL), play(URL, String)
These methods get the AudioClip corresponding to the specified URL and then play it.
The AudioClip interface defines the following methods:
loop()
Starts playing the clip repeatedly.
play()
Plays the clip once.
stop()
Stops playing the clip.


Previous | Next | Trail Map | Writing Applets | Creating an Applet User Interface