🎥 Make videos programmatically with React
add some text to the bundle
Jonny Burger9f8d360a122c
diff --git a/packages/bundler/src/homepage/homepage.tsx b/packages/bundler/src/homepage/homepage.tsxnew file mode 100644index 0000000000..f190776eac--- /dev/null+++ b/packages/bundler/src/homepage/homepage.tsx@@ -0,0 +1,112 @@+import React, {useCallback, useEffect, useState} from 'react';+import {Internals, TCompMetadata} from 'remotion';++const container: React.CSSProperties = {+ width: 800,+ margin: 'auto',+ paddingLeft: 20,+ paddingRight: 20,+ fontFamily: 'sans-serif',+ lineHeight: 1.5,+};++const pre: React.CSSProperties = {+ display: 'block',+ backgroundColor: '#f7f7f7',+ whiteSpace: 'nowrap',+ padding: 16,+ fontFamily: 'monospace',+ borderRadius: 5,+ fontSize: 15,+ overflowX: 'auto',+};++export const AvailableCompositions: React.FC = () => {+ const [comps, setComps] = useState<TCompMetadata[] | null>(null);++ useEffect(() => {+ let timeout: NodeJS.Timeout | null = null;+ const check = () => {+ if (window.ready === true) {+ setComps(window.getStaticCompositions());+ } else {+ timeout = setTimeout(check, 250);+ }+ };++ check();++ return () => {+ if (!timeout) {+ return;+ }++ clearTimeout(timeout);+ };+ }, []);++ const showComps = useCallback(() => {+ window.location.search = '?evaluation=true';+ }, []);++ if (!Internals.getIsEvaluation()) {+ return (+ <button type="button" onClick={showComps}>+ Click here to see a list of available compositions.+ </button>+ );+ }++ return (+ <div>+ {comps === null ? <p>Loading compositions...</p> : null}+ <ul>+ {comps === null+ ? null+ : comps.map((c) => {+ return <li key={c.id}>{c.id}</li>;+ })}+ </ul>+ </div>+ );+};++export const Homepage: React.FC = () => {+ const url = window.location.origin + window.location.pathname;+ return (+ <div style={container}>+ <h1>Remotion Bundle</h1>+ This is a website which contains a bundled Remotion video. You can render+ videos based on this URL.+ <h2>Available compositions</h2>+ <AvailableCompositions />+ <h2>How to render</h2>+ Locally: <br />+ <br />+ <div style={pre}>+ npx remotion render {url} {'<comp-name> <output-location>'}+ </div>+ <br />+ <br />+ With Remotion Lambda: <br />+ <br />+ <div style={pre}>+ npx remotion lambda render {url} {'<comp-name>'}+ </div>+ <br />+ <p>+ You can also render still images, and use the Node.JS APIs{' '}+ <code>getCompositions()</code>, <code>renderMedia()</code>,{' '}+ <code>renderVideoOnLambda()</code>, <code>renderStill()</code> and{' '}+ <code>renderStillOnLambda()</code> with this URL.+ </p>+ <p>+ Visit{' '}+ <a href="https://remotion.dev/docs" target="_blank">+ remotion.dev/docs+ </a>{' '}+ to read the documentation.+ </p>+ </div>+ );+};diff --git a/packages/bundler/src/renderEntry.tsx b/packages/bundler/src/renderEntry.tsxindex 4e225c9a3a..0173e97480 100644--- a/packages/bundler/src/renderEntry.tsx+++ b/packages/bundler/src/renderEntry.tsx@@ -14,6 +14,7 @@ import {LooseAnyComponent,TComposition,} from 'remotion';+import {Homepage} from './homepage/homepage';Internals.CSSUtils.injectCSS(Internals.CSSUtils.makeDefaultCSS(null));@@ -49,9 +50,11 @@ const GetVideo = () => {if (!video && compositions.compositions.length > 0) {compositions.setCurrentComposition(- (compositions.compositions.find(- (c) => c.id === Internals.getCompositionName()- ) as TComposition)?.id ?? null+ (+ compositions.compositions.find(+ (c) => c.id === Internals.getCompositionName()+ ) as TComposition+ )?.id ?? null);}}, [compositions, compositions.compositions, video]);@@ -111,3 +114,7 @@ if (!Internals.isPlainIndex()) {document.getElementById('container'));}++if (Internals.isPlainIndex() || Internals.getIsEvaluation()) {+ render(<Homepage />, document.getElementById('container'));+}