diff --git a/packages/core/src/runtime/mediaProxy.test.ts b/packages/core/src/runtime/mediaProxy.test.ts index df1582870e6..ef86ed2269a 100644 --- a/packages/core/src/runtime/mediaProxy.test.ts +++ b/packages/core/src/runtime/mediaProxy.test.ts @@ -1354,6 +1354,41 @@ describe("preview quality: lighter copies of heavy files", () => { } }); + // fails without the fix: the still was asked without the lighter-copy mark, so Studio's server refused it for a + // browser-safe H.264 file (422 browser_safe_codec) and the held clip showed black for as long as its copy took. + it("stands in its own frame from the server, asked as a lighter copy's still, while it is held", async () => { + const { el } = await waitingForItsCopy(making); + const media = await import("./media"); + media.syncRuntimeMedia({ + clips: [ + { + el, + start: 0, + mediaStart: 4, + duration: 10, + end: 10, + volume: null, + playbackRate: 1, + loop: false, + sourceDuration: null, + }, + ], + timeSeconds: 1, + playing: false, + playbackRate: 1, + getCompositionDuration: () => 0, + }); + await vi.advanceTimersByTimeAsync(2_000); + + const poster = new URL(el.getAttribute("poster")!, document.baseURI); + expect([...poster.searchParams]).toEqual([ + ["hf-proxy", "auto"], + ["hf-proxy-box", "2048x1218"], + ["hf-proxy-light", "1"], + ["hf-proxy-still", "5.0"], + ]); + }); + async function twoHeldOnScreen(facts: PreviewSourceFacts = HEAVY) { vi.useFakeTimers(); let made = false; diff --git a/packages/core/src/runtime/mediaProxy.ts b/packages/core/src/runtime/mediaProxy.ts index 5e24ec20c1e..03ceefeddcd 100644 --- a/packages/core/src/runtime/mediaProxy.ts +++ b/packages/core/src/runtime/mediaProxy.ts @@ -409,10 +409,11 @@ function showStill( originalSrc: string, variant: string, box: PreviewProxyBox | null, + light: boolean, ): void { const at = sourceTimeAtPlayhead(el); if (at === undefined || stills.has(el) || el.hasAttribute("poster")) return; - const url = new URL(appendProxyParam(originalSrc, variant, box), document.baseURI); + const url = new URL(appendProxyParam(originalSrc, variant, box, light), document.baseURI); url.searchParams.set(PREVIEW_PROXY_STILL_PARAM, at.toFixed(1)); stills.add(el); el.setAttribute("poster", url.href); @@ -586,7 +587,7 @@ async function makeCopy(el: HTMLMediaElement, job: CopyJob, scale: number | null (fraction) => noteCopy(el, "making", fraction, light), () => isActiveAtPlayhead(el), false, - light && !held ? undefined : () => showStill(el, originalSrc, variant, box), + light && !held ? undefined : () => showStill(el, originalSrc, variant, box, light), ); const wanted = live(); if (!served || !wanted) sizedBeforeCopy.delete(el);