howler.js icon indicating copy to clipboard operation
howler.js copied to clipboard

Canceling a running (slow) fade operation

Open suterma opened this issue 3 years ago • 1 comments

While https://github.com/goldfire/howler.js/issues/363 addresses the situation of a fade-in after a fade-out I still would like to have the possibility to cancel a current fade operation.

My scenario is this: I have a running, slow fade-out, but then, after a user input, I would like to stop the sound altogether.

Now this works, the sound is silent, but the fade operation is still running. When, after a short time, the sound should play again, before the fade operation actually ends, the incoming play operation is then immediately fading with the "old" fade.

There should be a possibility to cancel all pending fade operation, either as separate call or as (optional) part of the existing stop operation.

suterma avatar Dec 28 '21 22:12 suterma

I have found out, that starting a new fade operation cancels the previous one, so I can do:

        const currentVolume = this.sound.volume();
        this.sound.fade(currentVolume, 0, 0);

to immediately fade to zero, effectively cancel any previous fade.

This possibility should be better addressed in the docs or even offered as it's own method.

suterma avatar Dec 29 '21 10:12 suterma