Skip to content

🎥 Make videos programmatically with React

fix: properly restart video in development mode

Arthur Denner6ac7fdc74331
diff --git a/packages/core/src/video/VideoForDevelopment.tsx b/packages/core/src/video/VideoForDevelopment.tsx
index 75fa4a60e6..ba799c37e6 100644
--- a/packages/core/src/video/VideoForDevelopment.tsx
+++ b/packages/core/src/video/VideoForDevelopment.tsx
@@ -22,11 +22,19 @@ export const VideoForDevelopment: React.FC<RemotionVideoProps> = (props) => {
if (!videoRef.current) {
throw new Error('No video ref found');
}
+
if (!videoConfig) {
throw new Error('No video config found');
}
- if (!playing || currentFrame === 0) {
+
+ if (!playing) {
videoRef.current.currentTime = currentFrame / (1000 / videoConfig.fps);
+ return;
+ }
+
+ if (currentFrame === 0 && playing) {
+ videoRef.current.currentTime = 0;
+ videoRef.current?.play();
}
}, [currentFrame, playing, videoConfig]);
diff --git a/packages/example/src/Features/index.tsx b/packages/example/src/Features/index.tsx
index 92655061b7..ce4add10c2 100644
--- a/packages/example/src/Features/index.tsx
+++ b/packages/example/src/Features/index.tsx
@@ -1,7 +1,6 @@
-import React from 'react';
import {Video} from 'remotion';
-const Features = () => {
+const Features: React.FC = () => {
const tray = require('./tray.webm');
const watermelon = require('./watermelon.webm');
const textstickers = require('./textstickers.webm');