stop all sounds in Web Audio API

若如初见. 提交于 2020-01-13 17:51:49

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!