feat(player): add autoplay next episode with countdown overlay#57
Open
rogueburger21 wants to merge 1 commit into
Open
feat(player): add autoplay next episode with countdown overlay#57rogueburger21 wants to merge 1 commit into
rogueburger21 wants to merge 1 commit into
Conversation
- 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).
43267f9 to
329d1bd
Compare
codeCraft-Ritik
left a comment
There was a problem hiding this comment.
Great work! The implementation looks clean, and the change feels well-scoped.
truelockmc
requested changes
May 20, 2026
Owner
There was a problem hiding this comment.
Looks good so far, but here are some things I would like to have changed:
- 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.
- Also please move the newly added auto-play code segments into a new file (src/utils/useAutoplay)
- 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);- 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.
- 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.
- 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
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.
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
autoplayCountdownstate and refs to track when the video has ended.