🎥 Make videos programmatically with React
added 2nd remotion video
Shankhadeep Dey43bf9270fd7a
diff --git a/packages/player-example/src/App.tsx b/packages/player-example/src/App.tsxindex 7b854eb2e5..8ee362fa16 100644--- a/packages/player-example/src/App.tsx+++ b/packages/player-example/src/App.tsx@@ -1,12 +1,15 @@import {Player, PlayerMethods} from '@remotion/player';import {useRef, useState} from 'react';import CarSlideshow from './CarSlideshow';+import CarSlideshowNew from './CarSlideshowNew';export default function App() {const [title, setTitle] = useState('This is my title');const ref = useRef<PlayerMethods>(null);+ const ref2 = useRef<PlayerMethods>(null);+return (<div><Player@@ -21,6 +24,18 @@ export default function App() {title,}}/>+ <Player+ ref={ref2}+ width={768}+ height={432}+ fps={30}+ durationInFrames={500}+ component={CarSlideshowNew}+ controls+ props={{+ title,+ }}+ /><inputtype="text"value={title}@@ -34,6 +49,12 @@ export default function App() {<button type="button" onClick={() => ref.current?.pause()}>Pause</button>+ <button type="button" onClick={() => ref2.current?.play()}>+ Play2+ </button>+ <button type="button" onClick={() => ref2.current?.pause()}>+ Pause2+ </button></div>);}diff --git a/packages/player-example/src/CarSlideshowNew.tsx b/packages/player-example/src/CarSlideshowNew.tsxnew file mode 100644index 0000000000..e8c1bd20be--- /dev/null+++ b/packages/player-example/src/CarSlideshowNew.tsx@@ -0,0 +1,48 @@+import React from 'react';+import {+ interpolate,+ interpolateColors,+ useCurrentFrame,+ useVideoConfig,+} from 'remotion';++const CarSlideshow: React.FC<{+ title: string;+}> = ({title}) => {+ const frame = useCurrentFrame();+ const {width, height, durationInFrames} = useVideoConfig();+ const left = interpolate(frame, [0, durationInFrames], [width, width * -1]);+ const backGroundColor = interpolateColors(+ frame,+ [0, Math.floor(durationInFrames / 2), durationInFrames],+ ['red', 'hotpink', 'green']+ );+ return (+ <div+ style={{+ backgroundColor: backGroundColor,+ width: width,+ height: height,+ position: 'absolute',+ left: 0,+ top: 0,+ }}+ >+ <h1+ style={{+ fontSize: '5em',+ fontWeight: 'bold',+ position: 'absolute',+ top: height / 2 - 100,+ left,+ color: 'white',+ whiteSpace: 'nowrap',+ }}+ >+ {title}+ </h1>+ </div>+ );+};++export default CarSlideshow;