Skip to content

The swiss army knife of lossless video/audio editing

Website: hero video review fixes

Clauded3cd02d8fe07
diff --git a/website/src/components/Home.tsx b/website/src/components/Home.tsx
index 668ea9b0..aae87ad3 100644
--- a/website/src/components/Home.tsx
+++ b/website/src/components/Home.tsx
@@ -1,5 +1,5 @@
-// The homepage content. Rendered to static HTML at build time (no client-side JavaScript, except a small script for the feature icon
-// animation in index.astro).
+// The homepage content. Rendered to static HTML at build time (no client-side JavaScript, except a small script in index.astro for
+// the hero video's pause button and the feature icon animation).
import type { CSSProperties, ReactNode } from 'react';
import type { IconNode } from 'lucide';
import { Combine, Film, Layers, ListOrdered, RefreshCw, ScanSearch, Scissors, SquarePen, Terminal } from 'lucide';
@@ -165,8 +165,10 @@ export default function Home({ stars }: { stars: number }) {
</div>
{/* with prefers-reduced-motion, the poster is shown instead (home.css), and the script stops the video */}
<video poster={heroVideo.poster} autoPlay muted loop playsInline preload="metadata" width={1024} height={640} aria-label="LosslessCut cutting a video into three segments">
- <source src={heroVideo.smallSrc} type="video/mp4" media="(max-width: 700px)" />
- <source src={heroVideo.src} type="video/mp4" />
+ {/* with reduced motion, neither matches, so nothing is downloaded. Browsers that ignore media (before Chrome/Firefox
+ 120) take the first one, and the script removes them with reduced motion */}
+ <source src={heroVideo.src} type="video/mp4" media="(min-width: 701px) and (prefers-reduced-motion: no-preference)" />
+ <source src={heroVideo.smallSrc} type="video/mp4" media="(prefers-reduced-motion: no-preference)" />
</video>
<img className="hero-video-poster" src={heroVideo.poster} alt="LosslessCut with a video opened" width={1024} height={640} fetchPriority="high" />
</div>
diff --git a/website/src/pages/index.astro b/website/src/pages/index.astro
index b22757c8..e9165de1 100644
--- a/website/src/pages/index.astro
+++ b/website/src/pages/index.astro
@@ -42,8 +42,12 @@ const description = 'LosslessCut - Official downloads - free or paid version. Ed
const heroVideo = document.querySelector('.hero-video video');
if (heroVideo) {
if (matchMedia('(prefers-reduced-motion: reduce)').matches) {
+ // and don't download it (in browsers that ignore the sources' media, see Home.tsx)
heroVideo.removeAttribute('autoplay');
heroVideo.pause();
+ heroVideo.preload = 'none';
+ heroVideo.querySelectorAll('source').forEach((source) => source.remove());
+ heroVideo.load();
} else {
const pauseButton = document.querySelector('.hero-video-pause');
pauseButton.hidden = false;
@@ -55,6 +59,8 @@ const description = 'LosslessCut - Official downloads - free or paid version. Ed
heroVideo.addEventListener('play', update);
heroVideo.addEventListener('pause', update);
update(); // e.g. if the browser didn't autoplay it
+ // no button for a video that can't play
+ heroVideo.querySelector('source:last-of-type')?.addEventListener('error', () => { pauseButton.hidden = true; });
}
}
}
diff --git a/website/src/styles/home.css b/website/src/styles/home.css
index 39aa53ae..c3c4cb53 100644
--- a/website/src/styles/home.css
+++ b/website/src/styles/home.css
@@ -126,13 +126,6 @@ body {
flex: 1 1 500px;
max-width: 640px;
}
-.hero-media > img {
- display: block;
- width: 100%;
- height: auto;
- border-radius: 10px;
- box-shadow: rgba(0, 0, 0, 0.45) 0 20px 50px, rgba(51, 222, 239, 0.15) 0 0 0 1px;
-}
/* the hero video (Home.tsx) in a plain window frame, not macOS-like, since the app also runs on Windows and Linux */
.hero-video {
border-radius: 10px;