From ae3fea9c82664319661ffae310b978a0ff2b479d Mon Sep 17 00:00:00 2001 From: sebastjanartic <45803536-sebastjanartic@users.noreply.replit.com> Date: Thu, 7 Aug 2025 11:00:07 +0000 Subject: [PATCH] Enhance video player with progress sharing and time display Update the video player to show the current playback progress with a hover-over time tooltip, a blue progress bar, and a share button with social media links. Replit-Commit-Author: Agent Replit-Commit-Session-Id: d7424866-83d1-4486-a212-ac12b4c7becf Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/8cc42625-c1f5-4e43-99bd-77f2c4dedee2/d7424866-83d1-4486-a212-ac12b4c7becf/J2c5fwX --- client/src/components/video-modal.tsx | 175 ++++++++++++++------------ 1 file changed, 92 insertions(+), 83 deletions(-) diff --git a/client/src/components/video-modal.tsx b/client/src/components/video-modal.tsx index c573266..8d2c896 100644 --- a/client/src/components/video-modal.tsx +++ b/client/src/components/video-modal.tsx @@ -66,6 +66,7 @@ export default function VideoModal({ video, isOpen, onClose }: VideoModalProps) const [currentTime, setCurrentTime] = useState(0); const [duration, setDuration] = useState(0); const [volume, setVolume] = useState(1); + const [hoverTime, setHoverTime] = useState(-1); useEffect(() => { const handleEscape = (e: KeyboardEvent) => { @@ -364,6 +365,15 @@ export default function VideoModal({ video, isOpen, onClose }: VideoModalProps) } }; + const handleProgressHover = (e: React.MouseEvent) => { + if (duration > 0) { + const rect = e.currentTarget.getBoundingClientRect(); + const hoverX = e.clientX - rect.left; + const time = (hoverX / rect.width) * duration; + setHoverTime(Math.max(0, Math.min(duration, time))); + } + }; + const handleVolumeChange = (e: React.ChangeEvent) => { const newVolume = parseFloat(e.target.value); if (videoRef.current) { @@ -475,14 +485,26 @@ export default function VideoModal({ video, isOpen, onClose }: VideoModalProps) {/* Progress Bar */}
setHoverTime(-1)} data-testid="progress-bar" >
0 ? (currentTime / duration) * 100 : 0}%` }} /> + + {/* Time tooltip on hover */} + {hoverTime >= 0 && ( +
+ {formatTime(hoverTime)} +
+ )}
@@ -526,6 +548,73 @@ export default function VideoModal({ video, isOpen, onClose }: VideoModalProps) {formatTime(currentTime)} / {formatTime(duration)}
+ {/* Share Button */} +
+ + + {/* Share Menu */} + {showShareMenu && ( +
+
+
+ Share Video +
+ +
{ + window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(getShareUrl())}`, '_blank', 'width=600,height=400'); + setShowShareMenu(false); + }} + className="flex items-center gap-2 p-2 w-full hover:bg-gray-100 dark:hover:bg-gray-700 rounded cursor-pointer" + > + + Facebook +
+ +
{ + window.open(`https://twitter.com/intent/tweet?url=${encodeURIComponent(getShareUrl())}&text=${encodeURIComponent(`Watch "${video.title}" on g4.video`)}`, '_blank', 'width=600,height=400'); + setShowShareMenu(false); + }} + className="flex items-center gap-2 p-2 w-full hover:bg-gray-100 dark:hover:bg-gray-700 rounded cursor-pointer" + > + + Twitter +
+ +
{ + window.open(`https://wa.me/?text=${encodeURIComponent(`Watch "${video.title}" on g4.video: ${getShareUrl()}`)}`, '_blank'); + setShowShareMenu(false); + }} + className="flex items-center gap-2 p-2 w-full hover:bg-gray-100 dark:hover:bg-gray-700 rounded cursor-pointer" + > + + WhatsApp +
+ + +
+
+ )} +
+ {/* Fullscreen Button */} - - {/* Share Menu - moved to bottom */} - {showShareMenu && ( -
-
-
- Share Video - {videoThumbnail && ( -
- Video preview - Preview image for sharing -
- )} -
- -
{ - console.log('Facebook share clicked:', getShareUrl()); - window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(getShareUrl())}`, '_blank', 'width=600,height=400'); - }} - className="flex items-center gap-2 p-2 w-full hover:bg-gray-100 dark:hover:bg-gray-700 rounded cursor-pointer" - > - - Facebook -
- -
{ - console.log('Twitter share clicked:', getShareUrl()); - window.open(`https://twitter.com/intent/tweet?url=${encodeURIComponent(getShareUrl())}&text=${encodeURIComponent(`Watch "${video.title}" on g4.video`)}`, '_blank', 'width=600,height=400'); - }} - className="flex items-center gap-2 p-2 w-full hover:bg-gray-100 dark:hover:bg-gray-700 rounded cursor-pointer" - > - - Twitter -
- -
{ - console.log('WhatsApp share clicked:', getShareUrl()); - window.open(`https://wa.me/?text=${encodeURIComponent(`Watch "${video.title}" on g4.video: ${getShareUrl()}`)}`, '_blank'); - }} - className="flex items-center gap-2 p-2 w-full hover:bg-gray-100 dark:hover:bg-gray-700 rounded cursor-pointer" - > - - WhatsApp -
- - -
-
- )} - - - )} + {/* Video info - only show when not playing or when controls are visible */}