Skip to content

feat: multi-track subtitle selection#948

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

feat: multi-track subtitle selection#948
Ortes wants to merge 4 commits into
fluttercommunity:masterfrom
Ortes:feat/subtitle-tracks-upstream

Conversation

@Ortes

@Ortes Ortes commented May 31, 2026

Copy link
Copy Markdown
Contributor

Motivation

Streaming sources (notably HLS) expose multiple subtitle renditions in their manifest, but Chewie currently has no UI to let the user pick one. This adds a source-agnostic subtitle-track picker to the Material controls.

What this adds

  • A track picker in the options menu (plus an Off entry) that appears only when subtitleTracks is non-empty.
  • Support for streaming cues that arrive over time (via setLiveSubtitle), alongside the existing static subtitle cue list.

The widget is source-agnostic: the host populates the track list and reacts to selection; Chewie never assumes HLS or any particular backend.

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

ChewieController:

  • List<SubtitleTrack> subtitleTracks — selectable tracks (default empty).
  • Object? activeSubtitleTrackId — currently selected id (null = Off).
  • void Function(SubtitleTrack?)? onSubtitleTrackChanged — selection callback.
  • setSubtitleTracks() / selectSubtitleTrack() — for tracks known only after load.
  • setLiveSubtitle(String?) + ValueNotifier<String?> liveSubtitle — push current cue text for streaming sources.
  • bool get hasSubtitleTracks — gates the menu entry.

New: SubtitleTrack model and SubtitleTrackDialog 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 tracks.

Testing

  • dart analyze — no issues.
  • In production use in an HLS web player (subtitle tracks parsed from the manifest, cues pushed via setLiveSubtitle).

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

Generalise subtitle support beyond a single on/off cue list: the controller
now holds a source-agnostic list of selectable SubtitleTracks, an active id
and an onSubtitleTrackChanged callback, plus a liveSubtitle ValueNotifier for
streaming sources (e.g. HLS) that emit cue text over time.

- ChewieController: subtitleTracks / activeSubtitleTrackId /
  onSubtitleTrackChanged / liveSubtitle, setSubtitleTracks, selectSubtitleTrack,
  setLiveSubtitle; copyWith + dispose wired.
- Material + Material desktop controls: a Subtitles entry in the options menu
  opening a track picker, live-cue rendering reusing subtitleBuilder, and a
  track-aware toggle.
- SubtitleTrackDialog widget + SubtitleTrack model.
@codecov

codecov Bot commented May 31, 2026

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Patch % Lines
lib/src/material/material_controls.dart 98.24% 1 Missing ⚠️
lib/src/material/material_desktop_controls.dart 98.24% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master     #948       +/-   ##
===========================================
+ Coverage   43.82%   58.30%   +14.48%     
===========================================
  Files          21       23        +2     
  Lines        1602     1746      +144     
===========================================
+ Hits          702     1018      +316     
+ Misses        900      728      -172     

☔ 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 added 3 commits May 31, 2026 20:25
Adds unit and widget tests for the new subtitle-track API:
- SubtitleTrack model (equality, hashCode, toString)
- SubtitleTrackDialog (rendering, selection, custom off label, dismissal)
- ChewieController track methods (setSubtitleTracks, selectSubtitleTrack,
  setLiveSubtitle, copyWith, dispose, hasSubtitleTracks)
- Material and desktop controls: toggle-driven selection, options-menu
  track picker, live-cue and static-cue rendering, custom subtitleBuilder

Brings patch coverage to ~99%.
The Material controls passed the optionsTranslation subtitle label into the
SubtitleTrackDialog's "off" entry, but the desktop controls always showed the
hardcoded "Off". Mirror the Material behavior so both variants honor
optionsTranslation.subtitlesButtonText.
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