mwg API
    Preparing search index...

    Interface Playable

    The surface mwg/audio needs from a playing sound - exactly what HTMLAudioElement already provides, named here so a test (or a game with its own audio backend) can supply a fake without a real Audio element 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 questions HTMLAudioElement answers implicitly: currentTime reads and seeks the playhead and holds the duration once a track that does not loop has ended; playbackRate is honoured (by resampling) or ignored but never throws; onended fires once at the end of a track that does not loop and never for one that does; and play() may return a promise that settles when the audio is allowed to start.

    interface Playable {
        currentTime: number;
        loop: boolean;
        onended?: ((event: Event) => unknown) | null;
        playbackRate?: number;
        volume: number;
        pause(): void;
        play(): void | Promise<void>;
    }

    Hierarchy (View Summary)

    Implemented by

    Index
    currentTime: number
    loop: boolean
    onended?: ((event: Event) => unknown) | null

    Optional completion hook, matching HTMLAudioElement.onended. Backends without an end event can omit it; single-track Music remains fully usable there.

    playbackRate?: number

    speed and pitch together, matching HTMLAudioElement.playbackRate; 1 is unchanged

    volume: number