问题
I loaded and played multiple sounds with web audio api at the same time. Is there any way to stop all sounds?
ex: a button to stop all sounds now.
Since I have more than 10 sounds playing at the same time, I dont wanna manually use noteOff(0) (or stop(0) ) for each sound source.
回答1:
The easiest way to achieve the effect you want, then, is to connect() them all to a gain node which is then connected to the destination, and set gain.gain.value = 0.
It won't actually stop them, of course, but it will silence them.
来源:https://stackoverflow.com/questions/15644922/stop-all-sounds-in-web-audio-api