fix(media): ensure video plays continuously all the time on all devices without requiring hover
This commit is contained in:
@@ -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(() => {
|
||||
if (item.mediaType === 'video' && videoRef.current) {
|
||||
if (isHovered) {
|
||||
videoRef.current.play().catch(() => {});
|
||||
} else {
|
||||
videoRef.current.pause();
|
||||
videoRef.current.currentTime = 0;
|
||||
}
|
||||
const video = videoRef.current;
|
||||
video.muted = true;
|
||||
video.defaultMuted = true;
|
||||
video.playsInline = true;
|
||||
video.play().catch(() => {});
|
||||
}
|
||||
}, [isHovered, item.mediaType]);
|
||||
}, [item.mediaType]);
|
||||
|
||||
// When unhovered, reset slider smoothly to 50%
|
||||
useEffect(() => {
|
||||
@@ -439,9 +438,11 @@ function ToolWindowMedia({ item, isHovered }: { item: ToolMediaItem; isHovered:
|
||||
ref={videoRef}
|
||||
src={item.videoUrl}
|
||||
poster={item.poster}
|
||||
autoPlay
|
||||
muted
|
||||
loop
|
||||
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]"
|
||||
/>
|
||||
{/* GPU-composited overlay (opacity only) */}
|
||||
|
||||
Reference in New Issue
Block a user