Prefer non-forced when subtitle preference is always on (#1618)
## Description If subtitles preferences are "Always", this PR will prefer non-forced tracks even if any forced ones are default tracks. This is in-line with the web UI from my testing and another review of the code. ### Related issues Fixes https://github.com/damontecres/Wholphin/issues/790#issuecomment-4708705576 ### Testing Unit tests ## Screenshots N/A ## AI or LLM usage None
This commit is contained in:
parent
7422f15bff
commit
899e3decc2
2 changed files with 59 additions and 4 deletions
|
|
@ -277,11 +277,13 @@ class StreamChoiceService
|
|||
SubtitlePlaybackMode.ALWAYS -> {
|
||||
if (subtitleLanguage.isNotNullOrBlank()) {
|
||||
candidates.firstOrNull {
|
||||
it.language.equals(subtitleLanguage, true) ||
|
||||
it.language.isUnknown
|
||||
// Prefer non-forced first
|
||||
!it.isForced && it.language.equalsLangOrUnknown(subtitleLanguage)
|
||||
} ?: candidates.firstOrNull {
|
||||
it.language.equalsLangOrUnknown(subtitleLanguage)
|
||||
}
|
||||
} else {
|
||||
candidates.firstOrNull()
|
||||
candidates.firstOrNull { !it.isForced } ?: candidates.firstOrNull()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -371,3 +373,5 @@ private val String?.isUnknown: Boolean
|
|||
this.equals("undetermined", true) ||
|
||||
this.equals("mul", true) ||
|
||||
this.equals("zxx", true)
|
||||
|
||||
private fun String?.equalsLangOrUnknown(lang: String): Boolean = equals(lang, ignoreCase = true) || this.isUnknown
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue