web-audio-api-rs icon indicating copy to clipboard operation
web-audio-api-rs copied to clipboard

Implement `resume` and `suspend` on `OfflineAudioContext`

Open orottier opened this issue 3 years ago • 1 comments
trafficstars

https://www.w3.org/TR/webaudio/#OfflineAudioContext-methods

Notice the suspend function has the rather odd feature that you can specify the suspend time. We can implement that (later) as an addiditonal method suspend_at

orottier avatar Jan 22 '22 09:01 orottier

[disclaimer] Not related to OfflineAudioContext and really not sure about that but,

I wonder if we shouldn't have the context suspended by default.

From what I understand from the spec, that's not mandatory (https://webaudio.github.io/web-audio-api/#allowed-to-start) because the context can be somehow allowed to start (mainly for not breaking early demos and web page I think). But I'm not sure that gives a good hint when you are used to the JS API, where you have to do (except in some magical conditions I've never understood and that may differ between browsers):

const context = new AudioContext();
$someButton.addEventListener('click', async () => {
   await context.resume();
   // now it's safe to use the `context`
});

I say that because, I was basically thinking that resume, suspend and close where just not fully implemented or working, when I realized that I didn't need to resume first (and true... I didn't took any time to test anything there :)

b-ma avatar Jan 24 '22 06:01 b-ma

Fixed with #412

orottier avatar Dec 28 '23 13:12 orottier