mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 07:50:13 +00:00
fix(core): a looping preview keeps playing when a scene reloads during a hold for data (#7659)
* fix(core): a looping preview keeps playing when a scene reloads during a hold for data A Studio preview unloads scenes far from the playhead. On a long film, the loop's wrap back to the start lands while the first scene is reloading: the film holds for its video, then the scene swap re-seeks with keepPlaying. The seek read the held film as paused, dropped the hold and parked the film at the start, so the loop stopped after its second pass. A seek that keeps playing now counts a hold for data as playing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(core): name the playing-or-held check and drop history from its test comment Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
d7202bd42a
commit
b8f630c643
@@ -283,6 +283,25 @@ it("a pause while buffering stays paused once the track is ready", () => {
|
||||
expect(states.at(-1)).toEqual({ isPlaying: false, buffering: false });
|
||||
});
|
||||
|
||||
// A Studio preview reloading a far scene re-seeks with keepPlaying. When that lands while the film is held
|
||||
// for data, the hold must survive it and the film plays on.
|
||||
it("a seek that keeps playing during a hold for data plays on once the track is ready", () => {
|
||||
const mark = document.createElement("meta");
|
||||
mark.name = STUDIO_PREVIEW_MARK_META;
|
||||
document.head.append(mark);
|
||||
const { voiceReady, states, playFor } = playPodcast(0, "video");
|
||||
|
||||
playFor(0.5);
|
||||
expect(states.at(-1)).toEqual({ isPlaying: true, buffering: true });
|
||||
window.__player!.seek(0, { keepPlaying: true });
|
||||
voiceReady.value = 4;
|
||||
playFor(1);
|
||||
|
||||
mark.remove();
|
||||
expect(window.__player!.getTime()).toBeGreaterThan(0.5);
|
||||
expect(states.at(-1)).toEqual({ isPlaying: true, buffering: false });
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
window.__hfRuntimeTeardown?.();
|
||||
vi.restoreAllMocks();
|
||||
|
||||
@@ -3231,6 +3231,7 @@ export function initSandboxRuntimeModular(): void {
|
||||
}
|
||||
};
|
||||
let bufferingFor: HTMLMediaElement[] = [];
|
||||
const playingOrHeldForData = () => clock.isPlaying() || bufferingFor.length > 0;
|
||||
let keepLateMedia = false;
|
||||
const preloadNearPlayhead = (
|
||||
el: HTMLMediaElement,
|
||||
@@ -4989,8 +4990,8 @@ export function initSandboxRuntimeModular(): void {
|
||||
const applySeek = (quantized: number, options?: { keepPlaying?: boolean }) => {
|
||||
webAudio.stopAll();
|
||||
clock.detachAudioSource();
|
||||
const wasPlaying = clock.isPlaying();
|
||||
if (wasPlaying) clock.pause();
|
||||
const wasPlaying = playingOrHeldForData();
|
||||
if (clock.isPlaying()) clock.pause();
|
||||
clock.seek(quantized);
|
||||
state.currentTime = clock.now();
|
||||
state.isPlaying = false;
|
||||
@@ -5160,7 +5161,7 @@ export function initSandboxRuntimeModular(): void {
|
||||
state.nativeMediaSyncDisabled ||
|
||||
isExportRenderDrivingFrames() ||
|
||||
window.__HF_EXPORT_RENDER_SEEK_CONFIG ||
|
||||
(options?.keepPlaying && clock.isPlaying())
|
||||
(options?.keepPlaying && playingOrHeldForData())
|
||||
) {
|
||||
previewSeek?.cancel();
|
||||
pausedFrames.clear();
|
||||
|
||||
Reference in New Issue
Block a user