How can you play music in an application?
How can you play music in an application? I would like the music to change to certain events such as pressing a key. I have tried this way:
AudioPlayer p=AudioPlayer.player;
try{
AudioStream as =new AudioStream(new FileInputStream("music.wav"));
p.start(as);
}
catch(IOException err){
err.printStackTrace();
}
But I cannot make it react to certain events because I cannot make the variables public. I have also tried the applet.AudioClip but it makes my game lag terribly.
Any suggestions?

