// soundsingle.java // a strange set of changes designed for // sites that list many sounds. import java.applet.*; public class soundsingle extends Applet { AudioClip clip = null; boolean turnedOn = false; public void loadClip(String fileName) { clip = null; clip = getAudioClip(getDocumentBase(), fileName); } public void on() { turnedOn = true; } public void off() { turnedOn = false; this.stop(); } public boolean isOn() { return turnedOn; } public void play() { if (clip != null && turnedOn) { clip.play(); } } public void loop() { if (clip != null && turnedOn) { clip.loop(); } } public void stop() { if (clip != null) { clip.stop(); } } public void init() { // Load the sounds if (getParameter("sound").equalsIgnoreCase("on")) { turnedOn = true; } if (getParameter("sound0") != null) { clip = getAudioClip(getDocumentBase(), getParameter("sound0")); clip.play(); clip.stop(); } } }