Skip to content

🎥 Make videos programmatically with React

hide buttons

Jonny Burger12b0772ce7de
diff --git a/packages/cli/src/editor/components/PlayPause.tsx b/packages/cli/src/editor/components/PlayPause.tsx
index 84dd71406f..2ffaf8a97c 100644
--- a/packages/cli/src/editor/components/PlayPause.tsx
+++ b/packages/cli/src/editor/components/PlayPause.tsx
@@ -1,5 +1,6 @@
import {PlayerInternals} from '@remotion/player';
import React, {useCallback, useEffect} from 'react';
+import {Internals} from 'remotion';
import {useIsStill} from '../helpers/is-current-selected-still';
import {useKeybinding} from '../helpers/use-keybinding';
import {JumpToStart} from '../icons/jump-to-start';
@@ -26,6 +27,7 @@ export const PlayPause: React.FC<{
loop: boolean;
}> = ({playbackRate, loop}) => {
const {inFrame, outFrame} = useTimelineInOutFramePosition();
+ const videoConfig = Internals.useUnsafeVideoConfig();
PlayerInternals.usePlayback({
loop,
@@ -237,7 +239,7 @@ export const PlayPause: React.FC<{
<ControlButton
aria-label="Jump to beginning"
title="Jump to beginning"
- disabled={isFirstFrame}
+ disabled={!videoConfig || isFirstFrame}
onClick={jumpToStart}
>
<JumpToStart style={forwardBackStyle} />
@@ -245,7 +247,7 @@ export const PlayPause: React.FC<{
<ControlButton
aria-label="Step back one frame"
title="Step back one frame"
- disabled={isFirstFrame}
+ disabled={!videoConfig || isFirstFrame}
onClick={oneFrameBack}
>
<StepBack style={forwardBackStyle} />
@@ -255,6 +257,7 @@ export const PlayPause: React.FC<{
aria-label={playing ? 'Pause' : 'Play'}
title={playing ? 'Pause' : 'Play'}
onClick={playing ? pause : play}
+ disabled={!videoConfig}
>
{playing ? (
<Pause
@@ -278,7 +281,7 @@ export const PlayPause: React.FC<{
<ControlButton
aria-label="Step forward one frame"
title="Step forward one frame"
- disabled={isLastFrame}
+ disabled={!videoConfig || isLastFrame}
onClick={oneFrameForward}
>
<StepForward style={forwardBackStyle} />
diff --git a/packages/cli/src/editor/components/TimelineInOutToggle.tsx b/packages/cli/src/editor/components/TimelineInOutToggle.tsx
index 3bf5c75d54..6ddd890651 100644
--- a/packages/cli/src/editor/components/TimelineInOutToggle.tsx
+++ b/packages/cli/src/editor/components/TimelineInOutToggle.tsx
@@ -287,10 +287,6 @@ export const TimelineInOutPointToggle: React.FC = () => {
[onInMark, onInOutClear, onOutMark, setInAndOutFrames]
);
- if (!videoConfig) {
- return null;
- }
-
if (isStill) {
return null;
}
@@ -302,7 +298,7 @@ export const TimelineInOutPointToggle: React.FC = () => {
aria-label={getTooltipText('In', 'I')}
onClick={(e) => onInMark(e)}
onContextMenu={clearInMark}
- disabled={timelinePosition === 0}
+ disabled={!videoConfig || timelinePosition === 0}
>
<TimelineInPointer
color={inFrame === null ? 'white' : 'var(--blue)'}
@@ -314,7 +310,9 @@ export const TimelineInOutPointToggle: React.FC = () => {
aria-label={getTooltipText('Out', 'O')}
onClick={onOutMark}
onContextMenu={clearOutMark}
- disabled={timelinePosition === videoConfig.durationInFrames - 1}
+ disabled={
+ !videoConfig || timelinePosition === videoConfig.durationInFrames - 1
+ }
>
<TimelineOutPointer
color={outFrame === null ? 'white' : 'var(--blue)'}