feat: post-episode Up Next prompt + honor autoPlayNext setting (#86) - #126
Merged
Conversation
When a TV episode ends, PlayerScreen previously called onPlayNext()
immediately with zero UI feedback — users were abruptly dropped into the
next episode with no way to cancel except by hitting back. It also ignored
the profile's autoPlayNext setting entirely, so users who disabled
auto-advance still got silently advanced at the end of every episode.
NextEpisodeOverlay has been fully implemented for a while (~260 LOC with
countdown ring, focus handling, Back/Escape cancel, Enter confirm) but was
never invoked anywhere — confirmed by grep. This PR finally wires it up.
Changes:
- Add `autoPlayNext: Boolean` to PlayerUiState, load it from DataStore at
the start of loadDetails via the existing
profileManager.profileBooleanKey("auto_play_next") path that
SettingsViewModel already uses to persist the toggle. The player now
respects the setting for the first time.
- Add overlay state vars (showNextEpisodePrompt + pending next-episode
metadata) to PlayerScreen.
- Replace the unconditional onPlayNext() call in the STATE_ENDED handler
with a state transition that shows the overlay. Gated on autoPlayNext —
when disabled we stay on the ended frame instead of advancing.
- Add re-entry guards: only fires once per session (showNextEpisodePrompt
guard), doesn't fire while error/source/subtitle overlays are visible.
- Render NextEpisodeOverlay after StreamSelector in the UI tree, wired to
onPlayNext (advances) / onCancel (stays on ended frame) / 10-second
countdown (auto-advances).
- Include showNextEpisodePrompt in the container-focus LaunchedEffect key
set so the overlay's own onKeyEvent handler receives D-pad input
without the background container stealing focus.
- Use a generic "Episode N" label in the overlay rather than exposing the
current episode's title, since fetching the *upcoming* episode's
metadata would require an extra TMDB round-trip during playback. Show
title, S/E number, and backdrop give users enough context to decide.
Closes #86
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #86.
Adds the post-episode "Up Next" prompt with Continue / Cancel buttons and a 10-second countdown at the end of every TV episode. Also fixes a long-standing bug where the player ignored the
autoPlayNextprofile setting entirely.Root cause
Two separate bugs, both in
PlayerScreen.kt:1251-1262:onPlayNext()was called immediately with zero UI feedback. Users were abruptly dropped into the next episode with no way to cancel except by hitting back.autoPlayNextsetting at all — users who disabled auto-advance in Settings still got silently advanced at the end of every episode.NextEpisodeOverlay.kthas been fully implemented for a while (~260 LOC, countdown, focus handling, Back/Escape cancel, Enter confirm) but was never invoked anywhere — confirmed by grep across the entire project. This PR finally wires it up.Changes
1. Player respects the autoPlayNext setting
autoPlayNext: Boolean = truefield onPlayerUiState.PlayerViewModel.loadDetails()loads it from DataStore viaprofileManager.profileBooleanKey("auto_play_next")— the same keySettingsViewModelalready uses to persist the toggle. This was the missing link that made the setting a no-op for the player.2. Overlay state machine in PlayerScreen
showNextEpisodePrompt+pendingNextSeason/pendingNextEpisode/pendingNextAddonId/pendingNextSourceName/pendingNextBingeGroupstate vars.onPlayNext(...)call in theSTATE_ENDEDbranch with a state transition that captures the next-episode parameters and shows the overlay.mediaType == TV(unchanged).uiState.autoPlayNext— when disabled we stay on the ended frame.!showNextEpisodePromptprevents the tick loop (200-500ms) from re-triggering.showSourceMenu,showSubtitleMenu, oruiState.error != null.showNextEpisodePromptto the container-focusLaunchedEffectkey set so the overlay's ownonKeyEventhandler receives D-pad input without the background container stealing focus.3. Render the overlay
Placed after
StreamSelectorin the UI tree. Uses:showTitle→uiState.title(show name)episodeTitle→ generic"Episode N"for the upcoming episode (see note below)seasonNumber/episodeNumber→pendingNextSeason/pendingNextEpisodeepisodeImage→uiState.backdropUrl(show backdrop — we don't have the next episode's still)countdownSeconds→ 10onPlayNext→ hide overlay + call the existingonPlayNext(...)lambda with the pending parametersonCancel→ hide overlay, stay on the ended frameWhy a generic "Episode N" label instead of the next episode's title
Fetching the upcoming episode's metadata (name, overview, still image) would require an extra TMDB
/tv/{id}/season/{n}/episode/{m}round-trip at end-of-episode time. For this PR I'm keeping the scope tight and using a generic label — the show title, S/E number, and show backdrop still give users enough context to decide Continue / Cancel. A follow-up PR could prefetch the next episode's still during playback if we want the richer preview.Test plan
true).Risk
Low. The existing STATE_ENDED path was unconditional and ignored the setting — this PR strictly adds behavior (setting gate + overlay UI) and replaces the auto-advance with an overlay-gated advance. When autoPlayNext is true and the user takes no action, the net behavior is the same as before plus a 10-second countdown UI. When autoPlayNext is false, the new behavior (stay on frame) is what users who disabled the setting were expecting all along.