@@ -14,6 +14,7 @@ import androidx.compose.runtime.mutableStateListOf
1414import androidx.compose.runtime.mutableStateOf
1515import androidx.compose.runtime.setValue
1616import androidx.compose.ui.util.fastAny
17+ import androidx.compose.ui.util.fastForEach
1718import androidx.compose.ui.util.fastMapNotNull
1819import androidx.media3.common.C
1920import androidx.media3.common.Format
@@ -364,6 +365,8 @@ class FlixclusivePlayerManager(
364365 extractAudios()
365366 extractEmbeddedSubtitles()
366367
368+ areTracksInitialized = true
369+
367370 val subtitleIndex =
368371 when {
369372 ! subtitlesPreferences.isSubtitleEnabled -> 0 // == Off subtitles
@@ -379,10 +382,11 @@ class FlixclusivePlayerManager(
379382 languageExtractor = { it },
380383 )
381384
382- onSubtitleChange(index = subtitleIndex)
383- onAudioChange(index = audioIndex)
384-
385- areTracksInitialized = true
385+ onSubtitleChange(index = audioIndex)
386+ onAudioChange(index = subtitleIndex)
387+ } else {
388+ onSubtitleChange(index = selectedSubtitleIndex)
389+ onAudioChange(index = selectedAudioIndex)
386390 }
387391
388392 setPlaybackSpeed(playbackSpeed)
@@ -454,7 +458,7 @@ class FlixclusivePlayerManager(
454458 group.type == C .TRACK_TYPE_TEXT
455459 }
456460
457- subtitleTrackGroups.getFormats().forEach { format ->
461+ subtitleTrackGroups.getFormats().fastForEach { format ->
458462 // Filter out non subs, already used subs and subs without languages
459463 if (format.id == null || format.language == null ) {
460464 return
0 commit comments