Skip to content

feat: multi-track audio selection - #949

Merged
diegotori merged 7 commits into
fluttercommunity:masterfrom
Fullphysio:feat/audio-tracks-upstream
Sep 16, 2026
Merged

diegotori merged 7 commits into
fluttercommunity:masterfrom
Fullphysio: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.

@codecov

codecov Bot commented May 31, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.89041% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.18%. Comparing base (00d4b3a) to head (a0ddf90).
⚠️ Report is 1 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 ⚠️
lib/src/models/audio_track.dart 90.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #949      +/-   ##
==========================================
+ Coverage   77.70%   78.18%   +0.48%     
==========================================
  Files          43       45       +2     
  Lines        2687     2760      +73     
==========================================
+ Hits         2088     2158      +70     
- Misses        599      602       +3     

☔ View full report in Codecov by Harness.
📢 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
@diegotori

Copy link
Copy Markdown
Collaborator

@Ortes please resolve the conflicts currently present in this PR. Thanks.

@Ortes
Ortes force-pushed the feat/audio-tracks-upstream branch from 98901d7 to 1d7e684 Compare August 12, 2026 06:20
Ortes added a commit to Fullphysio/chewie that referenced this pull request Aug 12, 2026
Ortes added a commit to Fullphysio/chewie that referenced this pull request Aug 15, 2026
@Ortes
Ortes force-pushed the feat/audio-tracks-upstream branch from 0d2d3dc to f012612 Compare August 15, 2026 11:13
@diegotori

Copy link
Copy Markdown
Collaborator

@Ortes please resolve conflicts. Thanks.

@Ortes
Ortes force-pushed the feat/audio-tracks-upstream branch from f012612 to 75fa79c Compare September 1, 2026 12:10
Ortes added a commit to Fullphysio/chewie that referenced this pull request Sep 1, 2026
@Ortes
Ortes force-pushed the feat/audio-tracks-upstream branch from 75fa79c to 4dbf779 Compare September 1, 2026 12:16
Ortes added a commit to Fullphysio/chewie that referenced this pull request Sep 1, 2026
@Ortes
Ortes force-pushed the feat/audio-tracks-upstream branch from 4dbf779 to a229792 Compare September 1, 2026 19:56
Ortes added a commit to Fullphysio/chewie that referenced this pull request Sep 9, 2026
@Ortes
Ortes force-pushed the feat/audio-tracks-upstream branch 2 times, most recently from 5322f0a to 9d9a668 Compare September 14, 2026 21:22
@Ortes
Ortes force-pushed the feat/audio-tracks-upstream branch from 9d9a668 to 4752956 Compare September 16, 2026 19:37
Ortes and others added 7 commits September 16, 2026 23:34
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>
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>
The Flutter 3.47 upgrade enabled prefer_initializing_formals. Keeps the
fields private, matching _PlaybackSpeedDialog in cupertino_controls.dart;
callers still pass tracks:/selectedId:.
@Ortes
Ortes force-pushed the feat/audio-tracks-upstream branch from 4752956 to a0ddf90 Compare September 16, 2026 21:36

@diegotori diegotori left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@diegotori
diegotori merged commit 875d4c1 into fluttercommunity:master Sep 16, 2026
5 checks passed
diegotori added a commit that referenced this pull request Sep 16, 2026
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.

2 participants