Remember the last-picked audio/subtitle track per item - #74
Merged
Conversation
Adds TrackPreferenceStore, a per-user/per-item UserDefaults store (modeled on MediaVersionPreferenceStore) that records the audio track and subtitle track (or explicit "Off") a user last picked during playback. PlayerViewModel.start() restores that choice right after engine.load() returns, overriding whatever default/forced-subtitle selection the engine just settled on. A fresh item with no history falls through to that existing default behavior unchanged. Track ids are physical container positions, not stable identifiers, so a stored choice also carries the track's title and is only restored when a track with the same id *and* title still exists in the freshly loaded list — guards against both a track disappearing entirely and a reordered layout silently reassigning an id to a different track. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…ck-preference-memory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a small QOL feature: the player now remembers the audio/subtitle track a user last explicitly picked for an item, and restores it the next time they play that same item — instead of always falling back through the default/forced-subtitle selection.
How
TrackPreferenceStore(Core/Persistence/), modeled directly onMediaVersionPreferenceStore— plain per-userUserDefaults, keyed by item id.PlayerViewModel.selectAudioTrack(id:)/selectSubtitleTrack(id:)now persist the track's{id, title}(or.off) alongside delegating to the engine.PlayerViewModel.start()restores the stored choice right afterengine.load(...)returns, overriding whatever defaultAetherPlaybackEngine(including its forced-subtitle auto-select) already settled on.Why title, not just id
Track ids are physical container positions, not stable identifiers — the same id can point at a different track next time if the layout reorders (a different version resolved, a re-mux) even with the track count unchanged. Each stored choice carries the track's own title, and a restore only applies when both the id and title still match the freshly loaded track list — otherwise it's skipped, same "fall back gracefully" treatment as elsewhere in this codebase (
requestedMediaSourceID).Testing
TrackPreferenceStoreTests.swift(new) + 7 new/updated cases inPlayerViewModelTests.swift, including the id-matches-but-title-doesn't scenario.🤖 Generated with Claude Code