![]() ![]() ![]() ![]() |
Creating an Applet User Interface |
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.Below are the sound-related Applet methods. The two-argument form of each method takes a base URL (generally, returned by either
getDocumentBase()
orgetCodeBase()
) and the location of the sound file relative to the base URL. You should generally use the code base for sounds that are integral to the applet. The document base is generally used for sounds specified by the applet user, such as through applet parameters.
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:
[It'd be nice to have an example. Or point to one.]
loop()
![]()
- Starts playing the clip repeatedly.
play()
![]()
- Plays the clip once.
stop()
![]()
![]() ![]() ![]() ![]() |
Creating an Applet User Interface |