Skip to content

🎥 Make videos programmatically with React

get it working

Jonny Burger884a154ddf19
diff --git a/packages/core/src/get-static-files.ts b/packages/core/src/get-static-files.ts
index fc64ac5a12..72e105f5aa 100644
--- a/packages/core/src/get-static-files.ts
+++ b/packages/core/src/get-static-files.ts
@@ -38,8 +38,18 @@ export const getStaticFiles = (): StaticFile[] => {
};
export type StaticFile = {
+ /**
+ * A string that you can pass to the `src` attribute of an `<Audio>`, `<Img>` and `<Video>` element.
+ */
src: string;
+ /**
+ * The filepath of the file, relative to the public folder.
+ * Example: `subfolder/image.png`
+ */
name: string;
sizeInBytes: number;
+ /**
+ * UNIX timestamp in milliseconds
+ */
lastModified: number;
};
diff --git a/packages/example/src/AudioTesting/index.tsx b/packages/example/src/AudioTesting/index.tsx
index 7177774a74..de1bb273d0 100644
--- a/packages/example/src/AudioTesting/index.tsx
+++ b/packages/example/src/AudioTesting/index.tsx
@@ -1,14 +1,8 @@
-import {
- Audio,
- getStaticFiles,
- interpolate,
- Sequence,
- staticFile,
-} from 'remotion';
+import {Audio, getStaticFiles, interpolate, Sequence} from 'remotion';
const AudioTesting: React.FC = () => {
const files = getStaticFiles();
- const music = files.find((f) => f.path.startsWith('music.mp3'));
+ const music = files.find((f) => f.name.startsWith('music.mp3'));
return (
<div>
@@ -17,7 +11,7 @@ const AudioTesting: React.FC = () => {
loop
startFrom={100}
endAt={200}
- src={staticFile(music?.path as string)}
+ src={music?.src}
volume={(f) =>
interpolate(f, [0, 50, 100], [0, 1, 0], {
extrapolateLeft: 'clamp',