Playing repeated sound in Java

Posted by Diogo Schneider on Game Development See other posts from Game Development or by Diogo Schneider
Published on 2014-04-13T21:40:33Z Indexed on 2014/08/18 22:33 UTC
Read the original article Hit count: 315

Filed under:
|

I'm trying to play sounds in a Java game with the following code:

AudioStream audioStream = new AudioStream(stream);
AudioPlayer.player.start(audioStream);

The stream variable is just an InputStream to the resource. By the first time this code is called, the sound is played as expected, but by the second time the program just hangs, not even an exception is thrown.

I don't know what's going on or how to prevent this. If I try closing either stream or audioStream after the above code, the program doesn't hang, but no sound is ever played at all.

Any tips are welcome, thanks.

© Game Development or respective owner

Related posts about java

Related posts about sound