import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
import java.applet.AudioClip;
class KlipSuara extends Applet{
Button main,berhenti,ulang;
AudioClip klip;
public void init(){
klip=getAudioClip(getCodeBase(),"autumn.mid");
main=new Button("Main");
berhenti=new Button("Berhenti");
ulang=new Button("Ulang");
add(main);
add(berhenti);
add(ulang);
main.addActionListener(new KlipSuara.PenanganTombol());
berhenti.addActionListener(new KlipSuara.PenanganTombol());
ulang.addActionListener(new KlipSuara.PenanganTombol());
}
class PenanganTombol implements ActionListener{
public void actionPerformed(ActionEvent e){
String s=e.getActionCommand();
if(s.equals("Main"))
klip.play();
else if(s.equals("Berhenti"))
klip.stop();
else if(s.equals("Ulang"))
klip.loop();
}
}
}
sedangkan ini file .HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> Klip Suara </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<body>
<applet code="KlipSuara.class" width=250 heigth=80>
</applet>
</body>
</html>
0 komentar: