fix(media): ensure video plays continuously all the time on all devices without requiring hover

This commit is contained in:
2026-11-05 13:44:30 +05:30
parent d2e43a6da0
commit a0083e5219
@@ -288,17 +288,16 @@ function ToolWindowMedia({ item, isHovered }: { item: ToolMediaItem; isHovered:
} }
}, []); }, []);
// Video Autoplay Muted Loop only on Hover (No zoom, no scale) // Continuous Autoplay Muted Loop (Plays all the time on phones and desktop without requiring hover)
useEffect(() => { useEffect(() => {
if (item.mediaType === 'video' && videoRef.current) { if (item.mediaType === 'video' && videoRef.current) {
if (isHovered) { const video = videoRef.current;
videoRef.current.play().catch(() => {}); video.muted = true;
} else { video.defaultMuted = true;
videoRef.current.pause(); video.playsInline = true;
videoRef.current.currentTime = 0; video.play().catch(() => {});
} }
} }, [item.mediaType]);
}, [isHovered, item.mediaType]);
// When unhovered, reset slider smoothly to 50% // When unhovered, reset slider smoothly to 50%
useEffect(() => { useEffect(() => {
@@ -439,9 +438,11 @@ function ToolWindowMedia({ item, isHovered }: { item: ToolMediaItem; isHovered:
ref={videoRef} ref={videoRef}
src={item.videoUrl} src={item.videoUrl}
poster={item.poster} poster={item.poster}
autoPlay
muted muted
loop loop
playsInline playsInline
preload="auto"
className="absolute inset-y-0 left-1/2 -translate-x-1/2 h-full w-[680px] max-w-none object-cover pointer-events-none transform-gpu will-change-transform [backface-visibility:hidden]" className="absolute inset-y-0 left-1/2 -translate-x-1/2 h-full w-[680px] max-w-none object-cover pointer-events-none transform-gpu will-change-transform [backface-visibility:hidden]"
/> />
{/* GPU-composited overlay (opacity only) */} {/* GPU-composited overlay (opacity only) */}