OfflineAudioContext: complete event
Web Audio API
Web Audio API
The complete event of the OfflineAudioContext interface is fired when the rendering of an offline audio context is complete.
This event is not cancelable and does not bubble.
Syntax
Use the event name in addEventListener():
addEventListener("complete", (event) => { })
Alternatively, assign to the event handler property of the interface:
oncomplete = (event) => { }
Event type
An OfflineAudioCompletionEvent. Inherits from Event.
OfflineAudioCompletionEvent
Examples
When processing is complete, you might want to use the complete event handler to prompt the user that the audio can now be played, and enable the play button:
const offlineAudioCtx = new OfflineAudioContext(2, 44100 * 40, 44100);
offlineAudioCtx.addEventListener("complete", () => {
console.log("Offline audio processing now complete");
alert("Song processed and ready to play");
playBtn.disabled = false;
});
You can also set up the event handler using the oncomplete property (but note that this replaces other event listeners added using oncomplete, if any):
const offlineAudioCtx = new OfflineAudioContext(2, 44100 * 40, 44100);
offlineAudioCtx.oncomplete = () => {
console.log("Offline audio processing now complete");
alert("Song processed and ready to play");
playBtn.disabled = false;
};