'use client'; import { Volume2, VolumeX } from 'lucide-react'; import { useCallback, useRef, useState } from 'react'; /** * Hero video player with a frosted-glass mute toggle. * * Why not the native `controls` attribute: it pulls in a chrome bar that * fights the section's design vocabulary. We need exactly one control — * mute / unmute — so we render just that, styled to match the rest of * the brand (frosted indigo-bordered pill, bottom-right of the video). * * Default state is MUTED because every modern browser blocks autoplay * for unmuted media. The toggle is the user's explicit affordance to * turn the voice-over on; we keep the `muted` attribute on the element * as the initial value so the autoplay still fires. * * On unmute we also call `.play()` defensively — some browsers (mobile * Safari especially) pause the element when the muted property flips, * even mid-playback. The promise is swallowed because a rejection here * just means the user has to click again, which the toggle already * affords. */ export function HeroVideo() { const videoRef = useRef(null); const [muted, setMuted] = useState(true); const toggleMute = useCallback(() => { const v = videoRef.current; if (!v) return; const next = !v.muted; v.muted = next; setMuted(next); if (!next && v.paused) { // Best-effort: keep playback running after the user enables sound. v.play().catch(() => undefined); } }, []); return ( <> ); }