/* ═══════════════════════════════════════════════════════════════ VIDEO PLAYER: click to play A still with a play button; pressing it swaps in the player, so a page loads no iframes until someone asks for one. Used by the featured cards and the video content block. The still is the caller's image, else YouTube's own thumbnail (its 16:9 one, falling back to the 4:3 one cropped). Any still that fails, or comes back as YouTube's gray "no thumbnail" placeholder, gives way to the next; with none left it's a flat teal panel with the play button always showing. The play button shows on hover or keyboard focus, and always on a touch screen, which can't hover. Small rounded corners, as the only rounded thing besides buttons and dots. A link that embeds.ts can't turn into a player (not https, or not a host it knows how to frame) still goes somewhere: the still becomes a link to it. Reading mode (readingMode.ts) gets a link to the video (an uploaded file's own address), named by its title. ═══════════════════════════════════════════════════════════════ */ import { Play } from '@phosphor-icons/react' import { useState, type SyntheticEvent } from 'react' import HomeLink from '../pages/sections/home/HomeLink.tsx' import { playingSource, videoSource, videoThumbnails } from '../lib/embeds.ts' import { BRAND } from '../lib/color.ts' import { focusOnMount } from '../lib/focus.ts' import { useReadingMode } from '../lib/readingMode.ts' export default function VideoPlayer({ url, still, title, className = '', }: { url?: string | null /** An image URL to show before it plays. */ still?: string | null title?: string | null className?: string }) { const [playing, setPlaying] = useState(false) const [skipped, setSkipped] = useState(0) const source = videoSource(url) const reading = useReadingMode() if (reading) { const href = source?.kind === 'file' ? source.src : url return href ? (

{title || 'Watch the video'}

) : null } if (playing && source) { const live = playingSource(source) return live.kind === 'file' ? (