--- title: suspend slug: Web/API/OfflineAudioContext/suspend translation_of: Web/API/OfflineAudioContext/suspend ---
{{ APIRef("Web Audio API") }}
The suspend()
method of the {{ domxref("OfflineAudioContext") }} interface schedules a suspension of the time progression in the audio context at the specified time and returns a promise. This is generally useful at the time of manipulating the audio graph synchronously on OfflineAudioContext.
Note that the maximum precision of suspension is the size of the render quantum and the specified suspension time will be rounded down to the nearest render quantum boundary. For this reason, it is not allowed to schedule multiple suspends at the same quantized frame. Also scheduling should be done while the context is not running to ensure the precise suspension.
OfflineAudioContext.suspend(suspendTime).then(function() { ... });
A {{jsxref("Promise")}} resolving to void.
发生任何异常,promise就会拒绝.
如果帧数出现下列情况,就会抛出错误{{exception("InvalidStateError")}}:
Specification | Status | Comment |
---|---|---|
{{SpecName('Web Audio API', '#widl-OfflineAudioContext-suspend-Promise-void--double-suspendTime', 'suspend()')}} | {{Spec2('Web Audio API')}} | Initial definition. |
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | {{CompatChrome(49.0)}} |
Feature | Android | Android Webview | Firefox Mobile (Gecko) | Firefox OS | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|---|
Basic support | {{CompatNo}} | {{CompatChrome(49.0)}} | {{CompatChrome(49.0)}} |