web-audio-api-rs
web-audio-api-rs copied to clipboard
Implement `resume` and `suspend` on `OfflineAudioContext`
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
[disclaimer] Not related to
OfflineAudioContextand 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 :)
Fixed with #412