
380 • Java Programming
Explanation: The program is simple. A new URL
using the getCodeBase and an audio file name,
which is to be played, are created. The file name is
“POP1.mid”. Here, only audio files are created with
wav and mid extensions. The file to be played must
be in the current directory of the applet. The URL
thus created is passed to the play method. The play
method plays the file from beginning to end just
once. The audio file is played as soon as applet is
started.
14.11.2 Playing Audio Using AudioClip Interface
The AudioClip interface is defined by the java.applet package. The AudioClip interface is a
simple abstraction ...