export class AudioLoader {
    type = "audio";
    audioContext;
    constructor(audioContext) {
        this.audioContext = audioContext;
    }
    canLoad(request) {
        return /\.(?:mp3|wav|ogg|m4a|aac)(?:\?.*)?$/i.test(request.url);
    }
    async load(request, context) {
        context.throwIfAborted(request.url);
        if (typeof fetch !== "function") {
            throw new Error("AudioLoader requires fetch");
        }
        const response = await fetch(request.url, { signal: request.signal });
        if (!response.ok) {
            throw new Error(`Audio request failed with ${response.status}`);
        }
        const buffer = await this.audioContext.decodeAudioData(await response.arrayBuffer());
        return { url: request.url, buffer };
    }
}
//# sourceMappingURL=AudioLoader.js.map