I am attempting to add sound to a game, I've tried
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class PlaySoundApplet extends Applet
implements ActionListener{
Button play,stop;
AudioClip audioClip;
public void init(){
play = new Button(" Play in Loop ");
add(play);
play.addActionListener(this);
stop = new Button(" Stop ");
add(stop);
stop.addActionListener(this);
audioClip = getAudioClip(getCodeBase(), "Sound.wav");
}
public void actionPerformed(ActionEvent ae){
Button source = (Button)ae.getSource();
if (source.getLabel() == " Play in Loop "){
audioClip.play();
}
else if(source.getLabel() == " Stop "){
audioClip.stop();
}
}
}
but that interferes with my Keylistener for some reason. I've also tried How can I play sound in Java?, every solution there possible but those either deal with JFrame/Canvas or does not work. I've also encountered this error:
Mini.java:8: warning: AppletAudioClip is internal proprietary API and may be removed in a future release import sun.applet.AppletAudioClip;
I'm not quite sure what that error is, but in any case, I'm looking for a code that I can add to my existing program - preferably with a mute button available, but it's not necessary.