Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the onended event for an AudioBuffer in HTML5/Chrome

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?

like image 713
Matthew James Davis Avatar asked Nov 03 '22 19:11

Matthew James Davis


1 Answers

Chromium only added this recently (end of May, I think). Pretty sure it's not in the stable releases yet.

Have you tried it in Chrome Canary?

like image 130
Kevin Ennis Avatar answered Nov 13 '22 21:11

Kevin Ennis