--- title: 'OfflineAudioContext: complete event' slug: Web/API/OfflineAudioContext/complete_event translation_of: Web/API/OfflineAudioContext/complete_event original_slug: Web/API/OfflineAudioContext/complete ---

{{DefaultAPISidebar("Web Audio API")}}

complete当离线音频上下文的呈现完成时,将触发{{domxref("OfflineAudioContext")}}接口事件。

泡泡 没有
取消 没有
默认操作 没有
接口 {{domxref( "OfflineAudioCompletionEvent")}}
事件处理程序属性 {{domxref( "OfflineAudioContext.oncomplete")}}

例子

处理完成后,您可能希望使用oncomplete处理程序提示用户现在可以播放音频,并启用播放按钮:

offlineAudioCtx.addEventListener('complete',()=> {
  console.log('Offline audio processing now complete');
  showModalDialog('Song processed and ready to play');
  playBtn.disabled = false;
})

You can also set up the event handler using the {{domxref("OfflineAudioContext.oncomplete")}} property:

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

Specifications

Specification Status Comment
{{SpecName('Web Audio API', '#OfflineAudioCompletionEvent-section', 'OfflineAudioCompletionEvent')}} {{Spec2('Web Audio API')}}  

Browser compatibility

{{Compat("api.OfflineAudioContext.complete_event")}}

See also