Skip to content

🎥 Make videos programmatically with React

refactor: clean up formatting and improve readability in Postmount examples

Shankhadeep Dey8ccf7dd74b1e
diff --git a/packages/example/src/Postmount/PostmountExample.tsx b/packages/example/src/Postmount/PostmountExample.tsx
index 33a73e85d6..012e44e89b 100644
--- a/packages/example/src/Postmount/PostmountExample.tsx
+++ b/packages/example/src/Postmount/PostmountExample.tsx
@@ -6,28 +6,25 @@ export const PostmountExample: React.FC = () => {
<AbsoluteFill>
<Series>
{/* First video with both premount and postmount */}
- <Series.Sequence
- durationInFrames={100}
+ <Series.Sequence
+ durationInFrames={100}
premountFor={20}
postmountFor={30}
>
<Video pauseWhenBuffering src={staticFile('framer.webm')} />
</Series.Sequence>
-
+
{/* Second video with just postmount to keep it in memory */}
- <Series.Sequence
- durationInFrames={150}
- postmountFor={50}
- >
- <Video
- pauseWhenBuffering
- src="https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"
+ <Series.Sequence durationInFrames={150} postmountFor={50}>
+ <Video
+ pauseWhenBuffering
+ src="https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"
/>
</Series.Sequence>
-
+
{/* Third video with both to enable smooth transitions */}
- <Series.Sequence
- durationInFrames={100}
+ <Series.Sequence
+ durationInFrames={100}
premountFor={25}
postmountFor={25}
>
@@ -42,8 +39,8 @@ export const PostmountWithStyles: React.FC = () => {
return (
<AbsoluteFill>
<Series>
- <Series.Sequence
- durationInFrames={100}
+ <Series.Sequence
+ durationInFrames={100}
premountFor={20}
postmountFor={30}
styleWhilePremounted={{
@@ -55,21 +52,39 @@ export const PostmountWithStyles: React.FC = () => {
transform: 'scale(1.2)',
}}
>
- <AbsoluteFill style={{background: 'blue', color: 'white', fontSize: 50, display: 'flex', alignItems: 'center', justifyContent: 'center'}}>
+ <AbsoluteFill
+ style={{
+ background: 'blue',
+ color: 'white',
+ fontSize: 50,
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ }}
+ >
<div>Scene 1</div>
</AbsoluteFill>
</Series.Sequence>
-
- <Series.Sequence
- durationInFrames={100}
+
+ <Series.Sequence
+ durationInFrames={100}
premountFor={20}
postmountFor={30}
>
- <AbsoluteFill style={{background: 'green', color: 'white', fontSize: 50, display: 'flex', alignItems: 'center', justifyContent: 'center'}}>
+ <AbsoluteFill
+ style={{
+ background: 'green',
+ color: 'white',
+ fontSize: 50,
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ }}
+ >
<div>Scene 2</div>
</AbsoluteFill>
</Series.Sequence>
</Series>
</AbsoluteFill>
);
-};
\ No newline at end of file
+};
diff --git a/packages/example/src/Postmount/index.tsx b/packages/example/src/Postmount/index.tsx
index 7b98c57d24..e47ae9349f 100644
--- a/packages/example/src/Postmount/index.tsx
+++ b/packages/example/src/Postmount/index.tsx
@@ -3,7 +3,7 @@ import {AbsoluteFill, Sequence, Video, staticFile} from 'remotion';
/**
* Example demonstrating postmountFor feature
- *
+ *
* postmountFor keeps a sequence mounted for X frames after its duration ends,
* improving performance when scrubbing backwards in the timeline.
*/
@@ -11,11 +11,7 @@ export const PostmountDemoComposition: React.FC = () => {
return (
<AbsoluteFill>
{/* Video that stays mounted 40 frames after it ends */}
- <Sequence
- from={50}
- durationInFrames={100}
- postmountFor={40}
- >
+ <Sequence from={50} durationInFrames={100} postmountFor={40}>
<Video pauseWhenBuffering src={staticFile('framer.webm')} />
</Sequence>
@@ -27,9 +23,9 @@ export const PostmountDemoComposition: React.FC = () => {
postmountFor={30}
>
<AbsoluteFill style={{background: 'rgba(255, 0, 0, 0.5)'}}>
- <Video
- pauseWhenBuffering
- src="https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"
+ <Video
+ pauseWhenBuffering
+ src="https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"
/>
</AbsoluteFill>
</Sequence>
@@ -72,30 +68,34 @@ export const PostmountWithCustomStyles: React.FC = () => {
transform: 'translateX(100px)',
}}
>
- <AbsoluteFill style={{
- background: 'linear-gradient(45deg, #667eea 0%, #764ba2 100%)',
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'center',
- fontSize: 60,
- color: 'white',
- fontFamily: 'Arial, sans-serif',
- }}>
+ <AbsoluteFill
+ style={{
+ background: 'linear-gradient(45deg, #667eea 0%, #764ba2 100%)',
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ fontSize: 60,
+ color: 'white',
+ fontFamily: 'Arial, sans-serif',
+ }}
+ >
<div>Mounted Content</div>
</AbsoluteFill>
</Sequence>
{/* Visual indicator showing mount status */}
- <Sequence from={0} durationInFrames={140}>
- <div style={{
- position: 'absolute',
- top: 20,
- left: 20,
- fontSize: 20,
- color: 'black',
- background: 'white',
- padding: 10,
- }}>
+ <Sequence durationInFrames={140}>
+ <div
+ style={{
+ position: 'absolute',
+ top: 20,
+ left: 20,
+ fontSize: 20,
+ color: 'black',
+ background: 'white',
+ padding: 10,
+ }}
+ >
Frame timeline:
<br />
0-10: Not mounted
@@ -111,4 +111,4 @@ export const PostmountWithCustomStyles: React.FC = () => {
</Sequence>
</AbsoluteFill>
);
-};
\ No newline at end of file
+};