feat(audio): wire Mp3FormatDecoder and FlacFormatDecoder into AudioPlayer factory

This commit is contained in:
daniel-c-harvey
2026-06-11 09:32:33 -04:00
parent d3f1d6a8a0
commit 5d9ba1c953
+11 -6
View File
@@ -12,6 +12,8 @@ import { StreamDecoder } from './StreamDecoder.js';
import { PlaybackScheduler } from './PlaybackScheduler.js';
import { IFormatDecoder } from './IFormatDecoder.js';
import { WavFormatDecoder } from './WavFormatDecoder.js';
import { Mp3FormatDecoder } from './Mp3FormatDecoder.js';
import { FlacFormatDecoder } from './FlacFormatDecoder.js';
export interface AudioResult {
success: boolean;
@@ -110,13 +112,16 @@ export class AudioPlayer {
}
/**
* Select a format decoder from the response Content-Type. MP3 and FLAC decoders
* arrive in Wave 2; until then every format falls back to WAV. When Wave 2 lands,
* add the MP3/FLAC branches here, e.g.:
* if (contentType.includes('audio/mpeg')) return new Mp3FormatDecoder();
* Select a format decoder from the response Content-Type.
*/
private static createFormatDecoder(_contentType: string): IFormatDecoder {
return new WavFormatDecoder();
private static createFormatDecoder(contentType: string): IFormatDecoder {
if (contentType.includes('audio/mpeg') || contentType.includes('audio/mp3')) {
return new Mp3FormatDecoder();
}
if (contentType.includes('audio/flac') || contentType.includes('audio/x-flac')) {
return new FlacFormatDecoder();
}
return new WavFormatDecoder(); // default (audio/wav, unknown)
}
/**