Playing Sounds through an applet
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class Player extends Applet implements ActionListener {
// GUI Widgets
Button play, stop, loop;
AudioClip mySong;
public void init() {
// Make Gui
play = new Button("Play");
add(play);
play.addActionListener(this);
stop = new Button("Stop");
add(stop);
stop.addActionListener(this);
loop = new Button("Loop");
add(loop);
loop.addActionListener(this);
// Load the audio file
mySong = getAudioClip(getDocumentBase(), "Songs/song.au");
} // init
public void actionPerformed(ActionEvent e) {
if (e.getSource() == play)
mySong.play();
if (e.getSource() == stop)
mySong.stop();
if (e.getSource() == loop)
mySong.loop();
} // actionPerformed
} // Player