From 293628541281b502d9582e8ca843e4463bb950dd Mon Sep 17 00:00:00 2001 From: sebastjanartic <45803536-sebastjanartic@users.noreply.replit.com> Date: Wed, 17 Sep 2025 10:09:24 +0000 Subject: [PATCH] Fix video player mute and audio issues on hover previews Resolve an issue where the video player's mute button and audio functionality were not working correctly on video card previews. This commit updates the video player component to properly handle mute/unmute states, ensures audio is present before attempting to play, and improves the user experience by making the mute button more functional and providing localized titles. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 45a1dcfc-f8a2-475a-a6b9-96fbb841dc27 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/60d372ff-2c10-46c7-b01b-10c3435136b0/45a1dcfc-f8a2-475a-a6b9-96fbb841dc27/p9OwK9b --- .replit | 2 +- client/src/components/video-card.tsx | 41 ++++++++++++++++++++++++---- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/.replit b/.replit index 8090e93..10afe05 100644 --- a/.replit +++ b/.replit @@ -16,7 +16,7 @@ localPort = 5000 externalPort = 80 [[ports]] -localPort = 41645 +localPort = 43411 externalPort = 3000 [env] diff --git a/client/src/components/video-card.tsx b/client/src/components/video-card.tsx index f69cd41..768d808 100644 --- a/client/src/components/video-card.tsx +++ b/client/src/components/video-card.tsx @@ -77,7 +77,7 @@ export default function VideoCard({ video, onClick, className = "", hideOverlay }; }, []); - // Load mute preference on component mount + // Load mute preference on component mount - default to muted for previews useEffect(() => { const savedMuteState = localStorage.getItem('videoPreviewMuted'); const shouldBeMuted = savedMuteState === null ? true : savedMuteState === 'true'; @@ -264,7 +264,22 @@ export default function VideoCard({ video, onClick, className = "", hideOverlay } }} onTimeUpdate={(e) => setCurrentTime(e.currentTarget.currentTime)} - onLoadedMetadata={(e) => setDuration(e.currentTarget.duration)} + onLoadedMetadata={(e) => { + setDuration(e.currentTarget.duration); + const video = e.currentTarget; + // Check if video has audio using various browser methods + const hasAudio = + (video as any).mozHasAudio || + Boolean((video as any).webkitAudioDecodedByteCount) || + Boolean((video as any).audioTracks && (video as any).audioTracks.length) || + false; + console.log('🎵 Video metadata loaded:', { + hasAudio, + duration: video.duration, + muted: video.muted, + volume: video.volume + }); + }} onMouseMove={(e) => { if (!videoRef.current || duration === 0) return; const rect = e.currentTarget.getBoundingClientRect(); @@ -276,11 +291,12 @@ export default function VideoCard({ video, onClick, className = "", hideOverlay }} /> - {/* Mute/Unmute button - make it always visible and more prominent */} + {/* Mute/Unmute button - always visible and functional */}