Skip to content

🎥 Make videos programmatically with React

remove old

Jonny Burgerd13df6c2a116
diff --git a/packages/docs/components/LandingPage/GithubDemo.tsx b/packages/docs/components/LandingPage/GithubDemo.tsx
deleted file mode 100644
index a226a8c7b6..0000000000
--- a/packages/docs/components/LandingPage/GithubDemo.tsx
+++ /dev/null
@@ -1,82 +0,0 @@
-import React from "react";
-import {
- AbsoluteFill,
- Img,
- interpolate,
- measureSpring,
- spring,
- useCurrentFrame,
- useVideoConfig,
-} from "remotion";
-import styles from "./githubdemo.module.css";
-
-export type GithubResponse = {
- login: string;
- avatar_url: string;
- followers: number;
-};
-export const GithubDemo: React.FC<{
- data: GithubResponse | null;
-}> = ({ data }) => {
- const frame = useCurrentFrame();
- const { fps } = useVideoConfig();
- const progress = spring({
- frame,
- fps,
- config: {
- damping: 200,
- },
- });
-
- const springDur = measureSpring({ fps, config: { damping: 200 } });
-
- const titleTranslation = interpolate(progress, [0, 1], [700, 0]);
- const subtitleOpacity = interpolate(
- frame,
- [springDur + 15, springDur + 40],
- [0, 1]
- );
-
- if (!data) {
- return null;
- }
-
- return (
- <AbsoluteFill
- style={{
- backgroundColor: "var(--ifm-background-color)",
- justifyContent: "center",
- alignItems: "center",
- }}
- >
- <div
- style={{ display: "flex", flexDirection: "row", alignItems: "center" }}
- >
- <Img
- src={data.avatar_url}
- style={{
- borderRadius: 150,
- height: 300,
- width: 300,
- transform: `scale(${progress})`,
- }}
- />
- <div style={{ width: 60 }} />
- <div>
- <h1
- className={styles.githubdemotitle}
- style={{ transform: `translateY(${titleTranslation}px)` }}
- >
- Hi {data.login}!
- </h1>
- <p
- className={styles.githubdemodescription}
- style={{ opacity: subtitleOpacity }}
- >
- You have {data.followers} followers.
- </p>
- </div>
- </div>
- </AbsoluteFill>
- );
-};
diff --git a/packages/docs/components/LandingPage/Programmatic.tsx b/packages/docs/components/LandingPage/Programmatic.tsx
deleted file mode 100644
index 7cb3cccdca..0000000000
--- a/packages/docs/components/LandingPage/Programmatic.tsx
+++ /dev/null
@@ -1,68 +0,0 @@
-import type { PlayerRef } from "@remotion/player";
-import { Player } from "@remotion/player";
-import React, { useCallback, useEffect, useRef, useState } from "react";
-import type { GithubResponse } from "./GithubDemo";
-import { GithubDemo } from "./GithubDemo";
-import styles from "./mobileplayer.module.css";
-
-export const ProgrammaticContent: React.FC<{ data: GithubResponse | null }> = ({
- data,
-}) => {
- const containerRef = useRef<HTMLDivElement>(null);
- const playerRef = useRef<PlayerRef>(null);
-
- const [isIntersecting, setIsIntersecting] = useState(false);
-
- const callback: IntersectionObserverCallback = useCallback(
- (newData) => {
- setIsIntersecting(newData[0].isIntersecting);
- if (isIntersecting) {
- playerRef.current?.play();
- } else {
- playerRef.current?.pause();
- }
- },
- [isIntersecting]
- );
-
- useEffect(() => {
- const { current } = containerRef;
- if (!current) {
- return;
- }
-
- const observer = new IntersectionObserver(callback, {
- root: null,
- threshold: 1,
- });
- // Docusaurus sometimes has a layout shift that immediately focuses
- // the video on page load
- setTimeout(() => {
- observer.observe(current);
- }, 2000);
-
- return () => observer.unobserve(current);
- }, [callback]);
-
- useEffect(() => {
- if (isIntersecting) {
- playerRef.current?.play();
- }
- }, [data, isIntersecting]);
-
- return (
- <div ref={containerRef} className={styles.mobileplayer}>
- <Player
- ref={playerRef}
- component={GithubDemo}
- compositionHeight={720}
- compositionWidth={1280}
- durationInFrames={100}
- fps={30}
- controls
- style={{ width: "100%" }}
- inputProps={{ data }}
- />
- </div>
- );
-};
diff --git a/packages/docs/components/LandingPage/githubdemo.module.css b/packages/docs/components/LandingPage/githubdemo.module.css
deleted file mode 100644
index 35e5608db0..0000000000
--- a/packages/docs/components/LandingPage/githubdemo.module.css
+++ /dev/null
@@ -1,15 +0,0 @@
-.githubdemotitle {
- font-size: 5em;
- color: var(--text-color);
- margin-bottom: 0;
- margin-top: 0;
- line-height: 1.4;
-}
-
-.githubdemodescription {
- font-size: 3em;
- margin-bottom: 0;
- margin-top: 0;
- line-height: 1.4;
- color: var(--text-color);
-}
diff --git a/packages/docs/components/LandingPage/parametrize.tsx b/packages/docs/components/LandingPage/parametrize.tsx
deleted file mode 100644
index a00e060506..0000000000
--- a/packages/docs/components/LandingPage/parametrize.tsx
+++ /dev/null
@@ -1,162 +0,0 @@
-import React, { useEffect, useReducer, useRef, useState } from "react";
-import "../input-fields.css";
-import { BlueButton } from "../layout/Button";
-import type { GithubResponse } from "./GithubDemo";
-import styles from "./parametrize.module.css";
-import { ProgrammaticContent } from "./Programmatic";
-
-const cache: { [key: string]: GithubResponse } = {};
-
-const makeRequest = async (username: string): Promise<GithubResponse> => {
- if (cache[username]) {
- return cache[username];
- }
-
- const response = await fetch(`https://api.github.com/users/${username}`);
- const json = await response.json();
- if (response.status !== 200) {
- throw new Error(json.message);
- }
-
- cache[username] = json;
- return json;
-};
-
-type Actions =
- | {
- type: "fetch-video";
- }
- | {
- type: "receive-video";
- response: GithubResponse;
- }
- | {
- type: "receive-error";
- error: Error;
- };
-
-type State =
- | {
- type: "error";
- error: Error;
- }
- | {
- type: "loaded";
- response: GithubResponse;
- }
- | {
- type: "loading";
- };
-
-const reducer = (state: State, action: Actions): State => {
- switch (action.type) {
- case "fetch-video":
- return {
- type: "loading",
- };
- case "receive-video":
- return {
- type: "loaded",
- response: action.response,
- };
- case "receive-error":
- return {
- type: "error",
- error: action.error,
- };
- default:
- return state;
- }
-};
-
-export const Parametrize: React.FC = () => {
- const ref = useRef<HTMLInputElement>(null);
- const [username, setUsername] = useState("JonnyBurger");
-
- const [state, dispatch] = useReducer(reducer, { type: "loading" });
-
- useEffect(() => {
- dispatch({
- type: "fetch-video",
- });
- makeRequest(username)
- .then((response) => {
- dispatch({
- type: "receive-video",
- response,
- });
- })
- .catch((error) => {
- dispatch({
- type: "receive-error",
- error,
- });
- });
- }, [username]);
-
- return (
- <div className={styles.parametrizerow}>
- <div style={{ flex: 1 }}>
- <h2 className={styles.parametrizetitle}>
- <span className={styles.parametrizegradient}>Programmatic</span>{" "}
- content <br />
- and rendering
- </h2>
- <p>
- Fetch data from an API and use it as the content. <br />
- Display it in real-time with the{" "}
- <a href="/player">@remotion/player</a>.<br />
- Render videos programmatically using{" "}
- <a href="/lambda">@remotion/lambda</a>.
- </p>
- <span style={{ fontSize: 13 }}>
- Customize the video by entering your GitHub username.
- </span>
- <div style={{ height: 10 }} />
- <div>
- <form
- onSubmit={(e) => {
- e.preventDefault();
- if (!ref.current?.value) {
- return;
- }
-
- setUsername(ref.current?.value as string);
- }}
- style={{ display: "flex", flexDirection: "row" }}
- >
- <input
- ref={ref}
- className={styles.parametrizeinput}
- type="text"
- placeholder="Your GitHub username"
- />{" "}
- <div style={{ width: 8, display: "inline-block" }} />
- <BlueButton
- loading={state.type === "loading"}
- fullWidth={false}
- size="sm"
- onClick={() => {
- if (!ref.current?.value) {
- return;
- }
-
- setUsername(ref.current?.value as string);
- }}
- >
- Show video
- </BlueButton>
- </form>
- </div>
- {state.type === "error" ? (
- <div style={{ color: "red", fontSize: 13 }}>
- Error: {state.error.message}
- </div>
- ) : null}
- </div>
- <ProgrammaticContent
- data={state.type === "loaded" ? state.response : null}
- />
- </div>
- );
-};
diff --git a/packages/docs/src/pages/index.tsx b/packages/docs/src/pages/index.tsx
index 99f0d7841d..94fd87c7da 100644
--- a/packages/docs/src/pages/index.tsx
+++ b/packages/docs/src/pages/index.tsx
@@ -15,7 +15,6 @@ import TrustedByBanner from '../../components/LandingPage/TrustedByBanner';
import {WriteInReact} from '../../components/LandingPage/WriteInReact';
import {LightningFastEditor} from '../../components/LandingPage/editor';
import {IfYouKnowReact} from '../../components/LandingPage/if-you-know-react';
-import {Parametrize} from '../../components/LandingPage/parametrize';
import {RealMP4Videos} from '../../components/LandingPage/real-mp4-videos';
import {Demo} from '../components/Demo/Demo';
import styles from './landing.module.css';
@@ -43,8 +42,7 @@ const NewLanding: React.FC = () => {
<IfYouKnowReact />
<br />
<br />
-
- <Demo />
+ <br />
<br />
<br />
<br />
@@ -57,15 +55,13 @@ const NewLanding: React.FC = () => {
<br />
<br />
<br />
- <br />
- <Parametrize />
- <br />
- <br />
<VideoAppsTitle />
<VideoApps active="remotion" />
<br />
+
+ <Demo />
+
<br />
- <CommunityStats />
<br />
<br />
<PricingTitle />
@@ -73,6 +69,15 @@ const NewLanding: React.FC = () => {
<TrustedByBanner />
<br />
<EvaluateRemotionSection />
+ <br />
+ <br />
+
+ <CommunityStats />
+ <br />
+ <br />
+ <br />
+ <br />
+
<NewsletterButton />
<br />
<br />