The thread startet here:
http://lwjgl.org/forum/index.php/topic,3629.0.htmlBut though the subject changed I'm beginning a new one.
I've reduced the sample from the old thread to the minimum to play just one song:
import java.io.FileInputStream;
import java.io.IOException;
import org.lwjgl.openal.AL;
import org.newdawn.slick.openal.Audio;
import org.newdawn.slick.openal.AudioLoader;
public class SoundExample {
/** The ogg sound effect */
private static Audio oggEffect;
/**
* Main method
*/
public static void main(String[] argv) {
// soundExample.start();
try {oggEffect = AudioLoader.getAudio("OGG", new FileInputStream
("testdata/The Pretenders - Angel Of The Morning.ogg"));
} catch (IOException e) {e.printStackTrace();}
oggEffect.playAsSoundEffect(1.0f, 1.0f, true);
System.out.println("begin to sleep");
try{Thread.sleep(200000);
} catch (InterruptedException e) {e.printStackTrace();}
System.out.println("sleep ended");
AL.destroy();
}
}
As you can see I have a sleep to prevent the program from stopping before the sound ends. That method doesn't really make sense.
With native AL it should be like this:
public static void main(String[] argv) {
// soundExample.start();
try {oggEffect = AudioLoader.getAudio("OGG", new FileInputStream
("testdata/The Pretenders - Angel Of The Morning.ogg"));
} catch (IOException e) {e.printStackTrace();}
oggEffect.playAsSoundEffect(1.0f, 1.0f, true);
while (AL10.alGetSourcei(source, AL10.AL_SOURCE_STATE) == AL10.AL_PLAYING){
try{Thread.sleep(100);
} catch (InterruptedException e) {e.printStackTrace();}
}
But I cannot solve the source for the AL10.alGetSourcei.
What can I do here? I can't find something like that at AudioLoader here:
http://slick.cokeandcode.com/javadoc-util///Edit: I think this could help:
http://slick.cokeandcode.com/javadoc/org/newdawn/slick/openal/AudioImpl.htmlBut I don't know how to implement the isPlaying().