Skip to content

feat: multi-track audio selection - #949

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

feat: multi-track audio selection#949
Ortes wants to merge 4 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.

@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 56.65%. Comparing base (7a4631c) to head (f012612).
⚠️ Report is 15 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   51.21%   56.65%   +5.43%     
==========================================
  Files          25       27       +2     
  Lines        1728     1811      +83     
==========================================
+ Hits          885     1026     +141     
+ Misses        843      785      -58     

☔ 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 Ortes/chewie that referenced this pull request Aug 12, 2026
Ortes and others added 4 commits August 15, 2026 13:07
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>
@Ortes
Ortes force-pushed the feat/audio-tracks-upstream branch from 0d2d3dc to f012612 Compare August 15, 2026 11:13
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