WebAudio does not play after stopping (0)

I'm writing something like a web audio editor, and I think I'm close to completing the basics. I can play and stop the audio file, but when I try to call the playback method again, it simply won’t work, even if the parameters have not changed.

I would be glad to see someone look into my problem, because I do not understand why this does not work when the similar code is in other projects. Unfortunately, I cannot create jsfiddle, because I will need to download an external mp3 file, and it seems that I am not allowed to do this. But I inserted javascript here and the corresponding html file here .

All you need is a server to which you can upload files and mp3 to it. Alternatively, you can use this link , but in the end I will delete the files.

+6
source share
2 answers

You cannot call start() on an AudioBufferSourceNode more than once. They are disposable.

Indeed, the only way to do this is to create a new AudioBufferSourceNode from the base AudioBuffer every time you need to start playback.

+8
source

You can also leave it operational and simply disconnect it from the gain - node, and the oscillator will apparently just ignore / quietly produce a signal.

0
source

Source: https://habr.com/ru/post/953336/


All Articles