import java.applet.*; import java.awt.*; public class AudioAnimator extends Animator { public void init() { // do Animator initialization first super.init(); // look up the name of a sound and then // load and play it (just once), in a separate thread. String soundname = this.getParameter("sound"); new SoundPlayer(this,soundname); } } // This is the thread class that loads and plays the sound class SoundPlayer extends Thread { private Applet applet; private String sound_url; // Store the information the run() method needs, and start it. public SoundPlayer(Applet app, String url) { applet = app; sound_url = url; this.start(); } // This is the code the thread runs to load and play the sound public void run() {applet.play(applet.getDocumentBase(),sound_url);} }