diff --git a/app/src/main/kotlin/com/arflix/tv/ui/components/TrailerPlayer.kt b/app/src/main/kotlin/com/arflix/tv/ui/components/TrailerPlayer.kt index dfc9400b..458269b0 100644 --- a/app/src/main/kotlin/com/arflix/tv/ui/components/TrailerPlayer.kt +++ b/app/src/main/kotlin/com/arflix/tv/ui/components/TrailerPlayer.kt @@ -96,12 +96,18 @@ fun TrailerPlayer( ) { val player = remember(youtubeKey) { ExoPlayer.Builder(context).build().apply { - repeatMode = Player.REPEAT_MODE_ONE + repeatMode = Player.REPEAT_MODE_OFF playWhenReady = true addListener(object : Player.Listener { override fun onPlayerError(error: androidx.media3.common.PlaybackException) { extractor.evictCache(youtubeKey) } + override fun onPlaybackStateChanged(playbackState: Int) { + if (playbackState == Player.STATE_ENDED) { + shouldPlay = false + onPlayingChanged(false) + } + } }) } } diff --git a/app/src/main/kotlin/com/arflix/tv/ui/screens/home/HomeScreen.kt b/app/src/main/kotlin/com/arflix/tv/ui/screens/home/HomeScreen.kt index c6ec420a..b0134000 100644 --- a/app/src/main/kotlin/com/arflix/tv/ui/screens/home/HomeScreen.kt +++ b/app/src/main/kotlin/com/arflix/tv/ui/screens/home/HomeScreen.kt @@ -835,6 +835,8 @@ fun HomeScreen( var isTrailerPlaying by remember { mutableStateOf(false) } var trailerSuppressed by remember { mutableStateOf(false) } LaunchedEffect(displayHeroItem?.id) { trailerSuppressed = false } + val heroRowIsContinueWatching = latestDisplayCategories + .getOrNull(focusState.currentRowIndex)?.id == "continue_watching" val trailerOverlayAlpha = remember { Animatable(1f) } LaunchedEffect(isTrailerPlaying) { if (isTrailerPlaying) { @@ -1002,7 +1004,7 @@ fun HomeScreen( } // YouTube trailer auto-play (sound controlled by trailerSoundEnabled setting) - if (heroVideoUrl == null && uiState.trailerAutoPlay && uiState.heroTrailerKey != null && !trailerSuppressed) { + if (heroVideoUrl == null && uiState.trailerAutoPlay && uiState.heroTrailerKey != null && !trailerSuppressed && !heroRowIsContinueWatching) { TrailerPlayer( youtubeKey = uiState.heroTrailerKey!!, delayMs = uiState.trailerDelaySeconds * 1000L,