Skip to content

fix: always respect manual subtitle and audio selections#509

Open
mattsigal wants to merge 1 commit into
Moonfin-Client:mainfrom
mattsigal:feature/osd-initial-track-display
Open

fix: always respect manual subtitle and audio selections#509
mattsigal wants to merge 1 commit into
Moonfin-Client:mainfrom
mattsigal:feature/osd-initial-track-display

Conversation

@mattsigal

Copy link
Copy Markdown
Contributor

Pull Request

Summary

Finally resolves the issue where user-selected subtitle and audio tracks on the details screen did not persist during server-side transcoding, direct streaming (remuxing), or when transitioning from a preroll video to the main feature video.

Related Issues

Link related issues or tickets separated by commas.

  • Closes #
  • Fixes #
  • Related to #

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Performance improvement
  • UI/UX update
  • Documentation update
  • Build/CI change
  • Other (describe):

Changes Made

  • Updated Jellyfin & Emby getPlaybackInfo implementations to pass the selected audio/subtitle indices in query parameters, forcing the server to register transcoding sessions with the correct user choices.
  • Leveraged Dart null-aware map elements (?) in server query parameters to satisfy the compiler and project-specific lint rules.
  • Replaced error-prone regex replacements with robust Uri query parsing in MediaStreamResolver.applyStreamIndices that updates/syncs both subtitleStreamIndex (camelCase) and SubtitleStreamIndex (PascalCase).
  • Added direct stream routing for index application and parameter stripping in resolvers and the PlaybackManager to match transcoding flows.
  • Bypassed track selection translation when transitioning from a preroll to the main item if pending item overrides are already present, preserving user choices.
  • Queued pending audio/subtitle selections in Media3VideoView.kt and deferred execution until track selection data is loaded via onTracksChanged (resolving timing/race conditions on ExoPlayer initialization). Cleared pending fields in setSource to prevent leaking selections to subsequent streams.
  • Lifted the details page action buttons' selection indices to the persistent ItemDetailViewModel to avoid reset when buttons are temporarily unmounted during detail screen view model reloads.
  • Configured details page to fallback to streams marked with IsDefault == true if preferred language user settings are empty.

Platform

  • Android
  • iOS
  • macOS
  • Windows
  • Linux
  • All / Shared code

Testing

Describe how this change was tested.

  • Tested on emulator / simulator
  • Tested on physical device
  • Manual testing completed
  • Not tested (explain why):

Test Steps

  1. Play transcoded media with manual subtitle tracks selected (e.g. Bulgarian, Czech, Danish) from details page. Verify manual tracks stick correctly on first play and subsequent trials.
  2. Play main media item with intro/preroll video active, verify choice is retained after preroll completes and main movie/show starts.
  3. Reload details page/return from player, verify selection indicator is persisted.

Screenshots (if applicable)

Demonstrating a file where a custom sub track was selected from Media Info page and the change reflected in both the UI and the subtitle:

Shield_Screenshot_2026-06-12_04-20-09

Checklist

  • Code builds successfully
  • Code follows project style and conventions
  • No unnecessary commented-out code
  • No new warnings introduced

…and direct streaming

- Pass selected subtitle and audio track indices explicitly in queryParameters for getPlaybackInfo requests in Jellyfin and Emby APIs to ensure server transcodes and initializes playback sessions with the chosen streams.
- Preserves track overrides when transitioning from a preroll to the main media item by bypassing translateTrackSelectionsForNewItem when overrides are applied.
- Implements a robust Uri-based query parameter replacement in MediaStreamResolver.applyStreamIndices, matching both camelCase and PascalCase variations.
- Route and apply track selections in PlaybackManager during direct stream (remuxing) bringup in addition to transcoding.
- Implement pending track selection queuing in native android Media3VideoView to handle race conditions where tracks are changed before they are fully loaded.
- Lift action buttons' selected track index states to the persistent ItemDetailViewModel to prevent resets during screen unmounting/viewmodel reloads.
- Fallback to streams marked as default when user's preferred default audio or subtitle settings are empty.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant