diff --git a/client/src/components/video-card.tsx b/client/src/components/video-card.tsx index b846489..a28f437 100644 --- a/client/src/components/video-card.tsx +++ b/client/src/components/video-card.tsx @@ -46,7 +46,11 @@ function formatDate(date: Date | string): string { export default function VideoCard({ video, onClick, className = "", hideOverlay = false }: VideoCardProps) { const [isHovered, setIsHovered] = useState(false); const [showPreview, setShowPreview] = useState(false); - const [isMuted, setIsMuted] = useState(true); + const [isMuted, setIsMuted] = useState(() => { + // Check localStorage for user's audio preference, default to muted + const savedMuteState = localStorage.getItem('videoPreviewMuted'); + return savedMuteState === null ? true : savedMuteState === 'true'; + }); const hoverTimeoutRef = useRef(); const videoRef = useRef(null); const hlsRef = useRef(null); @@ -198,9 +202,14 @@ export default function VideoCard({ video, onClick, className = "", hideOverlay onClick={(e) => { e.preventDefault(); e.stopPropagation(); - setIsMuted(!isMuted); + const newMutedState = !isMuted; + setIsMuted(newMutedState); + + // Save preference to localStorage for all future previews + localStorage.setItem('videoPreviewMuted', newMutedState.toString()); + if (videoRef.current) { - videoRef.current.muted = !isMuted; + videoRef.current.muted = newMutedState; } }} className="absolute top-2 right-2 z-20 bg-black/50 hover:bg-black/70 text-white border-none p-2 rounded-full transition-all duration-200 opacity-75 hover:opacity-100"