Skip to content

🎥 Make videos programmatically with React

add loopdisplay test

Jonny Burgera294d814cb7a
diff --git a/packages/example/src/LoopDisplayTest.tsx b/packages/example/src/LoopDisplayTest.tsx
new file mode 100644
index 0000000000..d99ef12f44
--- /dev/null
+++ b/packages/example/src/LoopDisplayTest.tsx
@@ -0,0 +1,54 @@
+import {CalculateMetadataFunction, Composition, Html5Video} from 'remotion';
+// https://www.remotion.dev/docs/mediabunny/metadata
+import {Video} from '@remotion/media';
+import {getMediaMetadata} from './get-media-metadata';
+
+const src = 'https://remotion.media/video-1m.mp4';
+
+export const calculateMetadataFn: CalculateMetadataFunction<
+ Record<string, unknown>
+> = async () => {
+ const {dimensions, fps} = await getMediaMetadata(src);
+
+ return {
+ durationInFrames: fps! * 180,
+ fps: fps!,
+ width: dimensions!.width,
+ height: dimensions!.height,
+ };
+};
+
+export const Component = () => {
+ return (
+ <>
+ <Html5Video
+ src={src}
+ trimBefore={90}
+ trimAfter={60 * 30}
+ playbackRate={0.5}
+ loop
+ name="Html5Video"
+ style={{width: '50%'}}
+ />
+ <Video
+ src={src}
+ trimBefore={90}
+ trimAfter={60 * 30}
+ playbackRate={0.5}
+ loop
+ name="MediaVideo"
+ style={{width: '50%'}}
+ />
+ </>
+ );
+};
+
+export const LoopDisplayTestComp = () => {
+ return (
+ <Composition
+ component={Component}
+ id="LoopDisplayTest"
+ calculateMetadata={calculateMetadataFn}
+ />
+ );
+};
diff --git a/packages/example/src/Root.tsx b/packages/example/src/Root.tsx
index 53456a5e45..770534e8bf 100644
--- a/packages/example/src/Root.tsx
+++ b/packages/example/src/Root.tsx
@@ -137,6 +137,7 @@ import {LightLeakExample} from './LightLeak';
import {LightLeakAnimatedSize} from './LightLeak/AnimatedSize';
import {NewAudioExample} from './NewAudio/NewAudio';
import {NewVideoComp} from './NewVideo';
+import {LoopDisplayTestComp} from './LoopDisplayTest';
import {ChangingTrimBeforeValue} from './OffthreadRemoteVideo/ChangingTrimBefore';
import {LoopedNewVideo} from './OffthreadRemoteVideo/LoopedNewVideo';
import {LoopedOffthreadRemoteVideo} from './OffthreadRemoteVideo/LoopedOffthreadRemoteVideo';
@@ -793,6 +794,7 @@ export const Index: React.FC = () => {
/>
<OffthreadRemoteVideo />
<NewVideoComp />
+ <LoopDisplayTestComp />
<OffthreadRemoteSeries />
<LoopedNewVideo />
<LoopedOffthreadRemoteVideo />