Skip to content

🎥 Make videos programmatically with React

add new-audio example with mp3

Igor Samokhovets5895ae9b964f
diff --git a/packages/example/src/NewAudio/NewAudio.tsx b/packages/example/src/NewAudio/NewAudio.tsx
new file mode 100644
index 0000000000..213632d722
--- /dev/null
+++ b/packages/example/src/NewAudio/NewAudio.tsx
@@ -0,0 +1,17 @@
+import {Audio as NewAudio} from '@remotion/media';
+
+interface NewAudioProps {
+ src?: string;
+}
+
+export const NewAudioExample: React.FC<NewAudioProps> = ({src}) => {
+ if (!src) {
+ return <div>No audio source provided</div>;
+ }
+
+ return (
+ <>
+ <NewAudio src={src} />
+ </>
+ );
+};
diff --git a/packages/example/src/Root.tsx b/packages/example/src/Root.tsx
index ee91432e66..056a596a74 100644
--- a/packages/example/src/Root.tsx
+++ b/packages/example/src/Root.tsx
@@ -130,6 +130,7 @@ import {
import {EdgeBlur} from './EdgeBlur/EdgeBlur';
import {Empty} from './Empty';
import {JumpCuts, SAMPLE_SECTIONS, calculateMetadataJumpCuts} from './JumpCuts';
+import {NewAudioExample} from './NewAudio/NewAudio';
import {NewVideoExample} from './NewVideo/NewVideo';
import {LoopedOffthreadRemoteVideo} from './OffthreadRemoteVideo/LoopedOffthreadRemoteVideo';
import {MultiChannelAudio} from './OffthreadRemoteVideo/MultiChannelAudio';
@@ -668,7 +669,7 @@ export const Index: React.FC = () => {
}}
/>
</Folder>
- <Folder name="new-video-tests">
+ <Folder name="new-media-tags">
<Composition
id="new-video"
component={NewVideoExample}
@@ -700,6 +701,32 @@ export const Index: React.FC = () => {
};
}}
/>
+ <Composition
+ id="new-audio"
+ component={NewAudioExample}
+ fps={30}
+ defaultProps={{
+ src: staticFile('music.mp3'),
+ }}
+ calculateMetadata={async ({props}) => {
+ const fps = 30;
+
+ const {slowDurationInSeconds} = await parseMedia({
+ src: props.src as string,
+ fields: {
+ slowDurationInSeconds: true,
+ },
+ });
+
+ return {
+ props: props,
+ durationInFrames: Math.round(slowDurationInSeconds * fps),
+ fps,
+ width: 800,
+ height: 800,
+ };
+ }}
+ />
<Composition
id="video-testing-playback-codec"
component={VideoTestingPlayback}