Skip to content

🎥 Make videos programmatically with React

Merge branch 'main' into use-current-scale

Jonny Burger2d1a504797ad
diff --cc packages/core/src/index.ts
index 57775f5e8c,063e128c1e..dcf676e449
--- a/packages/core/src/index.ts
+++ b/packages/core/src/index.ts
@@@ -132,14 -132,8 +132,15 @@@ export * from './spring/index.js'
export {staticFile} from './static-file.js';
export * from './Still.js';
export type {PlayableMediaTag} from './timeline-position-state.js';
+ export {useBufferState} from './use-buffer-state';
export {useCurrentFrame} from './use-current-frame.js';
+export {
+ CurrentScaleContextType,
+ PreviewSize,
+ PreviewSizeCtx,
+ Translation,
+ useCurrentScale,
+} from './use-current-scale';
export * from './use-video-config.js';
export * from './version.js';
export * from './video-config.js';
diff --cc packages/core/src/internals.ts
index ebd1f90c72,c4803cbe0e..349d863cd5
--- a/packages/core/src/internals.ts
+++ b/packages/core/src/internals.ts
@@@ -147,10 -147,10 +148,12 @@@ export const Internals =
WATCH_REMOTION_STATIC_FILES,
addSequenceStackTraces,
useMediaStartsAt,
+ BufferingProvider,
+ BufferingContextReact,
enableSequenceStackTraces,
colorNames,
+ CurrentScaleContext,
+ PreviewSizeContext,
} as const;
export type {
diff --cc packages/docs/sidebars.js
index b358157a89,c84d304951..fed4c063d8
--- a/packages/docs/sidebars.js
+++ b/packages/docs/sidebars.js
@@@ -101,8 -101,8 +101,9 @@@ module.exports =
"spring",
"staticfile",
"still",
+ "use-buffer-state",
"use-current-frame",
+ "use-current-scale",
"use-video-config",
"version",
"video",
diff --cc packages/player-example/src/VideoAutoplay.tsx
index 587fff97aa,161a897045..3ce0acb6d2
--- a/packages/player-example/src/VideoAutoplay.tsx
+++ b/packages/player-example/src/VideoAutoplay.tsx
@@@ -6,7 -5,7 +6,8 @@@ import
Sequence,
Series,
staticFile,
+ useCurrentScale,
+ Video,
} from 'remotion';
preloadVideo(
diff --cc packages/player/src/PlayerUI.tsx
index acd198791c,f2376812d2..534547281f
--- a/packages/player/src/PlayerUI.tsx
+++ b/packages/player/src/PlayerUI.tsx
@@@ -455,17 -504,11 +505,18 @@@ const PlayerUI: React.ForwardRefRenderF
? renderLoading({
height: outerStyle.height as number,
width: outerStyle.width as number,
+ isBuffering: showBufferIndicator,
})
: null;
- }, [outerStyle.height, outerStyle.width, renderLoading]);
+ }, [outerStyle.height, outerStyle.width, renderLoading, showBufferIndicator]);
+ const currentScale: CurrentScaleContextType = useMemo(() => {
+ return {
+ type: 'scale',
+ scale,
+ };
+ }, [scale]);
+
if (!config) {
return null;
}
diff --cc packages/studio/src/components/Editor.tsx
index 5f4684a637,d3d4907428..ca6d0c3755
--- a/packages/studio/src/components/Editor.tsx
+++ b/packages/studio/src/components/Editor.tsx
@@@ -69,21 -56,20 +76,24 @@@ export const Editor: React.FC<{Root: Re
return (
<HigherZIndex onEscape={noop} onOutsideClick={noop}>
<TimelineZoomContext>
- <div style={background}>
- {canvasMounted ? <Root /> : null}
- <Internals.CanUseRemotionHooksProvider>
- <EditorContent
- bufferStateDelayInMilliseconds={
- BUFFER_STATE_DELAY_IN_MILLISECONDS
- }
- onMounted={onMounted}
- readOnlyStudio={readOnlyStudio}
- />
- <GlobalKeybindings />
- </Internals.CanUseRemotionHooksProvider>
- <NotificationCenter />
- </div>
+ <Internals.CurrentScaleContext.Provider value={value}>
+ <div style={background}>
+ {canvasMounted ? <Root /> : null}
+ <Internals.CanUseRemotionHooksProvider>
+ <EditorContent
+ drawRef={drawRef}
+ size={size}
+ onMounted={onMounted}
+ readOnlyStudio={readOnlyStudio}
++ bufferStateDelayInMilliseconds={
++ BUFFER_STATE_DELAY_IN_MILLISECONDS
++ }
+ />
+ <GlobalKeybindings />
+ </Internals.CanUseRemotionHooksProvider>
+ <NotificationCenter />
+ </div>
+ </Internals.CurrentScaleContext.Provider>
<Modals readOnlyStudio={readOnlyStudio} />
</TimelineZoomContext>
</HigherZIndex>
diff --cc packages/studio/src/components/EditorContent.tsx
index 242d563a9c,42bff0f95a..0309ea92c1
--- a/packages/studio/src/components/EditorContent.tsx
+++ b/packages/studio/src/components/EditorContent.tsx
@@@ -22,9 -21,8 +22,16 @@@ const container: React.CSSProperties =
export const EditorContent: React.FC<{
readOnlyStudio: boolean;
onMounted: () => void;
+ drawRef: React.RefObject<HTMLDivElement>;
+ size: Size | null;
- }> = ({readOnlyStudio, onMounted, size, drawRef}) => {
+ bufferStateDelayInMilliseconds: number;
-}> = ({readOnlyStudio, onMounted, bufferStateDelayInMilliseconds}) => {
++}> = ({
++ readOnlyStudio,
++ onMounted,
++ size,
++ drawRef,
++ bufferStateDelayInMilliseconds,
++}) => {
const isStill = useIsStill();
const {canvasContent} = useContext(Internals.CompositionManager);
@@@ -38,8 -36,7 +45,9 @@@
<MenuToolbar readOnlyStudio={readOnlyStudio} />
{onlyTopPanel ? (
<TopPanel
+ size={size}
+ drawRef={drawRef}
+ bufferStateDelayInMilliseconds={bufferStateDelayInMilliseconds}
onMounted={onMounted}
readOnlyStudio={readOnlyStudio}
/>
@@@ -53,8 -50,7 +61,9 @@@
>
<SplitterElement sticky={null} type="flexer">
<TopPanel
+ size={size}
+ drawRef={drawRef}
+ bufferStateDelayInMilliseconds={bufferStateDelayInMilliseconds}
onMounted={onMounted}
readOnlyStudio={readOnlyStudio}
/>
diff --cc packages/studio/src/components/TopPanel.tsx
index a79b9ef865,18df87971a..65494b239b
--- a/packages/studio/src/components/TopPanel.tsx
+++ b/packages/studio/src/components/TopPanel.tsx
@@@ -53,9 -59,8 +53,16 @@@ export const useResponsiveSidebarStatu
export const TopPanel: React.FC<{
readOnlyStudio: boolean;
onMounted: () => void;
+ size: Size | null;
+ drawRef: React.RefObject<HTMLDivElement>;
- }> = ({readOnlyStudio, onMounted, size, drawRef}) => {
+ bufferStateDelayInMilliseconds: number;
-}> = ({readOnlyStudio, onMounted, bufferStateDelayInMilliseconds}) => {
++}> = ({
++ readOnlyStudio,
++ onMounted,
++ size,
++ drawRef,
++ bufferStateDelayInMilliseconds,
++}) => {
const {setSidebarCollapsedState, sidebarCollapsedStateRight} =
useContext(SidebarContext);
const rulersAreVisible = useIsRulerVisible();