Merge branch 'p1.2-w3-factory-wiring' into dev
This commit is contained in:
@@ -12,6 +12,8 @@ import { StreamDecoder } from './StreamDecoder.js';
|
|||||||
import { PlaybackScheduler } from './PlaybackScheduler.js';
|
import { PlaybackScheduler } from './PlaybackScheduler.js';
|
||||||
import { IFormatDecoder } from './IFormatDecoder.js';
|
import { IFormatDecoder } from './IFormatDecoder.js';
|
||||||
import { WavFormatDecoder } from './WavFormatDecoder.js';
|
import { WavFormatDecoder } from './WavFormatDecoder.js';
|
||||||
|
import { Mp3FormatDecoder } from './Mp3FormatDecoder.js';
|
||||||
|
import { FlacFormatDecoder } from './FlacFormatDecoder.js';
|
||||||
|
|
||||||
export interface AudioResult {
|
export interface AudioResult {
|
||||||
success: boolean;
|
success: boolean;
|
||||||
@@ -110,13 +112,16 @@ export class AudioPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Select a format decoder from the response Content-Type. MP3 and FLAC decoders
|
* Select a format decoder from the response Content-Type.
|
||||||
* 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();
|
|
||||||
*/
|
*/
|
||||||
private static createFormatDecoder(_contentType: string): IFormatDecoder {
|
private static createFormatDecoder(contentType: string): IFormatDecoder {
|
||||||
return new WavFormatDecoder();
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user