Back to Content

OfflineAudioContext: complete event

files/en-us/web/api/offlineaudiocontext/complete_event/index.md

latest1.7 KB
Original Source

{{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.

Syntax

Use the event name in methods like {{domxref("EventTarget.addEventListener", "addEventListener()")}}, or set an event handler property.

js-nolint
addEventListener("complete", (event) => { })

oncomplete = (event) => { }

Event type

An {{domxref("OfflineAudioCompletionEvent")}}. Inherits from {{domxref("Event")}}.

{{InheritanceDiagram("OfflineAudioCompletionEvent")}}

Event properties

Also inherits properties from its parent, {{domxref("Event")}}.

  • {{domxref("OfflineAudioCompletionEvent.renderedBuffer")}} {{ReadOnlyInline}}
    • : An {{domxref("AudioBuffer")}} containing the result of processing an {{domxref("OfflineAudioContext")}}.

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:

js
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:

js
const offlineAudioCtx = new OfflineAudioContext();

offlineAudioCtx.oncomplete = () => {
  console.log("Offline audio processing now complete");
  alert("Song processed and ready to play");
  playBtn.disabled = false;
};

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also