🎥 Make videos programmatically with React
`remotion`: Keep Studio frameRef in sync with the current timeline
Noah Lindnerb3653383eefa
diff --git a/packages/core/src/TimelineContext.tsx b/packages/core/src/TimelineContext.tsxindex 6d95b24479..1328af4f6c 100644--- a/packages/core/src/TimelineContext.tsx+++ b/packages/core/src/TimelineContext.tsx@@ -29,9 +29,9 @@ export type SetTimelineContextValue = {setFrame: (u: React.SetStateAction<Record<string, number>>) => void;setPlaying: (u: React.SetStateAction<boolean>) => void;subscribePlaying: (listener: () => void) => () => void;- frameRef: RefObject<Record<string, number>> | null;- isPlaying: (() => boolean) | null;- audioAndVideoTags: RefObject<PlayableMediaTag[]> | null;+ frameRef: RefObject<Record<string, number>>;+ isPlaying: () => boolean;+ audioAndVideoTags: RefObject<PlayableMediaTag[]>;};export const SetTimelineContext = createContext<SetTimelineContextValue>({@@ -44,9 +44,11 @@ export const SetTimelineContext = createContext<SetTimelineContextValue>({subscribePlaying: () => {throw new Error('default');},- frameRef: null,- isPlaying: null,- audioAndVideoTags: null,+ frameRef: {current: {}},+ isPlaying: () => {+ throw new Error('default');+ },+ audioAndVideoTags: {current: []},});export const TimelineContext = createContext<TimelineContextValue | null>(null);@@ -74,6 +76,8 @@ export const TimelineContextProvider: React.FC<{);const frame = frameState ?? _frame;+ const frameRef = useRef(frame);+ frameRef.current = frame;const readIsPlaying = useCallback(() => playingStore.store.getSnapshot().playing,@@ -144,11 +148,11 @@ export const TimelineContextProvider: React.FC<{}},subscribePlaying: playingStore.store.subscribe,- frameRef: null,- isPlaying: null,- audioAndVideoTags: null,+ frameRef,+ isPlaying: readIsPlaying,+ audioAndVideoTags,};- }, [playingStore]);+ }, [playingStore, readIsPlaying]);return (<AbsoluteTimeContext.Provider value={timelineContextValue}>diff --git a/packages/player/src/use-player-methods.ts b/packages/player/src/use-player-methods.tsindex 3f0b65e2eb..1d3abf30e7 100644--- a/packages/player/src/use-player-methods.ts+++ b/packages/player/src/use-player-methods.ts@@ -40,12 +40,6 @@ export const usePlayerMethods = (): UsePlayerMethods => {throw new TypeError('Expected Player event emitter context');}- if (!frameRef || !readIsPlaying || !audioAndVideoTags) {- throw new Error(- 'Player timeline context is not available. This hook must be used inside a <Player>.',- );- }-const bufferingContext = useContext(Internals.BufferingContextReact);if (!bufferingContext) {throw new Error(