Skip to content

feat(player): add autoplay next episode with countdown overlay#57

Open
rogueburger21 wants to merge 1 commit into
truelockmc:mainfrom
rogueburger21:feature/autoplay-countdown
Open

feat(player): add autoplay next episode with countdown overlay#57
rogueburger21 wants to merge 1 commit into
truelockmc:mainfrom
rogueburger21:feature/autoplay-countdown

Conversation

@rogueburger21
Copy link
Copy Markdown
Contributor

@rogueburger21 rogueburger21 commented May 16, 2026

Addresses #16

Description

This PR implements an autoplay feature for TV series. When an episode finishes, a countdown overlay appears, allowing the user to seamlessly transition to the next episode or cancel autoplay.

Changes

  • Autoplay Lifecycle: Introduced autoplayCountdown state and refs to track when the video has ended.
  • Countdown Trigger: Automatically initiates a 5-second countdown when the video has 1 second or less remaining.
  • Overlay UI: Added a blurred overlay over the player with the next episode's title and a countdown timer. Includes "Cancel" and "Play Now" actions.
  • Playback: Ensures playback proceeds automatically to the next available, unrestricted episode.

@rogueburger21 rogueburger21 mentioned this pull request May 16, 2026
11 tasks
- Detect when current episode reaches its final seconds and trigger
  an autoplay countdown via a new useEffect tied to the video
  progress polling loop.
- Render a full-screen overlay showing a circular countdown timer
  (10 → 0) with "Play Now" and "Cancel" controls so users stay in
  charge of the transition.
- Automatically advance to the next episode when the timer expires,
  using the existing playEpisode helper and episode ordering logic.
- Guard against edge cases: unreleased episodes, last-episode-of-
  season boundaries, and rapid re-triggers via a ref-based lock
  (countdownStartedRef).
@rogueburger21 rogueburger21 force-pushed the feature/autoplay-countdown branch from 43267f9 to 329d1bd Compare May 16, 2026 18:15
Copy link
Copy Markdown

@codeCraft-Ritik codeCraft-Ritik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! The implementation looks clean, and the change feels well-scoped.

Copy link
Copy Markdown
Owner

@truelockmc truelockmc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good so far, but here are some things I would like to have changed:

  1. Could you wire it up into the Settings tho? In the Playback category. You should be able to dis-/enable it and change how long the timer is before it plays. (Also add the new storage keys to backup.js then) If the timer is set to 0 it should just show the overlay with buttons and not play automatically.
  2. Also please move the newly added auto-play code segments into a new file (src/utils/useAutoplay)
  3. I think it would make sense to use the autoplay next together with the already existing Auto-Watched thing. So that once the amount of time remaining is smaller then that treshold it shows the overlay, instead of hardcoding that to 5s.
const [watchedThreshold] = useState(() => storage.get("watchedThreshold") ?? 20);
  1. Please add a cancel button to cancel the countdown and continue playing the current episode. You described that in your PR, but i do not see it here.
  2. You dont have to do this, but i think it'd be cool if the overlay darkened over the whole player. But the Episode titel and the cover image of that Episode would be shown only in the right or left part of the player (that could also be changed in the settings). Then the "Cancel" and "Play now" button (should be bigger than it is right now) should be shown below that.
  3. Track nextEp in a ref that's always current, and read from that inside the interval instead of the closure.
const nextEpRef = useRef(nextEp);
useEffect(() => { nextEpRef.current = nextEp; }, [nextEp]);

// inside the interval callback:
playEpisode(nextEpRef.current);

Because if nextEp changes while the countdown is active (e.g. season data reloads mid-countdown, or a race condition on episode group fetch), the wrong episode plays. This is unlikely but rather safe than sorry ig.

Please tell me what you think of the design idea (5.) and implement the other things : )

tysm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants