Skip to content

🎥 Make videos programmatically with React

explicitly handle closed state

Jonny Burgerc019b4da9460
diff --git a/packages/core/src/audio/shared-audio-tags.tsx b/packages/core/src/audio/shared-audio-tags.tsx
index 48520df356..e3fb761c1f 100644
--- a/packages/core/src/audio/shared-audio-tags.tsx
+++ b/packages/core/src/audio/shared-audio-tags.tsx
@@ -172,12 +172,13 @@ type NodeToResume = {
duration: number;
};
-const shouldSaveForLater = (state: RemotionAudioContextState) => {
+const shouldSaveForLater = (
+ state: Exclude<RemotionAudioContextState, 'closed'>,
+) => {
if (
state === 'suspended' ||
state === 'running-to-suspended' ||
- state === 'interrupted' ||
- state === 'closed'
+ state === 'interrupted'
) {
return true;
}
@@ -251,6 +252,14 @@ export const SharedAudioContextProvider: React.FC<{
}
const currentState = ctxAndGain.getState();
+
+ if (currentState === 'closed') {
+ return {
+ type: 'not-started',
+ reason: 'audio context is closed',
+ };
+ }
+
const saveForLater = shouldSaveForLater(currentState);
if (duration > 0) {