Skip to content

feat: multi-track audio selection#949

Open
Ortes wants to merge 3 commits into
fluttercommunity:masterfrom
Ortes:feat/audio-tracks-upstream
Open

feat: multi-track audio selection#949
Ortes wants to merge 3 commits into
fluttercommunity:masterfrom
Ortes:feat/audio-tracks-upstream

Conversation

@Ortes

@Ortes Ortes commented May 31, 2026

Copy link
Copy Markdown
Contributor

Motivation

Streaming sources (notably HLS) expose multiple audio renditions (languages, commentary, codecs) in their manifest, but Chewie has no UI to switch between them. This adds a source-agnostic audio-track picker to the Material controls.

What this adds

  • An audio-track picker in the options menu, shown only when more than one track is available (a single track offers nothing to choose).
  • Unlike subtitles, audio is never "off": one track is always active.

The widget is source-agnostic: the host populates the track list and performs the actual rendition switch; Chewie never assumes HLS or any particular backend.

API (all opt-in — defaults preserve current behavior)

ChewieController:

  • List<AudioTrack> audioTracks — selectable tracks (default empty).
  • Object? activeAudioTrackId — currently selected id.
  • void Function(AudioTrack)? onAudioTrackChanged — selection callback.
  • setAudioTracks() / selectAudioTrack() — for tracks known only after load.
  • bool get hasAudioTracks — true only when length > 1; gates the menu entry.

New: AudioTrack model and AudioTrackDialog bottom sheet.

Backwards compatibility

Fully backwards compatible — every field is optional and defaults to the current behavior. No menu entry appears unless the host provides more than one track.

Testing

  • dart analyze — no issues.
  • In production use in an HLS web player (audio renditions parsed from the manifest, switched on selection).

Independent of the subtitle-track PR (#948) — single commit, based on master.

Mirror the subtitle-track support for audio: the controller now holds a
source-agnostic list of selectable AudioTracks, an active id and an
onAudioTrackChanged callback. Unlike subtitles, audio is never "off" — one
track is always active, and the menu entry only shows when more than one
track exists.

- ChewieController: audioTracks / activeAudioTrackId / onAudioTrackChanged /
  hasAudioTracks, setAudioTracks, selectAudioTrack; copyWith wired.
- Material + Material desktop controls: an Audio entry in the options menu
  opening a track picker.
- AudioTrackDialog widget + AudioTrack model.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@codecov

codecov Bot commented May 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.26027% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 52.83%. Comparing base (69a8fc7) to head (98901d7).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
lib/src/material/material_controls.dart 93.75% 1 Missing ⚠️
lib/src/material/material_desktop_controls.dart 93.75% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #949      +/-   ##
==========================================
+ Coverage   43.82%   52.83%   +9.01%     
==========================================
  Files          21       23       +2     
  Lines        1602     1675      +73     
==========================================
+ Hits          702      885     +183     
+ Misses        900      790     -110     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Ortes Ortes marked this pull request as ready for review May 31, 2026 20:49
Ortes and others added 2 commits May 31, 2026 20:24
Add tests for the new audio-track feature so the patch is exercised and
codecov/patch stops reporting 0% on the changed lines:

- AudioTrack model: equality, hashCode, toString, optional language
- ChewieController: hasAudioTracks, setAudioTracks, selectAudioTrack,
  copyWith propagation, onAudioTrackChanged callback
- AudioTrackDialog widget: tile rendering, selection check icon, language
  hint, tap-to-pick and dismiss-with-null
- MaterialControls & MaterialDesktopControls: options menu surfaces the
  Audio entry only when >1 track and drives selection end to end

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant