If you remove a AudioNode by calling the AudioNode#removeFromParent method it does not stop the audio from continuing to play.
Simple code to test it:[java] AudioNode audio = new AudioNode(this.getAssetManager(), “Sounds/test.ogg”, true);
audio.removeFromParent();[/java] If a AudioNode is REMOVED from the parent node or even the root node shouldn’t the audio attached to that node stop playing and be released?
AudioNode is a “special” node. If you attach the AudioNode to a nuclear explosion node the AudioNode shouldn’t stick around if the nuclear explosion is gone (unless you have a ear ringing effect then that should be spawned on a separate scene node until the effect subsides). Nothing survives NUCLEAR! AudioNode, being a Node at heart, should follow the typical Node behavior when removed from the parent. A jukebox that gets blown up shouldn’t keep playing its soundtrack as if it is a jukebox from Silent Hill… I rest my case.
AudioNode should never really have been a node in the first place, actually. A control linking to a separate audio source probably would have been better suited… but at any rate, the sound played is not related to the node’s attachment to the scene other than that if it is positional it will get its position from the node.
There is no way to detect node detachment so the feature your wish for is actually kind of impossible. Also, one could make the case that if my car node blows up and I attach an explosion node to it that it shouldn’t stop playing just because the car is gone… the explosion may still be ringing out at the car’s last position.
In my own projects, I’ve never actually attached an AudioNode to the scene at all.
Ah, removing it from the parent won’t stop it from playing? That answers my question without needing a new topic. Think I might update the wikipedia page on this.
At the moment I have a room which contains various noises, i’m assuming the easiest way to stop the noises when the player switches rooms would be to create my own audio manager to keep track of all the sounds in the current scene(so I can stop them as the player moves between rooms)?
EDIT: sorry, seems when I quote I can’t see my post :S :S…but it says i’ve posted. Weird!