OptionalonendedOptional completion hook, matching HTMLAudioElement.onended. Backends without an end event can omit it; single-track Music remains fully usable there.
Optionalplaybackspeed and pitch together, matching HTMLAudioElement.playbackRate; 1 is unchanged
The surface
mwg/audioneeds from a playing sound - exactly whatHTMLAudioElementalready provides, named here so a test (or a game with its own audio backend) can supply a fake without a realAudioelement existing, which nothing outside a browser can create.A backend that synthesises its sound instead of decoding a file (see
StreamPlayable) has to answer the questionsHTMLAudioElementanswers implicitly:currentTimereads and seeks the playhead and holds the duration once a track that does not loop has ended;playbackRateis honoured (by resampling) or ignored but never throws;onendedfires once at the end of a track that does not loop and never for one that does; andplay()may return a promise that settles when the audio is allowed to start.