Skip to content

🎥 Make videos programmatically with React

`remotion`: Cleanup `AudioContext` if used for amplification

Jonny Burger244ccbe70a65
diff --git a/packages/core/src/use-amplification.ts b/packages/core/src/use-amplification.ts
index a88389f3a6..911bfb6b64 100644
--- a/packages/core/src/use-amplification.ts
+++ b/packages/core/src/use-amplification.ts
@@ -80,6 +80,12 @@ export const useAmplification = ({
logLevel,
`Starting to amplify ${mediaRef.current?.src}. Gain = ${currentVolumeRef.current}`,
);
+
+ return () => {
+ gainNode.disconnect();
+ source.disconnect();
+ audioContext.close();
+ };
}, [logLevel, mediaRef, shouldAmplify]);
if (audioStuffRef.current) {