Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

share|improve this question
    
I've just tested it again on Windows and it works flawlessly. The problem only happens on Linux. –  Diogo Schneider Apr 13 at 22:45
    
Is there some sort of playback position you can reset to 0 between calls, or some sort of loop property you can set to true? –  ashes999 Apr 14 at 4:20
    
Not as far as I can see from these objects' methods. But even if there was a 'loop' field, it would be a problem because the sound would probably repeat itself infinitely. –  Diogo Schneider Apr 14 at 12:06
add comment

1 Answer 1

Well, since this is a Linux-only issue I have posted a bug to OpenJDK and just disabled sound if a Linux OS is detected. The code runs perfect in Mac OS X and Windows.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.