Strange sound with/without Eclipse problem

Hi,

I have a strange problem in my Java game in that the sounds (PCM-SIGNED, 8000 Hz, 16 bit mono from wav files) play ok in Eclipse but not from a standalone executable jar.

In that latter case I only hear blips and burps :frowning:

I suspected a difference in the JRE/JDK to be the cause but now even if I use the JDF in both instances the problem still appears.

I observed the behaviour as well with a 1.4.2_04 jdk as with the new 1.5.0.

Any toughts?

Thanks…

Christophe

Well I found the solution…

When loaded from Eclipse, the sounds were loaded as a file url whereas from the jar, the sounds were loaded as a jar url.

AudioInputStream.read() seems to load the whole file at once using a file url, but in the case of a jar url, AudioStream reads the file chunk by chunk, and in that case I only did read the first chunk.

A do … while loop fixed it…