Question

I'm trying to get this program to loop the song infinitely, but I've only managed to get it working once. Any advice?

Here is my code:

public static void music(){

    String filename = "darkAura.wav";
    ContinuousAudioDataStream loop = null;
    InputStream in = null;
    try {
        in = new FileInputStream(filename);
    } catch (FileNotFoundException ex) {
        System.out.println("File not found");
    }
    try {
        AudioStream s = new AudioStream(in);
        AudioData MD;
        AudioPlayer.player.start(s);
    } catch (IOException ex) {
        System.out.println(ex.getMessage());
    }

}
Was it helpful?

Solution

You are not using loop variable at all. Try it like this:

AudioStream s = new AudioStream(in);     
AudioData audiodata = s.getData();
loop = new ContinuousAudioDataStream(audiodata);
AudioPlayer.player.start(loop);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top