Hello, i was wondering if anyone could help me. I'm making a java game and i need a sound to start when i press a key and stop when i release it. What happens is that once the music starts it wont stop when i release :l
heres the code:
public void music() {
try {
InputStream in = new FileInputStream("C:/users/Usuario/Pictures/Game/nyan.wav");
AudioStream as = new AudioStream(in);
Anyways, it's not like we can see what happens when you press/release a key so there's nothing we can do with this code.
Name:
Anonymous2011-09-30 18:03
>>11 the sound starts when i press space key, and playingMusic changes to true.
when i release space playingMusic turns false, however music keeps playing.
I don't know Java beyond the basics, but I just did a google search and apparently you should be doing AudioPlayer.player.clear() instead of stop. I have no idea if this works or not, nor do I care, as you are clearly too stupid to use google.