//SoundClipsDemo.java import java.awt.*; import java.applet.*; //***AudioClip import javax.swing.*; public class SoundClipsDemo extends JApplet { AudioClip beep; //** public void init() { AudioClip ding; //variable of AudioClip ding = this.getAudioClip(this.getDocumentBase(),"ding.au"); //open the sound file ding.play(); //start to play it AudioClip ip; ip = this.getAudioClip(this.getDocumentBase(),"ip.au"); ip.play(); //open here, play in paint beep = this.getAudioClip(this.getDocumentBase(),"beep.au"); } public void paint(Graphics g) { //can declare, open, play in paint: AudioClip gong; gong = this.getAudioClip(this.getDocumentBase(),"gong.au"); gong.play(); beep.play(); //**gotten in init //beep.loop(); //** loop: play again and again forever //g.fillRect(1,1,100,100); //see that code continues from the start of the play //beep.stop(); //enough already. stop the playing } //applet's stop method called automatically when leave the web page public void stop() { //beep.stop(); //stop a looping sound } } // effect of non-existent file: no error, just no sound // wav and midi too