Skip to content

🎥 Make videos programmatically with React

test staticFile in example CRA app

Jonny Burger8533a0f968c9
diff --git a/packages/bundler/src/bundler.ts b/packages/bundler/src/bundler.ts
index a5ec663922..ebf82a9943 100644
--- a/packages/bundler/src/bundler.ts
+++ b/packages/bundler/src/bundler.ts
@@ -54,14 +54,15 @@ export const bundle = async (
throw new Error(errors[0].message + '\n' + errors[0].details);
}
- // TODO: What if public folder does not exist?
+ const from = path.join(process.cwd(), 'public');
+ const to = path.join(outDir, 'public');
+ if (fs.existsSync(from)) {
+ await copyDir(from, to);
+ }
// TODO: Make this better in Lambda
const html = indexHtml(`/public`);
fs.writeFileSync(path.join(outDir, 'index.html'), html);
- const from = path.join(process.cwd(), 'public');
- const to = path.join(outDir, 'public');
- await copyDir(from, to);
return outDir;
};
diff --git a/packages/player-example/public/logo.png b/packages/player-example/public/logo.png
new file mode 100644
index 0000000000..a35f38446a
Binary files /dev/null and b/packages/player-example/public/logo.png differ
diff --git a/packages/player-example/src/CarSlideshow.tsx b/packages/player-example/src/CarSlideshow.tsx
index ed5af154ed..29e0c1acb2 100644
--- a/packages/player-example/src/CarSlideshow.tsx
+++ b/packages/player-example/src/CarSlideshow.tsx
@@ -1,5 +1,12 @@
import {createRef, useCallback, useImperativeHandle, useState} from 'react';
-import {interpolate, useCurrentFrame, useVideoConfig, Video} from 'remotion';
+import {
+ Img,
+ interpolate,
+ useCurrentFrame,
+ useVideoConfig,
+ Video,
+ staticFile,
+} from 'remotion';
type Props = {
title: string;
@@ -61,6 +68,13 @@ const CarSlideshow = ({title, bgColor, color}: Props) => {
>
{title} {dummyText()}
</h1>
+ <Img
+ src={staticFile('/logo.png')}
+ style={{
+ height: 40,
+ width: 40,
+ }}
+ />
<Video
style={{
height: 200,