fix(runtime): respect keepPlaying option in player seek#863
Open
calcarazgre646 wants to merge 1 commit into
Open
fix(runtime): respect keepPlaying option in player seek#863calcarazgre646 wants to merge 1 commit into
calcarazgre646 wants to merge 1 commit into
Conversation
The runtime player's seek unconditionally pauses on every invocation, so
A/E Jump-to-in/out shortcuts (which pass { keepPlaying: true } per PR
heygen-com#842) pause playback in compositions backed by the __player runtime
adapter. Only the wrapTimeline path honoured the option.
Extend RuntimePlayer.seek and the PlayerAPI contract to accept
{ keepPlaying?: boolean }. When keepPlaying is set and playback was
active, resume the master plus rearmed sibling timelines and emit the
play-state events so media and analytics stay in sync. Default behaviour
is unchanged when no options are passed.
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
Closes the follow-up I promised in #842 (comment): the
__playerruntime adapter ignored the{ keepPlaying: true }option that A/E Jump-to-in/out shortcuts send, so playback pauses on every press even though the caller asked to preserve it. Only thewrapTimeline(GSAP) path honoured the option.Background
PR #842 added
seek: (time, options?: { keepPlaying?: boolean })toPlaybackAdapterand wired the A/E shortcuts inusePlaybackKeyboardto pass{ keepPlaying: true }. The fix landed correctly for compositions backed by__timeline/__timelines(GSAP), becausewrapTimelinereads the option and skips its internaltl.pause().For compositions backed by
window.__player(packages/core/src/runtime/init.ts:1529),useTimelinePlayer.getAdapter()returns the runtime adapter directly without a wrapper. That adapter'sseekisbasePlayer.seekfromcreateRuntimePlayer(packages/core/src/runtime/player.ts:147), and the implementation was:setIsPlaying(false)runs unconditionally, so A/E pauses the moment the shortcut fires. The option that the Studio sends never reaches the implementation because both the localbasePlayershape increatePlayerApiCompatand the publicPlayerAPI.seek/RuntimePlayer.seektypes only declared(time: number) => void.Fix
Extend the type contract from end to end so the option is preserved through
createPlayerApiCompat:core.types.ts—PlayerAPI.seek(time, options?: { keepPlaying?: boolean })runtime/types.ts—RuntimePlayer.seeksignatureruntime/init.ts:88— localbasePlayershape increatePlayerApiCompatImplement the behaviour in
createRuntimePlayer.seek:wasPlayingbefore the deterministic seek helper pauses the master and rearmed siblings.options.keepPlaying && wasPlaying, resume the master + siblings, reapplyplaybackRateviatimeScale, and emitonDeterministicPlay+onShowNativeVideos+onSyncMedia(t, true)so media and analytics stay in sync.keepPlaying: false, orwasPlaying === false) keeps the existingsetIsPlaying(false)+onSyncMedia(t, false)path. No back-compat change.Test plan
Added 6 new tests in
packages/core/src/runtime/player.test.tsunderdescribe(\"keepPlaying option\"):keepPlaying: trueand playback was active (nosetIsPlaying(false), emitsonDeterministicPlay+onSyncMedia(t, true)).play()is invoked after the last internalpause()viainvocationCallOrder).playbackRateto master and siblings on resume.keepPlaying: truebut playback was not active (intent is preserve, not force).keepPlaying: falsematches default behaviour.Other validations:
bun run --cwd packages/core test→ 868/868 passing (was 862, +6 new).bun run --cwd packages/studio test→ 514/514 passing, no regression in the consuming side.bun run --cwd packages/core typecheckandbun run --cwd packages/studio typecheckclean.bunx oxlintandbunx oxfmt --checkclean on touched files.Out of scope
createStaticSeekPlaybackAdapterinpackages/studio/src/player/lib/playbackAdapter.tsstill hasseek: (time) => void(no options). Its current behaviour happens to preserve playback by accident (theplayingflag drives the RAF ticker independently), but the contract is mismatched. Happy to follow up if a maintainer wants the static-seek adapter brought in line with the same shape.Related
__playerpath concern.