Skip to content
Advertisement

WebAudio not playing after stop(0)

I’m writing something like a web-audio-editor, and I think I’m close to finishing the basics. I can play and stop an audiofile, but when I try to call the play method again it just won’t work, even though the parameters havn’t changed.

I’d be glad to see someone look into my problem as I cannot see why it doesn’t work when similar code in other projects does. Unfortunately I cannot create a jsfiddle, because I would need to load an external mp3-file and it seems I’m not allowed to do that. But I have pasted the javascript here and the corresponding html file here.

All you need is a server you can upload the files to and a mp3 on it. Alternately you could use this link, but I will delete the files eventually.

Advertisement

Answer

You can’t call start() on an AudioBufferSourceNode more than once. They’re one-time-use only.

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

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement