fix(studio): a long audio file from outside the project is never decoded for its waveform (#7961)

This commit is contained in:
Miguel Ángel
2026-11-16 17:20:32 +00:00
committed by GitHub
parent 5f46379775
commit c77cd301c8
2 changed files with 24 additions and 1 deletions
@@ -190,6 +190,27 @@ describe("useRenderClipContent", () => {
if (isValidElement(content)) expect(content.type).toBe(AudioWaveform);
});
it("decodes a file from outside the project only when it is short and its length is known", () => {
const remote = (sourceDuration?: number) =>
renderClipContent({
id: "talk",
tag: "audio",
start: 0,
duration: 4,
track: 1,
src: "https://cdn.example.com/talk.mp3",
sourceDuration,
});
const audioUrlOf = (content: ReactNode) =>
isValidElement<{ audioUrl: string; waveformUrl?: string }>(content)
? [content.props.audioUrl, content.props.waveformUrl]
: null;
expect(audioUrlOf(remote(180))).toEqual(["https://cdn.example.com/talk.mp3", undefined]);
expect(audioUrlOf(remote(62 * 60))).toEqual(["", undefined]);
expect(audioUrlOf(remote())).toEqual(["", undefined]);
});
it("routes root-relative iframe media back through the active project", () => {
usePlayerStore.setState({ thumbnailMode: "adaptive" });
const resolvedRootMedia = `${window.location.origin}/assets/clip.mp4`;
@@ -25,6 +25,7 @@ import {
import { usePlayerStore } from "../player/store/playerStore";
import { thumbnailRevisionOf } from "../player/store/thumbnailSlice";
import { effectiveThumbnailMode } from "../player/lib/thumbnailPolicy";
import { fitsBeatAnalysis } from "../utils/timelineInspector";
export function normalizeCompositionSrc(
compSrc: string,
@@ -84,8 +85,9 @@ function renderAudioClip(
? buildProjectApiPath(pid, `/waveform/${encodedRelative}`)
: undefined;
const { start, end } = trimFractions(el);
const serverPeaksOrShortFile = waveformUrl !== undefined || fitsBeatAnalysis(el);
const waveform = createElement(AudioWaveform, {
audioUrl,
audioUrl: serverPeaksOrShortFile ? audioUrl : "",
waveformUrl,
label: "",
labelColor,