Explain how to play sound in an applet
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class Audio1Applet extends Applet implements ActionListener
{
Button play,stop;
AudioClip audioClip;
public void init()
{
play = new Button(" Play ");
add(play);
play.addActionListener(this);
stop = new Button(" Stop ");
add(stop);
stop.addActionListener(this);
audioClip = getAudioClip(getCodeBase(), "abc.wav");
}
public void actionPerformed(ActionEvent ae)
{
Button source = (Button)ae.getSource();
if (source.getLabel() == " Play ")
{
audioClip.play();
}
else if(source.getLabel() == " Stop ")
{
audioClip.stop();
}
}
}
<APPLET CODE="Audio1Applet" WIDTH="100" HEIGHT= "100"></APPLET>< H5>