Repository navigation
fix(web): start autoplay countdown when entering post-roll early - #162
Conversation
When a series episode reaches 30s before its end, the player enters post-roll and pauses the underlying video to stop HLS from buffering the tail segment. A paused video never fires the `ended` event, but the PlayingNextScreen countdown was gated on `postRollVideoEnded`, which only became true on `ended`. The result: the "Up Next" overlay appears, the video is paused, and the countdown never starts — it only resumes if the user manually plays the video (letting it reach the end and fire `ended`). Arm the countdown gate at the moment we enter post-roll early, since that is the point at which we've decided playback is over, rather than waiting for an `ended` event that an intentionally-paused video will never emit.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughIn ChangesPost-roll autoplay countdown fix
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
When a series episode reaches 30s before its end, the player enters post-roll and pauses the underlying video to stop HLS from buffering the tail segment. A paused video never fires the `ended` event, but the PlayingNextScreen countdown was gated on `postRollVideoEnded`, which only became true on `ended`. The result: the "Up Next" overlay appears, the video is paused, and the countdown never starts — it only resumes if the user manually plays the video (letting it reach the end and fire `ended`). Arm the countdown gate at the moment we enter post-roll early, since that is the point at which we've decided playback is over, rather than waiting for an `ended` event that an intentionally-paused video will never emit.
Problem
On a series episode, the web player enters post-roll ~30s before the end and pauses the underlying video (intentional —
VideoPlayer's post-roll effect pauses to stop HLS buffering the tail segment). However, the auto-play countdown inPlayingNextScreenis gated onpostRollVideoEnded, which is only set totrueon the nativeendedevent.A paused video never fires
ended, so:ended.Reported symptom (Silo Web, Win11/Firefox): "Picture-in-picture video pauses on transition to auto-play screen. Countdown for auto-play never starts. Will start working if you manually resume the video." — the player pauses exactly 30s before the end.
Approach
Arm the countdown gate (
setPostRollVideoEnded(true)) at the moment we enter post-roll early inhandlePlaybackStateChange, rather than waiting for anendedevent that an intentionally-paused video will never emit. Entering post-roll early is the point at which we've decided playback is effectively over, so that is the correct moment to start the countdown. The existingended-driven and fallback paths are unchanged.One-file change in
web/src/playback/WatchPlaybackChrome.tsx.Testing
cd web && pnpm run lint— 0 errorscd web && pnpm run format:check— cleanmake verify-local-paths— cleantsc -b— cleanpnpm test— playback/WatchRoute suites pass (the 5 failingServerStorageSteptests are a pre-existingResizeObserver is not definedenv issue, confirmed failing on cleanmain, unrelated to this change)Note: verified statically and via the test suite; not yet exercised in a live browser session against a running deployment.
Risk / scope
Bug fix, behavior-only, no API or schema changes. Auto-play for movies (no
series_id) is unaffected — the early post-roll trigger only fires for series episodes.Out of scope: a separate
404 GET /api/v1/catalog/items/{id}symptom observed in the same report (next-item detail lookup) is not addressed here; this PR fixes the countdown stall only.AI-use disclosure
This change was implemented with AI assistance (Claude). The diff was reviewed and the reasoning/tradeoffs are as described above.
Summary by CodeRabbit