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();