Thank you for the zip files.
Here is my observation on the reason for the problem:
- When you click on any button to play a sound, all is fine and the sound is stopped when page navigation occurs during playback. This is the expected behavior.
- To duplicate the problem: click on a button to begin playing a sound; then click the stop button ... the sound stops. This is also the expected behavior. Next click the same button again to begin playing the same sound; now navigate during playback and the sound will continue playing. This is NOT the expected behavior as the sound should have been stopped on page navigation.
- WHY? The issue or problem is introduced when you click the stop button on your page. When you use the option to "stopAll", the behavior is to stop all the sounds and move the playhead of each sound to position 0, but it does not UNLOAD them from the browser. This effectively keeps the sound loaded under the previous name that was used to play the sound. Next when the sound is played again under the same name, the sound manager thinks you want to load a NEW sound under the previously used name value. This creates a conflict where two sounds are using the same name string as a reference in the sound manager engine. One of the sounds now becomes orphaned without a reference in the sound manager. On page navigation, the orphaned sound will end up continuing to play.
- SOLUTION 1: On each button that begins playing a sound, you should call pgSoundControl() to check the status of the sound. If the status is 0 or null, then call pgSoundLoader() to load (or initialize) and play the sound. If the the result is > 0 then call pgSoundControl() with the property "play" to begin playing it again.
- SOLUTION 2: Adjust your stop button to unload or destroy the currently playing sound rather than using "stopAll".
Essentially, when managing multiple sounds on a single page, you need to unload/destroy previous ones before you can reuse their names. All of this is irrespective of the actual file itself because the PowerPac sound engine can load the same audio file multiple times under different names. As soon as you reuse a name that has not been specifically unloaded/destroyed, you get a reference error and lose the ability to control the sound on page navigation.