Get the onended event for an AudioBuffer in HTML5/Chrome
- by Matthew James Davis
So I am playing audio file in Chrome and I want to detect when playing has ended so I can delete references to it. Here is my code
var source = context.createBufferSource();
source.buffer = sound.buffer;
source.loop = sound.loop;
source.onended = function() {
delete playingSounds[soundName];
}
source.connect(mainNode);
source.start(0, sound.start, sound.length);
however, the event handler doesn't fire. Is this not yet supported as described by the W3 specification? Or am I doing something wrong?