Streaming + looping = broken vinyl record effect?

I don’t know if it is a bug, or my sloppy coding, but when I do:

[java] = new AudioNode(assetManager, “music/hgfy.ogg”, true);;;[/java]

first few seconds of music is played, then it is repeated (like in old broken vinyl record), before real music ends. It’s kinda shame because my music files are kinda large (about 2-3 MB each) and loading one of them takes few seconds which would increase game’s loading time. Streaming is good choice, but as I see, it doesn’t blend well with music looping.

Streaming sound doesn’t support looping afaik. just check for the end of the sound and then play it again or another

How? AudioNode doesn’t have isStopped(), hasEnded(), isFinished() or hasStopped method or similar (or I didn’t look hard enough.)

so obvious you would follow up with a “how” in five minutes…


Well, I’ve tried:

[java]if (( == AudioNode.Status.Stopped) || ( == AudioNode.Status.Paused)){;

} [/java]

in update(), but it doesn’t work.

Once a streamed audio node is done, it’s done. This is why they can’t loop. Throw that audio node away and create another one.

There was talk of making them resettable but I don’t know if that was ever implemented. In Mythruna, when my 3 minute ambient loop finishes then I throw that node away and create another one.

Yeahm but how to check if it is done?

If the status is Stopped.

@dariuszg-jagielski said:
Well, I've tried:
[java]if (( == AudioNode.Status.Stopped) || ( == AudioNode.Status.Paused)){;
} [/java]

in update(), but it doesn't work.

So... probably not.
@dariuszg-jagielski said:
So... probably not.

Then YOU did something wrong because I use exactly this approach and it works perfectly.

BUT in your sample code you are still trying to replay the same music node which I already said wouldn't work. So you are telling me the wrong thing. Stick a println in that if block. My guess is that the play() is being called and not doing anything. I think you made too many assumptions about what was happening and that's time to stick in some printlns or open the debugger.

You can reset the audio by calling


so you don’t have to recreate the sound every time.

6 years later


1 Like

Lol sorry I didn’t see the date and I also wanted to post the code so other people wouldn’t get confused.

Except at the time this thread was written, streaming audio couldn’t be reset in this way… I’m not convinced that non-cached streaming audio can now either. It’s a problem with the libraries that we use.