Skip to content

🎥 Make videos programmatically with React

simplify initial frame

Jonny Burger0578f57fa6c7
diff --git a/packages/bundler/src/setup-environment.ts b/packages/bundler/src/setup-environment.ts
index 2fefaaa3dc..511c0c6071 100644
--- a/packages/bundler/src/setup-environment.ts
+++ b/packages/bundler/src/setup-environment.ts
@@ -1,7 +1,6 @@
import {Internals} from 'remotion';
Internals.setupEnvVariables();
-Internals.setupInitialFrame();
Internals.setupPuppeteerTimeout();
Internals.CSSUtils.injectCSS(`
diff --git a/packages/core/src/RemotionRoot.tsx b/packages/core/src/RemotionRoot.tsx
index 6550a8bbc2..2d59b8a4d5 100644
--- a/packages/core/src/RemotionRoot.tsx
+++ b/packages/core/src/RemotionRoot.tsx
@@ -8,7 +8,6 @@ import React, {
import {SharedAudioContextProvider} from './audio/shared-audio-tags';
import {CompositionManagerProvider} from './CompositionManager';
import {continueRender, delayRender} from './delay-render';
-import {INITIAL_FRAME_LOCAL_STORAGE_KEY} from './initial-frame';
import {NonceContext, TNonceContext} from './nonce';
import {random} from './random';
import {
@@ -23,11 +22,7 @@ export const RemotionRoot: React.FC<{
children: React.ReactNode;
}> = ({children}) => {
const [remotionRootId] = useState(() => String(random(null)));
- console.log(
- 'INITIAL FRAME',
- window.remotion_initialFrame,
- localStorage.getItem(INITIAL_FRAME_LOCAL_STORAGE_KEY)
- );
+ console.log('INITIAL FRAME', window.remotion_initialFrame);
const [frame, setFrame] = useState<number>(window.remotion_initialFrame ?? 0);
const [playing, setPlaying] = useState<boolean>(false);
const imperativePlaying = useRef<boolean>(false);
diff --git a/packages/core/src/initial-frame.ts b/packages/core/src/initial-frame.ts
deleted file mode 100644
index 0d0c807c7a..0000000000
--- a/packages/core/src/initial-frame.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-export const INITIAL_FRAME_LOCAL_STORAGE_KEY = 'remotion.initialFrame';
-
-const getInitialFrame = (): number => {
- const param = localStorage.getItem(INITIAL_FRAME_LOCAL_STORAGE_KEY);
- return param ? Number(param) : 0;
-};
-
-export const setupInitialFrame = () => {
- window.remotion_initialFrame = getInitialFrame();
-};
diff --git a/packages/core/src/internals.ts b/packages/core/src/internals.ts
index 8582a86321..8967110358 100644
--- a/packages/core/src/internals.ts
+++ b/packages/core/src/internals.ts
@@ -82,10 +82,6 @@ import {DELAY_RENDER_CALLSTACK_TOKEN} from './delay-render';
import {FEATURE_FLAG_FIREFOX_SUPPORT} from './feature-flags';
import {getRemotionEnvironment, RemotionEnvironment} from './get-environment';
import {getPreviewDomElement} from './get-preview-dom-element';
-import {
- INITIAL_FRAME_LOCAL_STORAGE_KEY,
- setupInitialFrame,
-} from './initial-frame';
import {isAudioCodec} from './is-audio-codec';
import * as perf from './perf';
import {getRoot} from './register-root';
@@ -184,9 +180,7 @@ export const Internals = {
RemotionContextProvider,
CSSUtils,
setupEnvVariables,
- setupInitialFrame,
ENV_VARIABLES_ENV_NAME,
- INITIAL_FRAME_LOCAL_STORAGE_KEY,
getDotEnvLocation,
getServerPort,
MediaVolumeContext,
diff --git a/packages/renderer/src/set-props-and-env.ts b/packages/renderer/src/set-props-and-env.ts
index 112940708d..adc6ef794c 100644
--- a/packages/renderer/src/set-props-and-env.ts
+++ b/packages/renderer/src/set-props-and-env.ts
@@ -53,10 +53,10 @@ export const setPropsAndEnv = async ({
}
await page.evaluateOnNewDocument(
- (key: string, value: string) => {
- window.localStorage.setItem(key, value);
+ (key: number) => {
+ window.remotion_initialFrame = key;
},
- [Internals.INITIAL_FRAME_LOCAL_STORAGE_KEY, initialFrame]
+ [initialFrame]
);
const pageRes = await page.goto(urlToVisit);