π₯ Make videos programmatically with React
layout fixes
Jonny Burger5feac6f00484
diff --git a/packages/docs/components/LandingPage/VideoAppsShowcase.module.css b/packages/docs/components/LandingPage/VideoAppsShowcase.module.cssindex 2961d9fbe6..f09cc9eff4 100644--- a/packages/docs/components/LandingPage/VideoAppsShowcase.module.css+++ b/packages/docs/components/LandingPage/VideoAppsShowcase.module.css@@ -1,7 +1,6 @@.container {max-width: 1200px;margin: 0 auto;- padding: 2rem;}.tabs {@@ -13,42 +12,40 @@.tab {background: none;border: none;- padding: 10px 15px; /* Adjust these values as needed */- margin: 0.2rem 0.6rem;+ margin: 10px 15px; /* Adjust these values as needed */cursor: pointer;font-size: 16px; /* Default font size */font-weight: bold;transition: color 0.3s ease;color: #888; /* Light gray for inactive tabs */+ font-family: 'GTPlanar';}@media (max-width: 900px) {.tab {font-size: 14px; /* Smaller font size for screens less than 600px wide */- padding: 8px 10px; /* Smaller padding for narrow screens */- margin: 0.1rem 0.3rem; /* Reduce margin between tabs */+ margin: 8px 10px; /* Smaller padding for narrow screens */}}@media (max-width: 500px) {.tab {font-size: 12px; /* Even smaller font size for screens 500px and below */- padding: 6px 8px; /* Further reduce padding if needed */+ margin: 6px 8px; /* Further reduce padding if needed */}}.activeTab {color: #007bff;- border-bottom: 2px solid #007bff;}.content {display: flex;align-items: stretch;- border: 5px solid var(--text-color); /* Add black border */+ border: 2px solid var(--text-color); /* Add black border */+ border-bottom: 4px solid;border-radius: 16px; /* Rounded corners */overflow: hidden; /* Ensure content doesn't overflow rounded corners */- padding: 16px;}.videoWrapper {@@ -60,10 +57,12 @@.videoContainer {width: 100%;- max-width: 500px; /* Adjust this value as needed */+ max-width: 500px;aspect-ratio: 1 / 1;position: relative;border-radius: 8px;+ border-top-right-radius: 0;+ border-bottom-right-radius: 0;overflow: hidden;background-color: rgba(104, 104, 104, 0.171);}@@ -76,6 +75,8 @@height: 100%;object-fit: contain;border-radius: 8px;+ border-top-right-radius: 0;+ border-bottom-right-radius: 0;}.playButton {@@ -140,6 +141,11 @@padding-left: 0;padding-top: 16px; /* Add space between video and text on mobile */}++ .videoContainer {+ border-top-right-radius: 8px;+ border-bottom-right-radius: 8px;+ }}.titleContainer {diff --git a/packages/docs/components/LandingPage/VideoAppsShowcase.tsx b/packages/docs/components/LandingPage/VideoAppsShowcase.tsxindex 340e6c31c6..2b002b05c8 100644--- a/packages/docs/components/LandingPage/VideoAppsShowcase.tsx+++ b/packages/docs/components/LandingPage/VideoAppsShowcase.tsx@@ -64,14 +64,11 @@ const videoApps = [const VideoAppsShowcase: React.FC = () => {const [activeTab, setActiveTab] = useState(0);- const [isPlaying, setIsPlaying] = useState(false);const [isMuted, setIsMuted] = useState(true);const videoRef = useRef<HTMLVideoElement>(null);const containerRef = useRef<HTMLDivElement>(null);useEffect(() => {- setActiveTab(0); // Set to 0 for "Music visualization"-const observer = new IntersectionObserver((entries) => {if (entries[0].isIntersecting) {@@ -80,17 +77,13 @@ const VideoAppsShowcase: React.FC = () => {setIsMuted(true); // Update state to reflect muted statusvideoRef.current.play()- .then(() => {- setIsPlaying(true);- })+ .then(() => {}).catch((error) => {console.error('Playback error:', error);- setIsPlaying(false);});}} else if (videoRef.current && !videoRef.current.paused) {videoRef.current.pause();- setIsPlaying(false);}},{threshold: 0.5},@@ -109,7 +102,6 @@ const VideoAppsShowcase: React.FC = () => {}, []);useEffect(() => {- setIsPlaying(false);const video = videoRef.current;if (video) {video.pause();@@ -121,21 +113,16 @@ const VideoAppsShowcase: React.FC = () => {(entries) => {if (entries[0].isIntersecting) {// Introduce a delay before playing the video- setTimeout(() => {- if (video) {- video.muted = true; // Ensure video is muted before autoplay- setIsMuted(true); // Update state to reflect muted status- video- .play()- .then(() => {- setIsPlaying(true);- })- .catch((error) => {- console.error('Playback error:', error);- setIsPlaying(false);- });- }- }, 750); // 750ms (0.75 second) delay, adjust as needed+ if (video) {+ video.muted = true; // Ensure video is muted before autoplay+ setIsMuted(true); // Update state to reflect muted status+ video+ .play()+ .then(() => {})+ .catch((error) => {+ console.error('Playback error:', error);+ });+ }}},{threshold: 0.5},@@ -164,17 +151,14 @@ const VideoAppsShowcase: React.FC = () => {playPromise.then(() => {// Playback started successfully- setIsPlaying(true);}).catch((error) => {// Auto-play was prevented or there was an errorconsole.error('Playback error:', error);- setIsPlaying(false);});}} else {videoRef.current.pause();- setIsPlaying(false);}}};@@ -190,10 +174,7 @@ const VideoAppsShowcase: React.FC = () => {return (<div ref={containerRef} className={styles.container}><div className={styles.titleContainer}>- <h2 className={styles.title}>- Video apps created with{' '}- <span className={styles.highlight}>Remotion</span>- </h2>+ <h2 className={styles.title}>Use Cases</h2></div><div className={styles.tabs}>{tabs.map((tab, index) => (@@ -214,16 +195,11 @@ const VideoAppsShowcase: React.FC = () => {ref={videoRef}muxId={videoApps[activeTab].muxId}className={styles.video}- poster={videoApps[activeTab].thumbnailSrc}loopplaysInlinemuted={isMuted}/>- {!isPlaying && (- <div className={styles.playButton}>- <span>βΆ</span>- </div>- )}+<buttontype="button"className={styles.muteButton}@@ -232,7 +208,21 @@ const VideoAppsShowcase: React.FC = () => {handleMuteToggle();}}>- {isMuted ? 'π' : 'π'}+ {isMuted ? (+ <svg style={{width: 24}} viewBox="0 0 576 512">+ <path+ fill="white"+ d="M0 160L0 352l128 0L272 480l48 0 0-448-48 0L128 160 0 160zm441 23l-17-17L390.1 200l17 17 39 39-39 39-17 17L424 345.9l17-17 39-39 39 39 17 17L569.9 312l-17-17-39-39 39-39 17-17L536 166.1l-17 17-39 39-39-39z"+ />+ </svg>+ ) : (+ <svg style={{width: 24}} viewBox="0 0 576 512">+ <path+ fill="white"+ d="M32 160l0 192 128 0L304 480l48 0 0-448-48 0L160 160 32 160zM441.6 332.8C464.9 315.3 480 287.4 480 256s-15.1-59.3-38.4-76.8l-28.8 38.4c11.7 8.8 19.2 22.7 19.2 38.4s-7.5 29.6-19.2 38.4l28.8 38.4zm57.6 76.8c46.6-35 76.8-90.8 76.8-153.6s-30.2-118.6-76.8-153.6l-28.8 38.4c35 26.3 57.6 68.1 57.6 115.2s-22.6 88.9-57.6 115.2l28.8 38.4z"+ />+ </svg>+ )}</button></div></div>@@ -263,7 +253,7 @@ const VideoAppsShowcase: React.FC = () => {fontFamily: 'GTPlanar',}}>- For more examples see our <a href="../showcase">showcase page</a>.+ For more examples see our <a href="/showcase">showcase page</a>.</div></div></div>diff --git a/packages/docs/src/pages/index.tsx b/packages/docs/src/pages/index.tsxindex 17ee19257d..0ab8b4afee 100644--- a/packages/docs/src/pages/index.tsx+++ b/packages/docs/src/pages/index.tsx@@ -59,8 +59,10 @@ const NewLanding: React.FC = () => {<VideoAppsTitle /><VideoApps active="remotion" /><br />+ <br /><VideoAppsShowcase />- <CommunityStats />+ <br />+ <br /><Demo /><br /><br />@@ -73,10 +75,10 @@ const NewLanding: React.FC = () => {<br /><br /><br />+ <CommunityStats /><br /><br /><br />-<NewsletterButton /><br /><br />