Skip to content

The swiss army knife of lossless video/audio editing

Website: show the hero video (src/assets/home/hero.mp4) in a window frame, with a pause button, and only its poster with reduced motion

Claude8f34dae40371
diff --git a/AGENTS.md b/AGENTS.md
index 5ac31bec..0784ca8c 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -36,4 +36,4 @@ When a visual or especially interesting feature lands in master, suggest a short
- Ask the user to make a screenshot or a short silent screen recording (about 10 seconds) that shows it.
- Say that people can try it now in the latest nightly build (https://mifi.no/llc/nightly/), and that it will be in the next release.
-- Such a clip can also become the homepage's demo (`website/src/assets/home/demo.mp4`, shown in the hero instead of the screenshot).
+- Such a clip can also become the homepage's hero video (`website/src/assets/home/hero.mp4`, 1024×640, with a still of its first frame as `hero-poster.jpg`), shown instead of the screenshot.
diff --git a/website/src/components/Home.tsx b/website/src/components/Home.tsx
index 011d0e43..4b14861c 100644
--- a/website/src/components/Home.tsx
+++ b/website/src/components/Home.tsx
@@ -4,7 +4,7 @@ import type { CSSProperties, ReactNode } from 'react';
import type { IconNode } from 'lucide';
import { Combine, Film, Layers, ListOrdered, RefreshCw, ScanSearch, Scissors, SquarePen, Terminal } from 'lucide';
import type { IconNode as ReactIconNode } from 'lucide-react';
-import { CodeXml, Icon, Languages, Monitor, Star } from 'lucide-react';
+import { CodeXml, Icon, Languages, Monitor, Pause, Play, Star } from 'lucide-react';
import macAppStoreBadge from '../../../mac-app-store-badge.svg?url';
import msStoreBadge from '../../../ms-store-badge.svg?url';
@@ -20,10 +20,10 @@ import tracksScreenshot from '../assets/home/tracks-screenshot.jpg?url';
import { authorUrl, donateUrl, githubUrl, socialLinks, storeUrls, supportEmail } from '../links.ts';
import socialIconPaths from './socialIcons.ts';
-// An optional short, silent screen recording for the hero (src/assets/home/demo.mp4 and/or demo.webm), shown instead of the screenshot
-const demoClips = import.meta.glob<string>('../assets/home/demo.{webm,mp4}', { eager: true, query: '?url', import: 'default' });
-const demoSources = Object.entries(demoClips).toSorted(([a], [b]) => (a.endsWith('.webm') ? -1 : 1) - (b.endsWith('.webm') ? -1 : 1))
- .map(([path, url]) => ({ url, type: path.endsWith('.webm') ? 'video/webm' : 'video/mp4' }));
+// An optional short, silent screen recording for the hero (src/assets/home/hero.mp4, 1024×640, looping), shown in a window
+// frame instead of the screenshot, with a still of its first frame as the poster (src/assets/home/hero-poster.jpg)
+const heroVideo = Object.values(import.meta.glob<string>('../assets/home/hero.mp4', { eager: true, query: '?url', import: 'default' }))[0];
+const heroPoster = Object.values(import.meta.glob<string>('../assets/home/hero-poster.jpg', { eager: true, query: '?url', import: 'default' }))[0] ?? mainScreenshot;
const quotes = [
'I\'ve been looking a long time for a program like LosslessCut',
@@ -163,11 +163,21 @@ export default function Home({ stars }: { stars: number }) {
</div>
<div className="hero-media">
- {demoSources.length > 0 ? (
- // controls: a looping video must be pausable (WCAG 2.2.2), and there's no script for a custom button
- <video autoPlay muted loop playsInline controls width={1000} height={624} poster={mainScreenshot} aria-label="LosslessCut cutting a video">
- {demoSources.map(({ url, type }) => <source key={url} src={url} type={type} />)}
- </video>
+ {heroVideo != null ? (
+ <div className="hero-video">
+ <div className="hero-video-title">
+ <span className="hero-video-dots" aria-hidden="true"><i /><i /><i /></span>
+ LosslessCut
+ {/* a looping video must be pausable (WCAG 2.2.2). Shown by the script in index.astro */}
+ <button type="button" className="hero-video-pause" aria-label="Pause the video" hidden>
+ <Pause className="pause" aria-hidden size={14} />
+ <Play className="play" aria-hidden size={14} />
+ </button>
+ </div>
+ {/* with prefers-reduced-motion, the poster is shown instead (home.css), and the script stops the video */}
+ <video src={heroVideo} poster={heroPoster} autoPlay muted loop playsInline preload="metadata" width={1024} height={640} aria-label="LosslessCut cutting a video into segments" />
+ <img className="hero-video-poster" src={heroPoster} alt="LosslessCut with a video cut into segments" width={1024} height={640} />
+ </div>
) : (
<img src={mainScreenshot} alt="LosslessCut main window" width={1000} height={624} fetchPriority="high" />
)}
diff --git a/website/src/pages/index.astro b/website/src/pages/index.astro
index 3faac516..1f35ac6b 100644
--- a/website/src/pages/index.astro
+++ b/website/src/pages/index.astro
@@ -36,6 +36,27 @@ const description = 'LosslessCut - Official downloads - free or paid version. Ed
<Home stars={stars} />
<!-- is:inline: plain JS, not compiled by Vite, which would look for a tsconfig and find the app's (see tsconfig.json) -->
<script is:inline>
+ // The hero video's pause button (Home.tsx), and with prefers-reduced-motion, no video at all (only its poster, see home.css)
+ {
+ const heroVideo = document.querySelector('.hero-video video');
+ if (heroVideo) {
+ if (matchMedia('(prefers-reduced-motion: reduce)').matches) {
+ heroVideo.removeAttribute('autoplay');
+ heroVideo.pause();
+ } else {
+ const pauseButton = document.querySelector('.hero-video-pause');
+ pauseButton.hidden = false;
+ pauseButton.addEventListener('click', () => (heroVideo.paused ? heroVideo.play() : heroVideo.pause()));
+ const update = () => {
+ pauseButton.classList.toggle('paused', heroVideo.paused);
+ pauseButton.setAttribute('aria-label', heroVideo.paused ? 'Play the video' : 'Pause the video');
+ };
+ heroVideo.addEventListener('play', update);
+ heroVideo.addEventListener('pause', update);
+ }
+ }
+ }
+
// On touch screens, draw each feature card's icon when the card reaches the middle of the screen (.draw in home.css), again
// after it has left the screen, and when it's tapped. Cards that are on screen when scrolling stops without having passed the
// middle (after a jump to a link, or a fast scroll) are drawn then. (Scroll-driven CSS animations can't do this yet in all
diff --git a/website/src/styles/home.css b/website/src/styles/home.css
index d10a23fb..39aa53ae 100644
--- a/website/src/styles/home.css
+++ b/website/src/styles/home.css
@@ -126,13 +126,79 @@ body {
flex: 1 1 500px;
max-width: 640px;
}
-.hero-media img, .hero-media video {
+.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;
+ overflow: hidden;
+ border: 1px solid rgba(255, 255, 255, 0.12);
+ box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
+}
+.hero-video-title {
+ position: relative;
+ height: 28px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ background-color: #2b2b2b;
+ color: rgba(255, 255, 255, 0.7);
+ font: 13px system-ui, sans-serif;
+}
+.hero-video-dots {
+ position: absolute;
+ left: 12px;
+ display: flex;
+ gap: 6px;
+}
+.hero-video-dots i {
+ width: 10px;
+ height: 10px;
+ border-radius: 50%;
+ background-color: rgba(255, 255, 255, 0.25);
+}
+.hero-video-pause {
+ position: absolute;
+ right: 6px;
+ display: grid;
+ place-items: center;
+ width: 22px;
+ height: 22px;
+ padding: 0;
+ border: none;
+ border-radius: 4px;
+ background: none;
+ color: inherit;
+ cursor: pointer;
+}
+.hero-video-pause:hover {
+ background-color: rgba(255, 255, 255, 0.1);
+}
+.hero-video-pause[hidden], .hero-video-pause:not(.paused) .play, .hero-video-pause.paused .pause {
+ display: none;
+}
+.hero-video video, .hero-video-poster {
+ display: block;
+ width: 100%;
+ height: auto;
+ aspect-ratio: 16 / 10;
+}
+.hero-video-poster {
+ display: none;
+}
+@media (prefers-reduced-motion: reduce) {
+ .hero-video video, .hero-video-pause {
+ display: none;
+ }
+ .hero-video-poster {
+ display: block;
+ }
+}
.button {
display: inline-block;
padding: 10px 24px;