1
我编写了一个加载.wav文件的应用程序,但它只加载一次。 我希望能够在第一首曲目结束后重新加载wav文件。如何在java中创建该文件? 此外,如果我打的轨道的结束后播放两次(同时选择的曲目被加载)它抛出一个我如何使用openAL重新加载wav文件(java)
IllegalThreadStateException.
if (threadStatus != 0 || this != me)
throw new IllegalThreadStateException();
我使用加载该文件的代码是这样的:
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
}
Thread.sleep(10000); // Wait for 10 seconds
source.close();
openal.close();