Created
December 4, 2022 17:49
-
-
Save kernalphage/14c7ebe1c1cc697af1f9999d6b5c6014 to your computer and use it in GitHub Desktop.
An example of how to stitch together Series.Sequences in Remotion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const TimedSequence: React.FC<{ urls: string[]}> = ({ urls }) => { | |
const [allCues, setAllCues] = useState<>(undefined); | |
const [handle] = useState(() => delayRender()); | |
const {fps} = useVideoConfig(); | |
const fetchData = useCallback(async () => { | |
const all = await Promise.all(urls.map(async (url) => | |
({url, durationInSeconds: await getAudioDurationInSeconds(url)}) | |
)); | |
setAllCues(all); | |
continueRender(handle); | |
}, [handle]); | |
useEffect(() => { | |
fetchData(); | |
}, [fetchData]); | |
if (allCues) { | |
return ( | |
<Series> | |
{allCues.map((cue, i) => ( | |
<Series.Sequence | |
key={cue.url+i} | |
durationInFrames={Math.floor(cue.durationInSeconds * fps)} | |
> | |
<Audio src={cue.url} /> | |
</Series.Sequence> | |
))} | |
</Series> | |
) | |
} | |
return ( | |
<div style={{ fontSize: "2em" }}> | |
fetching {urls.join("")} | |
</div> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment