diff --git a/DeepDrftPublic/Interop/audio/AudioPlayer.ts b/DeepDrftPublic/Interop/audio/AudioPlayer.ts index 0ec05f6..8e7e183 100644 --- a/DeepDrftPublic/Interop/audio/AudioPlayer.ts +++ b/DeepDrftPublic/Interop/audio/AudioPlayer.ts @@ -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) } /**