Hello Guest

How can i reload a wav file using openAL (java)

  • 0 Replies
  • 4358 Views
How can i reload a wav file using openAL (java)
« on: September 29, 2012, 09:38:57 »


I made up an application which loads a .wav file, but it loads it only once. I want to be able to reload a wav file after the first track ends.How can i make that in java? Also, if i hit play twice after the end of the track(while the selected track is loaded) it throws an
IllegalThreadStateException.

 if (threadStatus != 0 || this != me)
            throw new IllegalThreadStateException();

the code i use to load the file is this:

OpenAL openal = new OpenAL();
source = openal.createSource(new File(Audioplayer.path));
System.out.println(source.toString());
source.play();
source.setGain(0.75f);      // 75% volume
source.setPitch(0.85f);     // 85% of the original pitch
source.setPosition(0, 0, 0); // -1 means 1 unit to the left
source.setLooping(false);    // Loop the sound effect
j=source.getBuffer();
System.out.println(j);
for (i=1;i<=10000;i++){
    Thread.sleep(1);        // Wait for 10 seconds
}
source.close();
openal.close();

I have posted this t another forum as well but still no answer so...