Restart video from the beginning on reveal#122
Merged
Conversation
The video autoplays muted from t=0 on page load, so by the time someone actually clicks the decoy - anywhere from a second to minutes later depending how long it holds their attention - the audio unmutes wherever playback has already drifted to, often cutting off the intro entirely. Fixes #121
- Cache Playwright's browser binaries (the slow part of installing it) across runs, keyed on a pinned exact version instead of a floating playwright@1. OS-level deps still install fresh every run since Actions runners aren't persistent, but that's fast on ubuntu-latest. - Cache the Docker build's video-fetch stage via GHA cache, same as ghcr-publish.yml already does - this workflow always builds the same default VIDEO_URL, so there's no reason to re-download it every run. - Extend test-autoplay.js to let muted autoplay run for a few seconds before clicking, then assert currentTime resets to near 0 after the click - regression coverage for the restart-on-reveal fix earlier in this PR.
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
t=0the moment the page loads, but the decoy overlay (loading/error) can hold someone's attention for anywhere from a second to several minutes before they actually click it. By the time they do, the unmuted playback lands wherever the video has already drifted to - often well past the intro.video.currentTime = 0right before unmuting/playing inreveal(), so the payoff always starts from the actual song opening regardless of how long the click took.Buffering is unaffected by this change. The video still starts fetching/buffering the instant the page loads, exactly as before - it's still autoplaying muted the whole time the decoy is up, so playback is never "starting fresh" on click. This change only rewinds the playback position at the moment of reveal; it doesn't change when or how the browser loads the video. Since the start of the file is therefore already buffered (that's the part that's been playing muted since page load), seeking back to it on click is instant with no rebuffering or stutter.
Fixes #121
Also in this PR
ghcr-publish.ymlalready does. Cuts a cold CI run from ~3min to ~1m30s.test-autoplay.jsnow lets muted autoplay run for a few seconds before clicking, then assertscurrentTimeresets to near 0 after - regression coverage for the restart-on-reveal fix above.Test plan
test-autoplay.js, both overlays, Chromium + Firefox, including the newcurrentTimeassertion) andtest-mobile-fit.jsall passing.