Skip to content

fix: 🐛 Play mislabeled audio files on iOS/macOS#500

Open
lavigarg-simform wants to merge 1 commit into
mainfrom
fix/I113_ios_mismatched_parser
Open

fix: 🐛 Play mislabeled audio files on iOS/macOS#500
lavigarg-simform wants to merge 1 commit into
mainfrom
fix/I113_ios_mismatched_parser

Conversation

@lavigarg-simform

@lavigarg-simform lavigarg-simform commented Jun 25, 2026

Copy link
Copy Markdown

Description

On iOS/macOS the file extension picks the audio parser. Android often records AAC-in-MP4 but names the file .mp3 or .aac. The extension lies, so AVFoundation grabs the wrong parser and the file fails to load (or silently mis-parses, e.g. a bogus 8ms duration).

What changed

  • Before preparing the player, sniff the real container from the file's leading magic bytes.
  • If the real container disagrees with the extension, point the player at a temp symlink that carries the correct extension, so the right parser is chosen.
  • Detects MP4/M4A, WAV, FLAC, Ogg, MP3, and ADTS AAC.
  • Done once in the Dart layer, so iOS, macOS, and the waveform extractor path are all covered without duplicating logic in the native players.
  • If the bytes match nothing known, the path is left untouched — no behavior change for files that genuinely can't play.
  • No-op on other platforms.

Checklist

  • The title of my PR starts with a Conventional Commit prefix (fix:, feat:, docs: etc).
  • I have followed the Contributor Guide when preparing my PR.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • I have updated/added relevant examples in examples or docs.

Breaking Change?

  • Yes, this PR is a breaking change.
  • No, this PR is not a breaking change.

Related Issues

Closes #113

AVFoundation routes strictly by file extension on iOS/macOS. Android can record AAC-in-MP4 yet name the file `.mp3`/`.aac`, so the player either fails to load or silently mis-parses it (e.g. an 8ms bogus duration that never throws).

Sniff the real container from the file's leading magic bytes in Dart and,when it disagrees with the extension, prepare the player from a temp symlink carrying the correct extension so the right parser is chosen. Doing this once in the Dart layer covers iOS, macOS, and the waveform extractor path without duplicating logic across the native players.
@lavigarg-simform lavigarg-simform force-pushed the fix/I113_ios_mismatched_parser branch from 24ac0a2 to 377ce1a Compare June 25, 2026 13:47
@lavigarg-simform lavigarg-simform changed the base branch from fix/I432_finalise_recording_before_return to main June 25, 2026 13:48
@lavigarg-simform lavigarg-simform marked this pull request as ready for review June 25, 2026 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Recorded audio file from Android can't play in iOS. Android to Android, iOS to iOS & iOS to Android is fine.

1 participant