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?

[818 byte] By [Chris1234554a] at [2007-11-27 4:10:14]
# 1
Does anyone have any suggestions?
Chris1234554a at 2007-7-12 9:15:44 > top of Java-index,Security,Cryptography...