{"record":{"id":"ab34f342a35f79c9","repo":"remotion-dev/remotion","slug":"no-src-was-passed-to-newaudioforpreview","errorCode":null,"errorMessage":"No `src` was passed to <NewAudioForPreview>.","messagePattern":"No `src` was passed to <NewAudioForPreview>\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/media/src/audio/audio-for-preview.tsx","lineNumber":113,"sourceCode":"\n\tconst volumePropFrame = useFrameForVolumeProp(\n\t\tloopVolumeCurveBehavior ?? 'repeat',\n\t);\n\n\tconst userPreferredVolume = evaluateVolume({\n\t\tframe: volumePropFrame,\n\t\tvolume,\n\t\tmediaVolume,\n\t});\n\n\twarnAboutTooHighVolume(userPreferredVolume);\n\n\tif (!videoConfig) {\n\t\tthrow new Error('No video config found');\n\t}\n\n\tif (!src) {\n\t\tthrow new TypeError('No `src` was passed to <NewAudioForPreview>.');\n\t}\n\n\tconst currentTime = frame / videoConfig.fps;\n\n\tconst currentTimeRef = useRef(currentTime);\n\tcurrentTimeRef.current = currentTime;\n\n\tconst preloadedSrc = usePreload(src);\n\n\tconst parentSequence = useContext(SequenceContext);\n\tconst isPremounting = Boolean(parentSequence?.premounting);\n\tconst isPostmounting = Boolean(parentSequence?.postmounting);\n\tconst sequenceOffset = (parentSequence?.absoluteFrom ?? 0) / videoConfig.fps;\n\n\tconst bufferingContext = useContext(Internals.BufferingContextReact);\n\n\tif (!bufferingContext) {\n\t\tthrow new Error(","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media/src/audio/audio-for-preview.tsx#L95-L131","documentation":"Thrown by <NewAudioForPreview> in @remotion/media when the `src` prop is falsy during Studio preview. The internal preview component needs a concrete URL to preload and play audio, so an empty/undefined source is a hard error rather than silent silence.","triggerScenarios":"Rendering <Audio src={undefined} />, <Audio src={''} />, or <Audio src={null} /> inside a composition that runs in Remotion Studio preview. Typically the src is bound to a variable that is not yet populated (e.g. a staticFile path computed conditionally).","commonSituations":"Loading audio src from props that are optional and not yet set, building src from a template that yields empty string, or forgetting to call staticFile() on an asset that lives in public/.","solutions":["Provide a non-empty string src: <Audio src={staticFile('audio.mp3')} />.","If audio is optional, conditionally render the component: {src && <Audio src={src} />}.","Verify the src variable is populated before the composition renders (check the prop value in Studio)."],"exampleFix":"// before\n<Audio src={audioUrl} /> // audioUrl may be undefined during preview\n\n// after\n{audioUrl ? <Audio src={audioUrl} /> : null}","handlingStrategy":"validation","validationCode":"const audioSrc = typeof src === 'string' && src.length > 0 ? src : null;\nreturn audioSrc ? <Audio src={audioSrc} /> : null;","typeGuard":"const isNonEmptyString = (v: unknown): v is string =>\n  typeof v === 'string' && v.trim().length > 0;","tryCatchPattern":null,"preventionTips":["Conditionally render <Audio> only when src is a non-empty string.","Resolve all staticFile() paths at module load so they are never undefined during preview.","Type optional audio props and default them before reaching the component."],"tags":["audio","src","preview","media","validation"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}