Skip to content

🎥 Make videos programmatically with React

`remotion`: Allow minor floating point math deviations when seeking a <Video>

Jonny Burger0a22ae802188
diff --git a/packages/core/src/video/seek-until-right.ts b/packages/core/src/video/seek-until-right.ts
index 9ab436ac2d..e1bf8a2bda 100644
--- a/packages/core/src/video/seek-until-right.ts
+++ b/packages/core/src/video/seek-until-right.ts
@@ -1,8 +1,17 @@
+import {isApproximatelyTheSame} from '../is-approximately-the-same';
+
const roundTo6Commas = (num: number) => {
return Math.round(num * 100_000) / 100_000;
};
export const seekToTime = (element: HTMLVideoElement, desiredTime: number) => {
+ if (isApproximatelyTheSame(element.currentTime, desiredTime)) {
+ return {
+ wait: Promise.resolve(desiredTime),
+ cancel: () => {},
+ };
+ }
+
element.currentTime = desiredTime;
let cancel: number;