feat(player): add autoplay next episode with countdown overlay#57
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.
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
|
@rogueburger21 Hi, are you still going to work on this PR? If not, I will merge your current changes into a new branch and implement the requests from my review. |
|
Hey @truelockmc — yes, still on it! Sorry for the delay. I've worked through all the points from your review and I'm just doing a final pass before pushing. Pushing the commit shortly! |
Addresses review feedback on PR truelockmc#57: - Move autoplay countdown logic into a dedicated src/utils/useAutoplay hook - Add an "Autoplay Next Episode" section to Settings > Playback: enable/disable toggle, configurable countdown duration, and overlay side (left/right). A duration of 0 shows the overlay with buttons only and does not auto-advance. - Persist the new keys (autoplayNextEnabled / autoplayNextDuration / autoplayNextLayout) and add them to backup.js - Trigger the overlay using the existing watchedThreshold instead of a hardcoded 5s - Read nextEp from an always-current ref inside the countdown interval so the correct episode plays if season data reloads mid-countdown - Redesign the overlay: darkened player with a side panel showing the next episode's still, title, and larger Cancel / Play Now actions Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Addresses review feedback on PR truelockmc#57: - Move autoplay countdown logic into a dedicated src/utils/useAutoplay hook - Add an "Autoplay Next Episode" section to Settings > Playback: enable/disable toggle, configurable countdown duration, and overlay side (left/right). A duration of 0 shows the overlay with buttons only and does not auto-advance. - Persist the new keys (autoplayNextEnabled / autoplayNextDuration / autoplayNextLayout) and add them to backup.js - Trigger the overlay using the existing watchedThreshold instead of a hardcoded 5s - Read nextEp from an always-current ref inside the countdown interval so the correct episode plays if season data reloads mid-countdown - Redesign the overlay: darkened player with a side panel showing the next episode's still, title, and larger Cancel / Play Now actions
2516f2c to
6f3e254
Compare
Addresses review feedback on PR truelockmc#57: - Move autoplay countdown logic into a dedicated src/utils/useAutoplay hook - Add an "Autoplay Next Episode" section to Settings > Playback: enable/disable toggle, configurable countdown duration, and overlay side (left/right). A duration of 0 shows the overlay with buttons only and does not auto-advance. - Persist the new keys (autoplayNextEnabled / autoplayNextDuration / autoplayNextLayout) and add them to backup.js - Trigger the overlay using the existing watchedThreshold instead of a hardcoded 5s - Read nextEp from an always-current ref inside the countdown interval so the correct episode plays if season data reloads mid-countdown - Redesign the overlay: darkened player with a side panel showing the next episode's still, title, and larger Cancel / Play Now actions
6f3e254 to
6c7a228
Compare
|
Done |
|
Thanks : ) |


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.