Playing Sound
Here is the applet: Solution//Purpose: Open sound file from the same directory as the web-page // that includes this applet and plays it to the screen. import java.awt.*; import java.applet.*; public class test8 extends Applet { AudioClip butch; //get audio clip public void init() { butch = getAudioClip(getDocumentBase(), "bark.au"); } //tell people what they are hearing public void paint(Graphics g) { g.drawString("Butch is barking again!", 25,25); } //start looping the sound public void start() { butch.loop(); } //stop the sound public void stop() { butch.stop(); } } |