Added ID3v2 support for FLAC files. (Fixes #417) (#418)

* Added ID3v2 support for FLAC files.  (Fixes #417)

* Fix ID3v2 header size calculation, adjust ID3v2 logic for FLAC files

---------

Co-authored-by: Vanilagy <[email protected]>
This commit is contained in:
Brad Isbell
2026-06-18 16:40:43 +00:00
committed by GitHub
co-authored by Vanilagy
parent 5b890efc29
commit 92a384f418
6 changed files with 117 additions and 17 deletions
+17 -1
View File
@@ -446,7 +446,23 @@ export class OggInputFormat extends InputFormat {
export class FlacInputFormat extends InputFormat {
/** @internal */
async _canReadInput(input: Input) {
let slice = input._reader.requestSlice(0, 4);
let currentPos = 0;
// There might be ID3v2 headers at the start, skip 'em
while (true) {
let slice = input._reader.requestSlice(currentPos, ID3_V2_HEADER_SIZE);
if (slice instanceof Promise) slice = await slice;
if (!slice) break;
const id3V2Header = readId3V2Header(slice);
if (!id3V2Header) {
break;
}
currentPos = slice.filePos + id3V2Header.size;
}
let slice = input._reader.requestSlice(currentPos, 4);
if (slice instanceof Promise) slice = await slice;
if (!slice) return false;