Capítulo 333 de 988
The following pattern is not ideal because every time the time updates, the <Player> is being re-rendered:
<Player>// @allowUmdGlobalAccess
// @filename: ./remotion/MyVideo.tsx
export const MyVideo = () => <></>;
// @filename: index.tsx
const otherProps = {
durationInFrames: 120,
compositionWidth: 1920,
compositionHeight: 1080,
fps: 30,
} as const;
export const App: React.FC = () => {
const playerRef = useRef<PlayerRef>(null);
const [currentTime, setCurrentTime] = useState(0);
useEffect(() => {
playerRef.current?.addEventListener('timeupdate', (e) => {
setCurrentTime(e.detail.frame);
});
}, []);
return (
<div>
<Player ref={playerRef} component={MyVideo} {...otherProps} />
<div>Current time: {currentTime}</div>
</div>
);
};
<player> when working with Player - Best practices.