Skip to content

Commit

Permalink
fix(player): resolve subtitles won't appear after screen time out
Browse files Browse the repository at this point in the history
  • Loading branch information
rhenwinch committed Feb 10, 2025
1 parent 1d17f7a commit 46e0d19
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.compose.ui.util.fastAny
import androidx.compose.ui.util.fastForEach
import androidx.compose.ui.util.fastMapNotNull
import androidx.media3.common.C
import androidx.media3.common.Format
Expand Down Expand Up @@ -364,6 +365,8 @@ class FlixclusivePlayerManager(
extractAudios()
extractEmbeddedSubtitles()

areTracksInitialized = true

val subtitleIndex =
when {
!subtitlesPreferences.isSubtitleEnabled -> 0 // == Off subtitles
Expand All @@ -379,10 +382,11 @@ class FlixclusivePlayerManager(
languageExtractor = { it },
)

onSubtitleChange(index = subtitleIndex)
onAudioChange(index = audioIndex)

areTracksInitialized = true
onSubtitleChange(index = audioIndex)
onAudioChange(index = subtitleIndex)
} else {
onSubtitleChange(index = selectedSubtitleIndex)
onAudioChange(index = selectedAudioIndex)
}

setPlaybackSpeed(playbackSpeed)
Expand Down Expand Up @@ -454,7 +458,7 @@ class FlixclusivePlayerManager(
group.type == C.TRACK_TYPE_TEXT
}

subtitleTrackGroups.getFormats().forEach { format ->
subtitleTrackGroups.getFormats().fastForEach { format ->
// Filter out non subs, already used subs and subs without languages
if (format.id == null || format.language == null) {
return
Expand Down

0 comments on commit 46e0d19

Please sign in to comment.