Skip to content

StreamVault is a TV-first free IPTV player for Android TV built with Kotlin, Jetpack Compose, Room, Hilt, and Media3.

fix(track): update subtitle track selection logic to maintain user preferences

David Nashash54bea743e7f3
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index 4258f525..2907e0b2 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -10,6 +10,7 @@ All notable product changes are recorded in this document.
- Localized player recording notices and EPG recording messages across all supported locales.
### Fixed
+- Fixed selected subtitles reverting to off by saving track details before track-list refreshes and keeping the player's active preference in sync with manual selections.
- Fixed a compile failure in the recording-by-time dialog that prevented the app from building after the recording scheduling update, which also blocked Settings backup export and import.
- Fixed audio stopping after a while.
- Fixed the player crashing when scheduling a recording (Schedule, Record Daily, or Record Weekly): the recording coordinator called itself instead of the scheduling use case, causing a stack overflow.
@@ -66,7 +67,6 @@ All notable product changes are recorded in this document.
### Fixed
-- Fixed selected subtitles reverting to off by saving track details before the player refreshes its available subtitle list.
- Fixed Guide schedules briefly appearing and disappearing during background updates, and missing provider EPG requests for channels loaded after the first page.
- Fixed Jellyfin Quick Connect QR links to use the Web Quick Connect route and safely encode the pairing code.
- Fixed QR provider pairing session cleanup and request validation, including expired sessions, malformed or oversized submissions, slow clients, and duplicate submissions.
diff --git a/player/src/main/java/com/streamvault/player/tracks/PlayerTrackController.kt b/player/src/main/java/com/streamvault/player/tracks/PlayerTrackController.kt
index 470fbaeb..c5863d26 100644
--- a/player/src/main/java/com/streamvault/player/tracks/PlayerTrackController.kt
+++ b/player/src/main/java/com/streamvault/player/tracks/PlayerTrackController.kt
@@ -520,6 +520,9 @@ class PlayerTrackController(
fun selectSubtitleTrack(player: ExoPlayer, trackId: String?) {
if (trackId == null) {
+ vodTrackPreferences = (vodTrackPreferences ?: VodTrackPreferences()).copy(
+ subtitle = VodTrackPreference(disabled = true)
+ )
player.trackSelectionParameters = player.trackSelectionParameters
.buildUpon()
.setTrackTypeDisabled(C.TRACK_TYPE_TEXT, true)
@@ -528,6 +531,16 @@ class PlayerTrackController(
return
}
val override = findOverride(player.currentTracks, C.TRACK_TYPE_TEXT, trackId) ?: return
+ val selectedTrack = _availableSubtitleTracks.value.firstOrNull { it.id == trackId }
+ vodTrackPreferences = (vodTrackPreferences ?: VodTrackPreferences()).copy(
+ subtitle = selectedTrack?.let { track ->
+ VodTrackPreference(
+ trackId = track.id,
+ language = track.language,
+ label = track.name
+ )
+ } ?: VodTrackPreference(trackId = trackId)
+ )
player.trackSelectionParameters = player.trackSelectionParameters
.buildUpon()
.setTrackTypeDisabled(C.TRACK_TYPE_TEXT, false)