Skip to content

🎥 Make videos programmatically with React

use `useMediaInTimeline` in the new video tag

Igor Samokhovetsd9abea329f5b
diff --git a/packages/media/src/video/video-for-preview.tsx b/packages/media/src/video/video-for-preview.tsx
index 0e463b1408..ce1038b029 100644
--- a/packages/media/src/video/video-for-preview.tsx
+++ b/packages/media/src/video/video-for-preview.tsx
@@ -21,6 +21,7 @@ const {
evaluateVolume,
warnAboutTooHighVolume,
usePreload,
+ useMediaInTimeline,
} = Internals;
const calculateLoopDuration = ({
@@ -102,6 +103,22 @@ const NewVideoForPreview: React.FC<NewVideoForPreviewProps> = ({
warnAboutTooHighVolume(userPreferredVolume);
+ const [timelineId] = useState(() => String(Math.random()));
+
+ useMediaInTimeline({
+ volume,
+ mediaVolume,
+ mediaType: 'video',
+ src,
+ playbackRate,
+ displayName: null,
+ id: timelineId,
+ stack: null,
+ showInTimeline: true,
+ premountDisplay: null,
+ postmountDisplay: null,
+ });
+
if (!videoConfig) {
throw new Error('No video config found');
}