Playing Sounds The JApplet class in the Java Swing package (javax.swing), and the AudioClip interface in the Java Applet package (java.applet) provide basic support for playing sounds. Currently, the Java API supports only one sound format: 8 bit, µ-law, 8000 Hz, 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.
Sound-Related Methods Below are the sound-related Applet methods. The two-argument form of each method takes a base URL, which is usually returned by either getDocumentBase or getCodeBase, and the location of the sound file relative to the base URL.
getAudioClip(URL), getAudioClip(URL, String) Return an object that implements the AudioClip interface. play(URL), play(URL, String) Play the AudioClip corresponding to the specified URL. The AudioClip interface defines the following methods:
loop Starts playing the clip repeatedly. play Plays the clip once. stop Stops the clip. Works with both looping and one-time sounds.