Skip to content

fix(player): keep the video playing when you jump to another moment - #2

Closed
robinebers wants to merge 7 commits into
mainfrom
fix/player-seek-keeps-playing
Closed

robinebers wants to merge 7 commits into
mainfrom
fix/player-seek-keeps-playing

Conversation

@robinebers

Copy link
Copy Markdown
Owner

Why

When you watch a video in the HyperFrames player and click somewhere on the progress bar to jump ahead, the video stops. You land on the new moment, frozen, and have to press play again. Dragging along the bar does the same. Every other video player, from YouTube to the browser's own, keeps playing from the new spot, so this feels broken. Apps that draw their own play button also fall out of sync, because the player stops without announcing it: paused turns true and no pause event fires.

What changes

  • Clicking or dragging the progress bar while a video plays keeps it playing from wherever you let go. While you hold the button down, the video waits on that frame, and it continues when you release, the way the browser's own video controls behave.
  • A paused video stays paused when you click or drag the bar.
  • Touch works the same way.
  • The play button keeps showing "pause" through the click.
  • Developers get the same choice for their own buttons and keyboard shortcuts: player.seek(30, { keepPlaying: true }) jumps without stopping. A plain player.seek(30) and player.currentTime = 30 still stop at the new time, exactly as before, so existing pages keep working the same way.
  • The package README and the docs page describe both.

Before

Clicking the bar at 65% while the video plays: it stops at 6.5 s. A drag afterwards leaves it stopped too.

Before: after the click the time stays at 6.5 s and the status reads paused

Watch the Before recording (MP4)

After

The same clicks: the video keeps playing from 6.5 s, and again from where the drag ends.

After: after the click the time keeps advancing and the status reads playing

Watch the After recording (MP4)

Test plan

Checked in Chrome 157 with the built player (dist/hyperframes-player.global.js) against a build of main, on four kinds of embed: an opaque-origin composition (sandbox-origin="opaque"), a same-origin composition, a composition that only registers window.__timelines, and an MP4 in video mode.

  • Clicking the bar at 70% while playing continues from 7.0 s (8.2 s one second later) on all four. Events arrive as pause then play, the same order Chrome's own <video controls> uses (pause, seeking, seeked, play, playing).
  • Dragging while playing continues from the release point.
  • Clicking or dragging while paused stays paused and fires no events.
  • A touch tap and a touch drag (Chrome touch emulation) continue playing with one pause/play pair.
  • The play button shows "pause" in all 89 frames recorded around a click.
  • seek(2, { keepPlaying: true }) while playing keeps playing and fires no events; seek(6) still lands paused.
  • bun run --cwd packages/player test (589 tests, 10 new, 6 of which fail on main), typecheck, oxlint, oxfmt, fallow, the comment checks and bun run verify:packed-manifests pass.

How

  • controls.ts: pressing the scrubber while playing pauses through the existing onPause callback and remembers that it did; releasing calls onPlay. The play button ignores state changes during that press. When a touch scrub ends, its touchend is cancelled so the browser doesn't follow the tap with mouse events, which would scrub a second time.
  • hyperframes-player.ts: seek(t, { keepPlaying: true }) runs the normal seek, then resumes through the internal play path (no second play event) if the player was playing or had a play queued while its assets loaded.
  • Size budget: packed 157,145 → 159,100. With CI's pnpm 10.17.1, main packs to 158,705 bytes, 11 under the old limit. This change adds 235 bytes of code and 104 bytes of README (159,044). The unpacked size stays within its budget.

Why seek() keeps pausing by default

Landing paused is seek()'s deliberate contract. Maintainer comments say so (heygen-com#750, heygen-com#4054), a test asserts it, and the loop wrap, play-range jumps and the scrubber's own settle rely on it. The runtime (heygen-com#863) and Studio (heygen-com#842) both made playing on an opt-in keepPlaying flag, so the player's API takes the same shape. The built-in controls are different: nothing chose for the scrubber to pause, it inherited seek()'s contract (heygen-com#890 noticed that a scrubber click pauses and made the audio match). CONTRIBUTING asks for default changes to be discussed, so treat this part as a proposal. If you'd rather keep today's scrubber behavior by default, it can move behind an attribute.

Notes

  • On the runtime paths, paused can read true for a few milliseconds after a keep-playing seek, until the runtime's next state message arrives. The same already happens after a loop wrap, and nothing changes on screen.
  • Clicking the very end of an MP4's bar while it plays restarts it, because play() at the end starts over (the player's existing rule, and the HTML one). Compositions end normally.
  • Open question: should setting currentTime keep playing, as it does on a <video>? This PR leaves it landing paused.

Related work

Open in Capy

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Edit accuracy: accurate 271 (base branch 271), smooth 61 of those

The gate passes.
Smoothness is reported in the artifact, not gated. A case fails only if it fails 2 of 3 runs.

Quarantined, measured but not gated (0)

Unstable (1)

  • seqplainkeys-none-pct-r0-root-z100: tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true / tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true / tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true

Clicking or dragging the scrubber while a film played left it paused at
the new spot, and `paused` turned true without a `pause` event. The
controls now hold a playing film during the press and play on from where
it is released, like a <video>'s own controls; a paused film stays
paused. A touch scrub no longer replays as mouse events.

seek() gains an opt-in { keepPlaying: true } for hosts (keyboard seeks,
chapter jumps). A plain seek(t), and setting currentTime, still land
paused, so existing callers keep their behavior.

The packed player tarball grows 339 bytes (158705 to 159044, packed with
pnpm 10.17.1 as CI does). main sat 11 bytes under the 1% gate, so the
packed budget moves to 159100; the unpacked size stays within budget.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@robinebers
robinebers force-pushed the fix/player-seek-keeps-playing branch from 53c33cf to 8a67bca Compare November 15, 2026 02:22
robinebers and others added 3 commits November 16, 2026 20:06
Brings the branch up to date with upstream main at 95e4e7f, which
adds the fullscreen button (heygen-com#7726) and the preview-freeze fix (heygen-com#7795).

Two files conflicted, both by appending to the same place:
- packages/player/src/controls.test.ts: this branch's scrubbing tests
  and main's fullscreen tests each added a describe block at the end.
  Both are kept.
- scripts/package-size-budgets.json: the player budget. Packed with
  pnpm 10.17.1 as CI packs it, the merged player is 160733 bytes packed
  and 550893 unpacked; main's own player is 160355 and 550015. The
  packed budget is the merged size rounded up to the next hundred,
  160800. The unpacked size stays inside its budget's 1% allowance.
…d cube-validate lines (heygen-com#8059)

heygen-com#8013 escaped resolve's results, recipes, stats and error lines, and
heygen-com#8087 the adopt skip line. A few resolve lines still printed their
values raw: argument errors that repeat --type, --provider, --from,
--reuse and the --for path, the measured-grade note and the
similar-asset hint that repeats the intent. cube-validate's error can
quote a value from the LUT file. They now go through the same
terminalText copy, so a control character shows as \xNN. --json output
is unchanged.
…heygen-com#8128)

A tag name went into new RegExp unescaped, so a page could hang or crash
the linter (heygen-com#8028). This test reads every RegExp the lint package builds
and fails when a template input is not escapeRegExp(...), an escaped*
name or an ALL_CAPS constant. Three inputs that cannot carry page text
are listed with the reason.
robinebers pushed a commit that referenced this pull request Nov 18, 2026
…com#8013)

* fix(cli): audio and media-use print control characters from project files as visible escapes

hyperframes audio, audio --read and media-use resolve (including
--candidates) printed file names, element ids, transcript words, model
descriptions and media manifest fields as they were. They now pass
through terminalText, so a control character shows as a visible \xNN
escape. The media-use engine runs without the CLI's packages, so it
carries a small copy of the helper. --json output is unchanged.

* fix(engine): playlist check refuses drive-relative and other colon-prefixed entries

ffmpeg reads an HLS or ffconcat entry with a colon before its first
separator as a URL or a drive, and opens it apart from the list's
folder. The folder check read entries such as C:Videos\a.mp4 or c:x.mp4
as names inside the folder and approved them. It now refuses any entry,
raw or percent-decoded, whose colon comes before its first /, \, ? or #,
as it already refuses absolute and parent-folder paths. http and https
segments are still kept.

* fix(cli): background-removal and Kokoro TTS model files are pinned to a sha256

The u2net_human_seg weights and the Kokoro model and voices files were
downloaded from release URLs and used whatever bytes arrived, and any
cached copy was trusted because it existed. Each file now has a pinned
size and sha256. A cached copy is checked before it is loaded and
downloaded again when it does not match. A download that does not
match is discarded with a message that names the file.

* fix(engine): playlist check reads entries from the folder ffmpeg uses

ffmpeg resolves a list's entries against its path cut at the first ? or
#. A list at proj/h#z/list.m3u8 naming ../h#z/x.ts was judged against
proj/h#z and approved, while ffmpeg opened proj/../h#z/x.ts. Entries are
now judged against the same cut folder. A list in a folder such as
"Take #2" still passes when its entries resolve inside that folder.

* fix(cli): a pinned model's cached copy is checked and removed under the download lock

ensurePinnedFile removed a cached copy that failed its check before the
download lock was taken, so a concurrent run could delete a file another
run had just published. downloadFile now takes a keepExisting check and
runs it under the lock: a copy that passes is kept, one that fails is
removed and downloaded again. The mismatch error now says the file does
not match its expected checksum, and that a retry helps only if the
download was interrupted or corrupted.

* fix(cli): audio escapes each field's line breaks, and media-use escapes recipe and stats output

The audio formatters escaped their output line by line, so a newline
inside a src, warning or transcript still printed as a real line break.
Each output line is now escaped whole with terminalText, which shows a
newline inside a field as \x0a. media-use resolve also escapes its
recipe lines and its --stats lines, which print recipe names, paths and
missed intents.

* fix(cli): media-use error messages show control characters as visible escapes

resolve printed error messages as they were, and some name project or
cache data, such as the known recipe names when a recipe is not found.
Every error: line now passes through terminalText, as the success lines
already do.

* ci: the edit accuracy filter includes the CLI model file check

The CLI's pinned model download now imports whisper/modelFile.ts, so a
change to it must run the edit accuracy bench too.

* test(cli): pinned model tests use private temp folders and rename like downloadFile

The tests wrote fixtures under fixed names in the shared temp folder,
and their download stand-in checked for a file before replacing it.
Each test now works in its own mkdtemp folder, and the stand-in asks
keepExisting directly and renames the part file into place, as
downloadFile does.

* test(cli): the media-use terminalText copy is checked against core's

The media-use engine keeps its own copy of terminalText. A CLI test now
compares the two over U+0000 to U+00A0, so a change to either fails
until both match. keepsDest moves above downloadFile's doc comment,
which belongs to downloadFile.
robinebers and others added 3 commits November 18, 2026 04:35
Brings the branch up to date with upstream main at a9b4745, which
adds the preview player branding (heygen-com#7718).

Two files conflicted:
- packages/player/src/controls.test.ts: this branch's scrubbing tests
  and main's page glyph slot tests each added a describe block in the
  same place. Both are kept.
- scripts/package-size-budgets.json: the player budget. Packed with
  pnpm 10.17.1 as CI packs it, the merged player is 161645 bytes packed
  and 553737 unpacked; main's own player is 161309 and 552859. Both fit
  under main's budget of 162000 and 554000, so main's line is kept and
  this branch no longer changes the budget file.
* fix(cli): run global updates from the home directory

* fix(cli): skip self-updates inside package scripts and explain unsafe homes
@capy-ai

capy-ai Bot commented Nov 18, 2026

Copy link
Copy Markdown

Merged upstream as heygen-com#7719.

@capy-ai capy-ai Bot closed this Nov 18, 2026
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