{"record":{"id":"ff3aac5088f6da68","repo":"remotion-dev/remotion","slug":"cannot-change-the-behavior-for-pre-mounting-audio","errorCode":null,"errorMessage":"Cannot change the behavior for pre-mounting audio tags dynamically.","messagePattern":"Cannot change the behavior for pre-mounting audio tags dynamically\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/audio/AudioForPreview.tsx","lineNumber":49,"sourceCode":"type AudioForPreviewProps = RemotionAudioProps & {\n\treadonly shouldPreMountAudioTags: boolean;\n\treadonly onDuration: (src: string, durationInSeconds: number) => void;\n\treadonly pauseWhenBuffering: boolean;\n\treadonly _remotionInternalNativeLoopPassed: boolean;\n\treadonly _remotionInternalStack: string | null;\n\treadonly showInTimeline: boolean;\n\treadonly onNativeError: React.ReactEventHandler<HTMLAudioElement>;\n};\n\nconst AudioForDevelopmentForwardRefFunction: React.ForwardRefRenderFunction<\n\tHTMLAudioElement,\n\tAudioForPreviewProps\n> = (props, ref) => {\n\tconst [initialShouldPreMountAudioElements] = useState(\n\t\tprops.shouldPreMountAudioTags,\n\t);\n\tif (props.shouldPreMountAudioTags !== initialShouldPreMountAudioElements) {\n\t\tthrow new Error(\n\t\t\t'Cannot change the behavior for pre-mounting audio tags dynamically.',\n\t\t);\n\t}\n\n\tconst logLevel = useLogLevel();\n\n\tconst {\n\t\tvolume,\n\t\tmuted,\n\t\tplaybackRate,\n\t\tpreservePitch,\n\t\tshouldPreMountAudioTags,\n\t\tsrc,\n\t\tonDuration,\n\t\tacceptableTimeShiftInSeconds,\n\t\t_remotionInternalNeedsDurationCalculation,\n\t\t_remotionInternalNativeLoopPassed,\n\t\t_remotionInternalStack,","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/core/src/audio/AudioForPreview.tsx#L31-L67","documentation":"Thrown by <Audio> in preview when the shouldPreMountAudioTags prop changes between renders. Remotion captures the initial premount decision on first render via useState and forbids changing it afterward, because switching premount strategy mid-lifecycle would desync audio tags.","triggerScenarios":"Passing shouldPreMountAudioTags that derives from mutable state, props, or context that changes after mount. This is normally an internal prop, so a change indicates an upstream conditional that flipped.","commonSituations":"Custom wrappers around <Audio> that compute shouldPreMountAudioTags from changing context; hot reload surfacing the mismatch; version mismatch where Remotion internals pass different values.","solutions":["Make shouldPreMountAudioTags stable across the component's lifetime (constant or fixed at mount).","If you do not explicitly need this prop, omit it and let Remotion default it.","Ensure the parent does not conditionally change the premount setting between renders."],"exampleFix":"// before\n<Audio src={src} shouldPreMountAudioTags={someCondition} />\n\n// after\n// omit the prop or make it stable:\n<Audio src={src} />","handlingStrategy":"validation","validationCode":"// Treat shouldPreMountAudioTags as constant for the component's lifetime.\nconst [premount] = useState(() => initialPremountValue);\n// pass premount, never recompute it","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not derive shouldPreMountAudioTags from changing props or context.","Omit the prop if you don't explicitly need to control premount behavior."],"tags":["audio","premount","internal-prop","lifecycle"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}