Skip to content

🎥 Make videos programmatically with React

add buttons

Jonny Burger7b8529739e92
diff --git a/packages/cli/src/editor/components/PlayPause.tsx b/packages/cli/src/editor/components/PlayPause.tsx
index 8b71750a34..72f2b160be 100644
--- a/packages/cli/src/editor/components/PlayPause.tsx
+++ b/packages/cli/src/editor/components/PlayPause.tsx
@@ -26,7 +26,7 @@ export const PlayPause: React.FC<{
playbackRate,
});
- const {playing, play, pause, frameBack, frameForward, isLastFrame} =
+ const {playing, play, pause, frameBack, seek, frameForward, isLastFrame} =
PlayerInternals.usePlayer();
const isStill = useIsStill();
@@ -82,6 +82,19 @@ export const PlayPause: React.FC<{
const oneFrameForward = useCallback(() => {
frameForward(1);
}, [frameForward]);
+
+ const jumpToStart = useCallback(() => {
+ seek(0);
+ }, [seek]);
+
+ const jumpToEnd = useCallback(() => {
+ if (!video) {
+ return;
+ }
+
+ seek(video.durationInFrames - 1);
+ }, [seek, video]);
+
const keybindings = useKeybinding();
useEffect(() => {
@@ -110,6 +123,14 @@ export const PlayPause: React.FC<{
return (
<>
+ <ControlButton
+ aria-label="Jump to beginning"
+ title="Jump to beginning"
+ disabled={frame === 0}
+ onClick={jumpToStart}
+ >
+ <StepBack style={forwardBackStyle} />
+ </ControlButton>
<ControlButton
aria-label="Step back one frame"
title="Step back one frame"
@@ -152,6 +173,14 @@ export const PlayPause: React.FC<{
>
<StepForward style={forwardBackStyle} />
</ControlButton>
+ <ControlButton
+ aria-label="Jump to end"
+ title="Jump to end"
+ disabled={isLastFrame}
+ onClick={jumpToEnd}
+ >
+ <StepForward style={forwardBackStyle} />
+ </ControlButton>
</>
);
};