Single Instance Loopable Audio
If you attempt to play a loopable audio asset that is supposed to fade in / out and then pause, attempting to re-initiate the fade in while a fade out is already happening causes the sound to continue fading out instead or create an additional instance of the sound based on whether or not the pause occurred.
To fix this, I added a check for whether an asset was intended to loop in the play function like so:
for (var i=0; i<self._sounds.length; i++) {
if ((self._sounds[i]._paused && !self._sounds[i]._ended) || self._sounds[i]._loop) {
num++;
id = self._sounds[i]._id;
}
}
This seemed to fix the multiple instance problem, but the fade in / out problem still persists.
Is this referring to 2.0 or 1.x?
2.0
EDIT: I also think I fixed the fade in / fade out problem. Inside of the for loop of the fade method, I added a call to self._stopFade that kills any existing fades on the sound instances using this line of code:
for (var i=0; i<ids.length; i++) {
self._stopFade(ids[i]);
// Get the sound.
var sound = self._soundById(ids[i]);
Seems as though this probably isn't proper as it is also sending out the 'faded' emission, I'll see if there's something I can do instead to solve the problem without adding additional ones.
EDIT2: Soak testing revealed that this would fix my current problems and my boss has instructed me that nothing we're doing in house uses the faded emission anyways. If you come up with an official fix, please let me know and I'll revert my local change to match the official release.
This is partly taken care of with 51921596bc8f4d8cf2d836aa65bfca7290f71c89. However, I don't really follow what you are saying with the other part. Do you have a sample?
I'm still unable to reproduce the multiple instance issue you are referring to. If you can provide an example I'll reopen this.