From 366cf3e99fd2ba3d63e6ce1d5748e4986904422d Mon Sep 17 00:00:00 2001 From: Pas <74743263+Pasithea0@users.noreply.github.com> Date: Sun, 1 Jun 2025 23:33:41 -0600 Subject: [PATCH] move trailer to new overlay --- src/components/overlays/DetailsModal.tsx | 223 ++++++++--------------- 1 file changed, 74 insertions(+), 149 deletions(-) diff --git a/src/components/overlays/DetailsModal.tsx b/src/components/overlays/DetailsModal.tsx index 8bf542d9..0b9ee010 100644 --- a/src/components/overlays/DetailsModal.tsx +++ b/src/components/overlays/DetailsModal.tsx @@ -126,6 +126,44 @@ interface DetailsContent { logoUrl?: string; } +function TrailerOverlay({ + trailerUrl, + onClose, +}: { + trailerUrl: string; + onClose: () => void; +}) { + return ( +
+
e.stopPropagation()} + > + + + {/* Close Button */} + +
+
+ ); +} + function DetailsContent({ data, minimal = false, @@ -136,8 +174,7 @@ function DetailsContent({ const [imdbData, setImdbData] = useState(null); const [rtData, setRtData] = useState(null); const [, setIsLoadingImdb] = useState(false); - const [isMuted, setIsMuted] = useState(true); - const [isPaused, setIsPaused] = useState(false); + const [showTrailer, setShowTrailer] = useState(false); const [showEpisodeMenu, setShowEpisodeMenu] = useState(false); const [customSeason, setCustomSeason] = useState(""); const [customEpisode, setCustomEpisode] = useState(""); @@ -177,64 +214,6 @@ function DetailsContent({ } }, [showProgress]); - const toggleMute = () => { - if (videoRef.current) { - const newMuted = !videoRef.current.muted; - videoRef.current.muted = newMuted; - setIsMuted(newMuted); - setShowVolumeBar(!newMuted); - } - }; - - const handleVolumeChange = (e: React.ChangeEvent) => { - const newVolume = parseFloat(e.target.value); - setVolume(newVolume); - if (videoRef.current) { - videoRef.current.volume = newVolume; - if (newVolume === 0) { - videoRef.current.muted = true; - setIsMuted(true); - setShowVolumeBar(false); - } else { - videoRef.current.muted = false; - setIsMuted(false); - setShowVolumeBar(true); - } - } - }; - - // Hide volume bar after 2 seconds of inactivity - useEffect(() => { - if (!showVolumeBar || isMuted) return; - const timeout = setTimeout(() => setShowVolumeBar(false), 2000); - return () => clearTimeout(timeout); - }, [showVolumeBar, isMuted, volume]); - - // Hide volume bar when clicking outside - useEffect(() => { - if (!showVolumeBar) return; - const handleClick = (e: MouseEvent) => { - const bar = document.getElementById("vertical-volume-bar"); - if (bar && !bar.contains(e.target as Node)) { - setShowVolumeBar(false); - } - }; - document.addEventListener("mousedown", handleClick); - return () => document.removeEventListener("mousedown", handleClick); - }, [showVolumeBar]); - - const togglePlay = () => { - if (videoRef.current) { - if (videoRef.current.paused) { - videoRef.current.play(); - setIsPaused(false); - } else { - videoRef.current.pause(); - setIsPaused(true); - } - } - }; - useEffect(() => { const fetchExternalData = async () => { if (!data.imdbId) return; @@ -451,95 +430,28 @@ function DetailsContent({ )} + {/* Trailer Overlay */} + {showTrailer && imdbData?.trailer_url && ( + setShowTrailer(false)} + /> + )} + {/* Backdrop - Even taller */}
- {imdbData?.trailer_url ? ( -
- -
- - {/* Volume Bar */} - {showVolumeBar && !isMuted && ( -
- -
- )} -
- {isPaused && ( - - )} -
- ) : ( -
- )} +
{/* Content */}
)}
+ {imdbData?.trailer_url && ( + + )} 0 && ( -
+
{data.genres.map((genre, index) => ( 0 && ( -
+
{data.genres.map((genre, index) => (