{"record":{"id":"61984b84c4787c09","repo":"remotion-dev/remotion","slug":"the-number-of-shared-audio-tags-has-changed-dynami","errorCode":null,"errorMessage":"The number of shared audio tags has changed dynamically. Once you have set this property, you cannot change it afterwards.","messagePattern":"The number of shared audio tags has changed dynamically\\. Once you have set this property, you cannot change it afterwards\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/audio/shared-audio-tags.tsx","lineNumber":591,"sourceCode":"\t\t_experimentalKeepAudioContextAlive,\n\t]);\n\n\treturn (\n\t\t<SharedAudioContext.Provider value={audioContextValue}>\n\t\t\t{children}\n\t\t</SharedAudioContext.Provider>\n\t);\n};\n\nexport const SharedAudioTagsContextProvider: React.FC<{\n\treadonly numberOfAudioTags: number;\n\treadonly children: React.ReactNode;\n}> = ({children, numberOfAudioTags}) => {\n\tconst audios = useRef<AudioElem[]>([]);\n\tconst [initialNumberOfAudioTags] = useState(numberOfAudioTags);\n\n\tif (numberOfAudioTags !== initialNumberOfAudioTags) {\n\t\tthrow new Error(\n\t\t\t'The number of shared audio tags has changed dynamically. Once you have set this property, you cannot change it afterwards.',\n\t\t);\n\t}\n\n\tconst logLevel = useLogLevel();\n\tconst mountTime = useMountTime();\n\tconst env = useRemotionEnvironment();\n\tconst audioCtx = useContext(SharedAudioContext);\n\tconst audioContext = audioCtx?.audioContext ?? null;\n\tconst resume = audioCtx?.resume;\n\n\tconst [refs] = useState(() => {\n\t\treturn new Array(numberOfAudioTags).fill(true).map((): Ref => {\n\t\t\tconst ref = createRef<HTMLAudioElement>();\n\t\t\treturn {\n\t\t\t\tid: Math.random(),\n\t\t\t\tref,\n\t\t\t\tmediaElementSourceNode: makeSharedElementSourceNode({","sourceCodeStart":573,"sourceCodeEnd":609,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/core/src/audio/shared-audio-tags.tsx#L573-L609","documentation":"numberOfAudioTags (passed to SharedAudioTagsContextProvider, surfaced via the Player's numberOfSharedAudioTags prop) sets how many silent <audio> tags Remotion pre-mounts to dodge browser autoplay restrictions. The provider captures the initial count in useState and allocates refs/contexts once; a different count on a later render is rejected because the pre-mounted audio infrastructure cannot be safely resized.","triggerScenarios":"Passing <Player numberOfSharedAudioTags={count} /> where count is React state that changes. Also triggered by deriving the count from window width or a settings panel that updates during playback.","commonSituations":"Tying audio tag count to a user-configurable setting; re-rendering the Player from a parent that computes the count dynamically; hot-reloading in Studio with a different count.","solutions":["Pass a constant literal for numberOfSharedAudioTags.","If the count must change, remount the Player with a key tied to the value.","Pick a single value that covers your worst-case simultaneous audio count and keep it fixed."],"exampleFix":"// before\n<Player numberOfSharedAudioTags={audioCount} ... />\n\n// after\n<Player key={audioCount} numberOfSharedAudioTags={audioCount} ... />","handlingStrategy":"validation","validationCode":"const AUDIO_TAG_COUNT = 5; // constant\n// <Player numberOfSharedAudioTags={AUDIO_TAG_COUNT} key={String(AUDIO_TAG_COUNT)} .../>","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass a literal for numberOfSharedAudioTags.","Size it once to your worst-case simultaneous audio count.","Remount the Player (via key) rather than mutating the value."],"tags":["audio","player","validation","react","lifecycle","autoplay"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}