How to tell when audio is finished?

Hey everyone. You know how there is an onAnimCycleDone method built in to the animation class? Is there anything similar for audio? I want to be able to do certain things when a piece of audio is finished. Thanks.

There’s definitely a way to poll (in the update loop) if an audio node isn’t playing anymore (for streamed music at least), can’t remember the method name off top of my head, sorry.

Edit: It’s auidoNode.getStatus ()

Do you know of any sample code that demonstrates how to use this? Thank you so much even if you don’t!

[java]simpleUpdate (float tpf) {
if (audioNode.getStatus () == Status.Stopped) {
// This node has finished playing
}
}[/java]

If you aren’t gonna start it again, then this will be called repeatedly, so you may wanna have a boolean when u start, and change it when it finishes for the first time.

1 Like