Skip to content

🎥 Make videos programmatically with React

the same

Jonny Burger9a44becf5486
diff --git a/index.html b/index.html
new file mode 100644
index 0000000000..9cd7b840a3
--- /dev/null
+++ b/index.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="UTF-8" />
+ <meta http-equiv="X-UA-Compatible" content="IE=edge" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <title>Document</title>
+ </head>
+ <body>
+ <canvas id="hi"></canvas>
+ <video src="./packages/example/src/resources/framer-24fps.mp4"></video>
+ </body>
+ <script>
+ const canvas = document.getElementById("id");
+ </script>
+</html>
diff --git a/packages/core/src/video/VideoForRendering.tsx b/packages/core/src/video/VideoForRendering.tsx
index 206ff0ee34..eacbbe9e6b 100644
--- a/packages/core/src/video/VideoForRendering.tsx
+++ b/packages/core/src/video/VideoForRendering.tsx
@@ -6,6 +6,9 @@ import {useCurrentFrame} from '../use-frame';
import {useUnsafeVideoConfig} from '../use-unsafe-video-config';
import {RemotionVideoProps} from './props';
+const isTheSame = (num1: number, num2: number) => {
+ return Math.abs(num1 - num2) < FLOATING_POINT_ERROR_THRESHOLD;
+};
export const VideoForRendering: React.FC<RemotionVideoProps> = ({
onError,
...props
@@ -55,7 +58,7 @@ export const VideoForRendering: React.FC<RemotionVideoProps> = ({
return frame / (1000 / videoConfig.fps);
})();
const handle = delayRender();
- if (videoRef.current.currentTime === currentTime) {
+ if (isTheSame(videoRef.current.currentTime, currentTime)) {
if (videoRef.current.readyState >= 2) {
continueRender(handle);
return;