remotion
Advanced tools
Comparing version 1.4.0-alpha.c6377c08 to 1.4.0-alpha.cb57b7a8
@@ -45,3 +45,3 @@ "use strict"; | ||
if (!id.match(/^([a-zA-Z0-9-])+$/g)) { | ||
throw new Error(`Composition id can only contain a-z, A-Z, 0-9 and -. You passed ${name}`); | ||
throw new Error(`Composition id can only contain a-z, A-Z, 0-9 and -. You passed ${id}`); | ||
} | ||
@@ -48,0 +48,0 @@ registerComposition({ |
@@ -10,8 +10,3 @@ "use strict"; | ||
const VideoForRendering = (props) => { | ||
const [metadataLoaded, setMetadataLoaded] = react_1.useState(false); | ||
const [currentFrameSet, setCurrentFrameSet] = react_1.useState(false); | ||
const [handle] = react_1.useState(() => { | ||
return ready_manager_1.delayRender(); | ||
}); | ||
const currentFrame = use_frame_1.useCurrentFrame(); | ||
const frame = use_frame_1.useCurrentFrame(); | ||
const videoConfig = use_unsafe_video_config_1.useUnsafeVideoConfig(); | ||
@@ -22,10 +17,14 @@ const videoRef = react_1.useRef(null); | ||
} | ||
const frameInSeconds = react_1.useMemo(() => currentFrame / videoConfig.fps, [ | ||
currentFrame, | ||
videoConfig.fps, | ||
]); | ||
const setFrame = react_1.useCallback(() => { | ||
react_1.useEffect(() => { | ||
if (!videoRef.current) { | ||
return; | ||
} | ||
const frameInSeconds = frame / videoConfig.fps; | ||
const handle = ready_manager_1.delayRender(); | ||
if (videoRef.current.currentTime === frameInSeconds) { | ||
videoRef.current.addEventListener('loadeddata', () => { | ||
ready_manager_1.continueRender(handle); | ||
}, { once: true }); | ||
return; | ||
} | ||
videoRef.current.currentTime = frameInSeconds; | ||
@@ -35,46 +34,3 @@ videoRef.current.addEventListener('seeked', () => { | ||
}, { once: true }); | ||
setInterval(() => { | ||
setCurrentFrameSet(true); | ||
}, 0); | ||
}, [frameInSeconds, handle]); | ||
const onMetadataLoad = react_1.useCallback(() => { | ||
setMetadataLoaded(true); | ||
}, []); | ||
react_1.useEffect(() => { | ||
if (metadataLoaded) { | ||
setFrame(); | ||
} | ||
}, [metadataLoaded, currentFrameSet, setFrame]); | ||
react_1.useEffect(() => { | ||
if (!videoRef.current) { | ||
return; | ||
} | ||
if (metadataLoaded) { | ||
setFrame(); | ||
return; | ||
} | ||
const { current } = videoRef; | ||
current.addEventListener('loadedmetadata', onMetadataLoad); | ||
return () => { | ||
current.removeEventListener('loadedmetadata', onMetadataLoad); | ||
}; | ||
}, [currentFrame, metadataLoaded, onMetadataLoad, setFrame, videoConfig.fps]); | ||
const onSetReadyState = react_1.useCallback(() => { | ||
if (!videoRef.current) { | ||
throw Error('No video ref'); | ||
} | ||
if (videoRef.current.readyState === 4) { | ||
setFrame(); | ||
} | ||
}, [setFrame]); | ||
react_1.useEffect(() => { | ||
if (!videoRef.current) { | ||
return; | ||
} | ||
const { current } = videoRef; | ||
current.addEventListener('loadeddata', onSetReadyState); | ||
return () => { | ||
current.removeEventListener('loadeddata', onSetReadyState); | ||
}; | ||
}); | ||
}, [frame, videoConfig.fps]); | ||
return jsx_runtime_1.jsx("video", Object.assign({ ref: videoRef }, props), void 0); | ||
@@ -81,0 +37,0 @@ }; |
{ | ||
"name": "remotion", | ||
"version": "1.4.0-alpha.c6377c08", | ||
"version": "1.4.0-alpha.cb57b7a8", | ||
"description": "Render videos in React", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
150124
1849