The onended
event handler of the AudioBufferSourceNode
contains the callback associated with the ended
event: this allows you to run code in response to the audio track finishing playback.
Note: The onended
handler won't have any effect if the loop
property is set to true
, as the audio won't stop playing. To see the effect in this case you'd have to use AudioBufferSourceNode.stop()
.
SyntaxEdit
var source = audioCtx.createBufferSource();
source.onended = function() { ... };
ExampleEdit
source.start();
source.onended = function() {
console.log('Your audio has finished playing');
}
PropertiesEdit
None.
SpecificationEdit
Specification | Status | Comment |
---|---|---|
Web Audio API The definition of 'onended' in that specification. |
Working Draft |