files/en-us/web/api/offlineaudiocontext/complete_event/index.md
{{APIRef("Web Audio API")}}
The complete event of the {{domxref("OfflineAudioContext")}} interface is fired when the rendering of an offline audio context is complete.
This event is not cancelable and does not bubble.
Use the event name in methods like {{domxref("EventTarget.addEventListener", "addEventListener()")}}, or set an event handler property.
addEventListener("complete", (event) => { })
oncomplete = (event) => { }
An {{domxref("OfflineAudioCompletionEvent")}}. Inherits from {{domxref("Event")}}.
{{InheritanceDiagram("OfflineAudioCompletionEvent")}}
Also inherits properties from its parent, {{domxref("Event")}}.
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();
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:
const offlineAudioCtx = new OfflineAudioContext();
offlineAudioCtx.oncomplete = () => {
console.log("Offline audio processing now complete");
alert("Song processed and ready to play");
playBtn.disabled = false;
};
{{Specifications}}
{{Compat}}