Skip to content

🎥 Make videos programmatically with React

throttle the seeking of the video tag

Jonny Burgerfaf89f9fd6a4
diff --git a/packages/core/src/use-media-playback.ts b/packages/core/src/use-media-playback.ts
index 573bf20e36..40462fd832 100644
--- a/packages/core/src/use-media-playback.ts
+++ b/packages/core/src/use-media-playback.ts
@@ -61,6 +61,14 @@ export const useMediaPlayback = ({
mediaRef.current.playbackRate = playbackRateToSet;
}
+ // Let's throttle the seeking to only every 10 frames when a video is playing to avoid bottlenecking
+ // the video tag.
+ if (playing) {
+ if (absoluteFrame % 10 !== 0) {
+ return;
+ }
+ }
+
const _shouldBeTime = getMediaTime({
fps,
frame,