Repository navigation
feat(player): remember subtitle and audio picks for the whole series #681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
63 changes: 63 additions & 0 deletions
63
...src/androidMain/kotlin/org/siloserver/silo/common/player/video/PendingSeriesTrackPicks.kt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| package org.siloserver.silo.common.player.video | ||
|
|
||
| import org.siloserver.silo.model.playback.SubtitleIdentity | ||
|
|
||
| /** | ||
| * The viewer's track picks waiting for playback to take them. A pick is | ||
| * remembered for the series only once it lands: a staged pick can be refused | ||
| * and a committed one rolled back, and either leaves the earlier track | ||
| * playing. Each pick is handed back at most once. | ||
| * | ||
| * An audio pick the player switches to itself ([local]) lands when the player | ||
| * is on the track; one the server must deliver lands when its replan commits. | ||
| * Called from the player and from the track transaction's persistence, which | ||
| * may run on another thread. | ||
| */ | ||
| class PendingSeriesTrackPicks { | ||
| private var subtitle: SubtitleIdentity? = null | ||
| private var audio: Pair<Int, Boolean>? = null | ||
|
|
||
| @Synchronized | ||
| fun pickSubtitle(identity: SubtitleIdentity) { | ||
| subtitle = identity | ||
| } | ||
|
|
||
| @Synchronized | ||
| fun pickAudio(catalogOrdinal: Int, local: Boolean) { | ||
| audio = catalogOrdinal to local | ||
| } | ||
|
|
||
| /** Whether [committed] is the subtitle the viewer picked. */ | ||
| @Synchronized | ||
| fun takeSubtitle(committed: SubtitleIdentity): Boolean { | ||
| if (subtitle?.isSameTrackAs(committed) != true) return false | ||
| subtitle = null | ||
| return true | ||
| } | ||
|
|
||
| /** Whether [catalogOrdinal], landing [local]ly or through a replan, is the audio the viewer picked. */ | ||
| @Synchronized | ||
| fun takeAudio(catalogOrdinal: Int?, local: Boolean): Boolean { | ||
| if (catalogOrdinal == null || audio != (catalogOrdinal to local)) return false | ||
| audio = null | ||
| return true | ||
| } | ||
|
|
||
| @Synchronized | ||
| fun clear() { | ||
| subtitle = null | ||
| audio = null | ||
| } | ||
| } | ||
|
|
||
| /** The same track, though playback may deliver it another way (an embedded track as a sidecar). */ | ||
| private fun SubtitleIdentity.isSameTrackAs(other: SubtitleIdentity): Boolean = | ||
| this == other || serverIndexOrNull()?.let { it == other.serverIndexOrNull() } == true || | ||
| this is SubtitleIdentity.Downloaded && other is SubtitleIdentity.Downloaded && downloadId == other.downloadId | ||
|
|
||
| private fun SubtitleIdentity.serverIndexOrNull(): Int? = when (this) { | ||
| is SubtitleIdentity.ServerSidecar -> serverIndex | ||
| is SubtitleIdentity.ServerBurnIn -> serverIndex | ||
| is SubtitleIdentity.Embedded -> serverIndex | ||
| else -> null | ||
| } | ||
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
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Audio preference persistence fails on mobile when playback exhausts local selection attempts and falls back to replanForDesiredAudio: its successful transaction calls takeAudio with local=false, which cannot consume the pending local=true entry, so the series never remembers the successfully applied pick. Track pending intent independently of its initial delivery path or update that path when initiating fallback.
Prompt for LLM
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.