mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-16 06:19:21 +00:00
fix(player): slideshow no auto-progress + presenter slide fits/pins
- navigation jumps to a static frame instead of auto-playing the timeline: playTo() seeks to the hold (+ a brief RENDER_NUDGE to repaint) rather than sustaining playback, so slides hold until the user advances - presenter view: pin the live slide to the top and confine the player to the region above the notes panel, so the player CONTAINS the composition — the full slide stays visible (letterboxed) at any width and re-fits on resize; its bottom is no longer cut off by the notes panel - tests: seek targets updated for the render-nudge offset Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
cc75257909
commit
2e5e63c68e
@@ -66,10 +66,12 @@ function showAtSlide1InDeep() {
|
||||
}
|
||||
|
||||
describe("SlideshowController linear nav", () => {
|
||||
it("enters the first slide on construction: seek to start + play", () => {
|
||||
it("enters the first slide on construction: jumps to the first hold (no auto-play)", () => {
|
||||
const p = fakePlayer();
|
||||
new SlideshowController(p, SHOW);
|
||||
expect(p.seek).toHaveBeenCalledWith(0);
|
||||
// No auto-play: jumps to the first hold (fragments[0]=2), seeking just before
|
||||
// it (minus the render-nudge) so the composition repaints.
|
||||
expect(p.seek).toHaveBeenCalledWith(1.8);
|
||||
expect(p.play).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -99,7 +101,7 @@ describe("SlideshowController linear nav", () => {
|
||||
p.emit(4);
|
||||
c.next(); // no more fragments — advance to slide b immediately
|
||||
expect(c.position.slideIndex).toBe(1);
|
||||
expect(p.seek).toHaveBeenLastCalledWith(5);
|
||||
expect(p.seek).toHaveBeenLastCalledWith(9.8); // slide b end (10) minus render-nudge
|
||||
});
|
||||
|
||||
it("next() on a slide with NO fragments advances to the next slide immediately", () => {
|
||||
@@ -123,7 +125,7 @@ describe("SlideshowController linear nav", () => {
|
||||
// slide 0 has no fragments; one next() should advance immediately to slide 1
|
||||
c2.next();
|
||||
expect(c2.position.slideIndex).toBe(1);
|
||||
expect(p2.seek).toHaveBeenLastCalledWith(5);
|
||||
expect(p2.seek).toHaveBeenLastCalledWith(9.8); // slide b end (10) minus render-nudge
|
||||
});
|
||||
|
||||
it("next() on the last slide is a no-op", () => {
|
||||
@@ -186,7 +188,7 @@ describe("SlideshowController branching", () => {
|
||||
c.enterBranch("deep");
|
||||
expect(c.position.sequenceId).toBe("deep");
|
||||
expect(c.currentSlide?.sceneId).toBe("c");
|
||||
expect(p.seek).toHaveBeenLastCalledWith(10);
|
||||
expect(p.seek).toHaveBeenLastCalledWith(12.8); // slide c end (13) minus render-nudge
|
||||
});
|
||||
|
||||
it("counter is scoped to the current sequence", () => {
|
||||
@@ -256,7 +258,7 @@ describe("SlideshowController Fix 8b — back() restores parent fragmentIndex",
|
||||
expect(c.position.sequenceId).toBe("main");
|
||||
expect(c.position.slideIndex).toBe(0);
|
||||
expect(c.position.fragmentIndex).toBe(1);
|
||||
expect(p.seek).toHaveBeenLastCalledWith(4); // fragments[1] = 4
|
||||
expect(p.seek).toHaveBeenLastCalledWith(3.8); // fragments[1] (4) minus render-nudge
|
||||
});
|
||||
|
||||
it("back() when parent fragmentIndex=-1 seeks to slide start", () => {
|
||||
@@ -354,8 +356,8 @@ describe("SlideshowController Fix #backToMain — restores fragment position lik
|
||||
expect(c.position.sequenceId).toBe("main");
|
||||
expect(c.position.slideIndex).toBe(0);
|
||||
expect(c.position.fragmentIndex).toBe(1);
|
||||
// resumeSlide seeks to the fragment time (fragments[1]=4)
|
||||
expect(p.seek).toHaveBeenLastCalledWith(4);
|
||||
// resumeSlide seeks to the fragment time (fragments[1]=4) minus the render-nudge
|
||||
expect(p.seek).toHaveBeenLastCalledWith(3.8);
|
||||
});
|
||||
|
||||
it("backToMain when root fragmentIndex=-1 seeks to slide start", () => {
|
||||
@@ -602,7 +604,7 @@ describe("SlideshowController syncTo", () => {
|
||||
// resumeSlide seeks to slide start, then plays one frame so the composition
|
||||
// repaints (a bare paused seek doesn't re-render some compositions); onTime
|
||||
// pauses again as soon as the player reports it has reached the hold.
|
||||
expect(p.seek).toHaveBeenLastCalledWith(10);
|
||||
expect(p.seek).toHaveBeenLastCalledWith(9.8); // slide start (10) minus render-nudge
|
||||
expect(p.play).toHaveBeenCalled();
|
||||
p.emit(50); // player passes the render-nudge hold
|
||||
expect(p.pause).toHaveBeenCalled();
|
||||
@@ -615,7 +617,7 @@ describe("SlideshowController syncTo", () => {
|
||||
expect(c.position.sequenceId).toBe("main");
|
||||
expect(c.position.slideIndex).toBe(0);
|
||||
expect(c.position.fragmentIndex).toBe(1);
|
||||
expect(p.seek).toHaveBeenLastCalledWith(4);
|
||||
expect(p.seek).toHaveBeenLastCalledWith(3.8); // fragments[1] (4) minus render-nudge
|
||||
});
|
||||
|
||||
it("ignores an unknown sequence target", () => {
|
||||
|
||||
@@ -105,14 +105,16 @@ export class SlideshowController {
|
||||
this.holdAt = null;
|
||||
const slide = this.currentSlide;
|
||||
if (!slide) return;
|
||||
this.player.seek(slide.start);
|
||||
// Jump to the slide's first hold (its first fragment, or the built end-state
|
||||
// when it has none). playTo() seeks rather than sustaining playback, so the
|
||||
// slide does NOT auto-progress — it shows a static frame and waits.
|
||||
this.playTo(this.nextStop(slide, -1));
|
||||
this.emitChange();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resumes a slide at a saved fragmentIndex without resetting to slide start.
|
||||
* Used by back() to restore the caller's exact position in the parent slide.
|
||||
* Used by back()/backToMain()/syncTo() to restore an exact position.
|
||||
*/
|
||||
private resumeSlide(index: number, fragmentIndex: number): void {
|
||||
this.frame.slideIndex = index;
|
||||
@@ -124,14 +126,8 @@ export class SlideshowController {
|
||||
fragmentIndex >= 0 && fragmentIndex < slide.fragments.length
|
||||
? (slide.fragments[fragmentIndex] ?? slide.start)
|
||||
: slide.start;
|
||||
// Seek to the target, then play a short way PAST it so the composition
|
||||
// actually repaints — a bare seek while paused does not re-render some
|
||||
// compositions (the audience mirror would otherwise stay frozen on the first
|
||||
// frame), and pausing on the very first timeupdate fires before a paint.
|
||||
// onTime() pauses once playback passes the hold (~a few frames later).
|
||||
const renderHold = Math.min(seekTime + RENDER_NUDGE, slide.end);
|
||||
this.player.seek(seekTime);
|
||||
this.playTo(renderHold);
|
||||
this.holdAt = null;
|
||||
this.playTo(seekTime);
|
||||
this.emitChange();
|
||||
}
|
||||
|
||||
@@ -140,8 +136,16 @@ export class SlideshowController {
|
||||
return next ?? slide.end;
|
||||
}
|
||||
|
||||
/**
|
||||
* Jump to hold time `t` and pause there — NO sustained playback, so slides
|
||||
* never auto-progress. Seeks just before `t` and plays a short render-nudge
|
||||
* ending at `t`: a bare paused seek doesn't repaint some compositions, and
|
||||
* pausing on the first timeupdate fires before a paint. onTime() pauses at `t`
|
||||
* and advances fragmentIndex when `t` is a fragment boundary.
|
||||
*/
|
||||
private playTo(t: number): void {
|
||||
this.holdAt = t;
|
||||
this.player.seek(Math.max(0, t - RENDER_NUDGE));
|
||||
this.player.play();
|
||||
}
|
||||
|
||||
@@ -167,7 +171,7 @@ export class SlideshowController {
|
||||
if (!slide) return;
|
||||
const hasMoreFragments = this.frame.fragmentIndex + 1 < slide.fragments.length;
|
||||
if (hasMoreFragments) {
|
||||
// Reveal the next fragment (play-to-hold). onTime() advances fragmentIndex at the hold.
|
||||
// Reveal the next fragment. onTime() advances fragmentIndex at the hold.
|
||||
const nextTarget = this.nextStop(slide, this.frame.fragmentIndex);
|
||||
this.playTo(nextTarget);
|
||||
this.emitChange();
|
||||
|
||||
@@ -561,8 +561,17 @@ export class HyperframesSlideshow extends HTMLElement {
|
||||
const elapsedSec =
|
||||
this.presenterStartMs !== null ? Math.floor((Date.now() - this.presenterStartMs) / 1000) : 0;
|
||||
|
||||
// Confine the live slide (the player) to the top region so the speaker-notes
|
||||
// panel sits BELOW it — slide above, notes below.
|
||||
// Pin the live slide to the TOP and reserve the bottom 32% for the notes
|
||||
// panel. The player contains the composition, so the FULL slide stays visible
|
||||
// (letterboxed) at any width — its bottom is never hidden behind the panel —
|
||||
// and it re-fits to the top region on window resize.
|
||||
const playerEl = this.querySelector("hyperframes-player");
|
||||
if (playerEl instanceof HTMLElement) {
|
||||
playerEl.style.top = "0";
|
||||
playerEl.style.bottom = "32%";
|
||||
playerEl.style.height = "auto";
|
||||
}
|
||||
|
||||
if (!this.chrome) {
|
||||
this.chrome = document.createElement("div");
|
||||
this.chrome.setAttribute("data-hf-chrome", "");
|
||||
|
||||
Reference in New Issue
Block a user