From 28093534b8e1daac8b3894088aab5a86037fb3cb Mon Sep 17 00:00:00 2001 From: PhilReact Date: Mon, 23 Jun 2025 17:20:21 +0300 Subject: [PATCH] fix colors --- src/components/VideoPlayer/MobileControls.tsx | 47 +++++++++++++++++-- .../VideoPlayer/SubtitleManager.tsx | 10 +++- src/components/VideoPlayer/VideoControls.tsx | 29 ++++++++++-- .../VideoPlayer/VideoControlsBar.tsx | 4 +- .../VideoPlayer/VideoPlayer-styles.ts | 5 +- src/components/VideoPlayer/VideoPlayer.tsx | 45 +++++++++++++----- src/hooks/useGlobalPipPlayer.tsx | 36 ++++++++++---- 7 files changed, 140 insertions(+), 36 deletions(-) diff --git a/src/components/VideoPlayer/MobileControls.tsx b/src/components/VideoPlayer/MobileControls.tsx index 7760124..a80141c 100644 --- a/src/components/VideoPlayer/MobileControls.tsx +++ b/src/components/VideoPlayer/MobileControls.tsx @@ -22,6 +22,7 @@ interface MobileControlsProps { toggleFullscreen: () => void; setProgressRelative: (val: number) => void; setLocalProgress: (val: number)=> void; + resetHideTimeout: ()=> void } export const MobileControls = ({ showControlsMobile, @@ -35,7 +36,8 @@ export const MobileControls = ({ openPlaybackMenu, toggleFullscreen, setProgressRelative, - setLocalProgress + setLocalProgress, + resetHideTimeout }: MobileControlsProps) => { return ( { e.stopPropagation(); openPlaybackMenu(); }} > - + { e.stopPropagation(); @@ -110,6 +126,7 @@ export const MobileControls = ({ @@ -118,6 +135,9 @@ export const MobileControls = ({ sx={{ opacity: 1, zIndex: 2, + background: 'rgba(0,0,0,0.3)', + borderRadius: '50%', + padding: '10px' }} onClick={(e) => { e.stopPropagation(); @@ -127,6 +147,7 @@ export const MobileControls = ({ @@ -136,6 +157,9 @@ export const MobileControls = ({ sx={{ opacity: 1, zIndex: 2, + background: 'rgba(0,0,0,0.3)', + borderRadius: '50%', + padding: '10px' }} onClick={(e) => { e.stopPropagation(); @@ -145,6 +169,7 @@ export const MobileControls = ({ @@ -153,6 +178,9 @@ export const MobileControls = ({ sx={{ opacity: 1, zIndex: 2, + background: 'rgba(0,0,0,0.3)', + borderRadius: '50%', + padding: '10px' }} onClick={(e) => { e.stopPropagation(); @@ -162,6 +190,7 @@ export const MobileControls = ({ @@ -177,13 +206,19 @@ export const MobileControls = ({ { e.stopPropagation(); toggleFullscreen(); }} > - + diff --git a/src/components/VideoPlayer/SubtitleManager.tsx b/src/components/VideoPlayer/SubtitleManager.tsx index d4643d2..a341f3b 100644 --- a/src/components/VideoPlayer/SubtitleManager.tsx +++ b/src/components/VideoPlayer/SubtitleManager.tsx @@ -74,6 +74,7 @@ export interface SubtitleManagerProps { currentSubTrack: null | string setDrawerOpenSubtitles: (val: boolean)=> void isFromDrawer: boolean + exitFullscreen: ()=> void } export interface Subtitle { language: string | null; @@ -111,7 +112,8 @@ const SubtitleManagerComponent = ({ subtitleBtnRef, currentSubTrack, setDrawerOpenSubtitles, - isFromDrawer = false + isFromDrawer = false, + exitFullscreen }: SubtitleManagerProps) => { const [mode, setMode] = useState(1); const [isOpenPublish, setIsOpenPublish] = useState(false); @@ -315,7 +317,10 @@ const SubtitleManagerComponent = ({ sx={{ marginLeft: "auto", }} - onClick={() => setIsOpenPublish(true)} + onClick={() => { + setIsOpenPublish(true) + + }} > { ); }; -export const ProgressSlider = ({ progress, setLocalProgress, duration, playerRef }: any) => { +export const ProgressSlider = ({ progress, setLocalProgress, duration, playerRef, resetHideTimeout, isVideoPlayerSmall }: any) => { const sliderRef = useRef(null); const [isDragging, setIsDragging] = useState(false); const [sliderValue, setSliderValue] = useState(0); // local slider value const [hoverX, setHoverX] = useState(null); const [thumbnailUrl, setThumbnailUrl] = useState(null); const [showDuration, setShowDuration] = useState(0); + +const showTimeFunc = (val: number, clientX: number) => { + const slider = sliderRef.current; + if (!slider) return; + console.log('time',val, duration) + const percent = val / duration; + const time = Math.min(Math.max(0, percent * duration), duration); + + setHoverX(clientX); + setShowDuration(time); + + resetHideTimeout() + // Optionally debounce processing thumbnails + // debounceTimeoutRef.current = setTimeout(() => { + // debouncedExtract(time, clientX); + // }, THUMBNAIL_DEBOUNCE); +}; const onProgressChange = (e: any, value: number | number[]) => { + const clientX = 'touches' in e ? e.touches[0].clientX : (e as React.MouseEvent).clientX; +if(clientX && resetHideTimeout){ + showTimeFunc(value as number, clientX); + + +} setIsDragging(true); setSliderValue(value as number); }; @@ -82,7 +105,7 @@ const onChangeCommitted = (e: any, value: number | number[]) => { playerRef.current?.currentTime(value as number); setIsDragging(false); setLocalProgress(value) - +handleMouseLeave() }; @@ -148,7 +171,7 @@ const onChangeCommitted = (e: any, value: number | number[]) => { position="relative" sx={{ width: "100%", - padding: "0px 10px", + padding: isVideoPlayerSmall ? "0px" : "0px 10px", }} > - + {/* */} diff --git a/src/components/VideoPlayer/VideoPlayer-styles.ts b/src/components/VideoPlayer/VideoPlayer-styles.ts index 53d3f3f..6233f72 100644 --- a/src/components/VideoPlayer/VideoPlayer-styles.ts +++ b/src/components/VideoPlayer/VideoPlayer-styles.ts @@ -32,10 +32,7 @@ export const VideoElement = styled("video")(({ theme }) => ({ }, "&::-webkit-media-controls": { display: "none !important", - }, - "&:fullscreen": { - paddingBottom: '50px', - }, + } })); //1075 x 604 diff --git a/src/components/VideoPlayer/VideoPlayer.tsx b/src/components/VideoPlayer/VideoPlayer.tsx index 29cdac3..882dbc5 100644 --- a/src/components/VideoPlayer/VideoPlayer.tsx +++ b/src/components/VideoPlayer/VideoPlayer.tsx @@ -272,6 +272,8 @@ export const VideoPlayer = ({ }, [isFullscreen]); const toggleFullscreen = useCallback(() => { + setShowControls(false) + setShowControlsMobile(false) isFullscreen ? exitFullscreen() : enterFullscreen(); }, [isFullscreen]); @@ -313,6 +315,7 @@ export const VideoPlayer = ({ const openSubtitleManager = useCallback(() => { if (isVideoPlayerSmall) { setDrawerOpenSubtitles(true); + return } setIsOpenSubtitleManage(true); }, [isVideoPlayerSmall]); @@ -378,11 +381,11 @@ export const VideoPlayer = ({ const videoStylesContainer = useMemo(() => { return { - cursor: showControls ? "auto" : "none", + cursor: "auto", // aspectRatio: "16 / 9", ...videoStyles?.videoContainer, }; - }, [showControls]); + }, [showControls, isVideoPlayerSmall]); const videoStylesVideo = useMemo(() => { return { @@ -460,7 +463,7 @@ export const VideoPlayer = ({ const hideTimeout = useRef(null); const resetHideTimer = () => { - if (isTouchDevice) return; + if (isVideoPlayerSmall) return; setShowControls(true); if (hideTimeout.current) clearTimeout(hideTimeout.current); hideTimeout.current = setTimeout(() => { @@ -469,7 +472,8 @@ export const VideoPlayer = ({ }; const handleMouseMove = () => { - if (isTouchDevice) return; + if (isVideoPlayerSmall) return; + console.log('going 222') resetHideTimer(); }; @@ -486,12 +490,12 @@ export const VideoPlayer = ({ }, [isVideoPlayerSmall]); useEffect(() => { - if (isTouchDevice) return; + if (isVideoPlayerSmall) return; resetHideTimer(); // initial show return () => { if (hideTimeout.current) clearTimeout(hideTimeout.current); }; - }, []); + }, [isVideoPlayerSmall]); const previousSubtitleUrlRef = useRef(null); @@ -816,7 +820,16 @@ export const VideoPlayer = ({ }; }, []); - console.log("showControlsMobile", showControlsMobile); + const handleClickVideoElement = useCallback(()=> { + if(isVideoPlayerSmall){ + resetHideTimeout() + return + } + console.log('sup') + togglePlay() + }, [isVideoPlayerSmall, togglePlay]) + + console.log("showControlsMobile", isVideoPlayerSmall); return ( <> @@ -845,7 +858,7 @@ export const VideoPlayer = ({ poster={startPlay ? "" : poster} onTimeUpdate={updateProgress} autoPlay={autoPlay} - onClick={togglePlay} + onClick={handleClickVideoElement} onEnded={handleEnded} onCanPlay={handleCanPlay} preload="metadata" @@ -855,15 +868,18 @@ export const VideoPlayer = ({ onVolumeChange={onVolumeChangeHandler} controls={false} /> - + )} + - {isReady && !showControlsMobile && ( + {isReady && showControls && ( )} - {showControlsMobile && ( + {showControlsMobile && isReady && ( )} setDrawerOpenSubtitles(false)}> @@ -969,7 +988,7 @@ export const VideoPlayer = ({ { - + {location && ( { e.stopPropagation() @@ -374,7 +382,9 @@ useEffect(() => { } }} > - + )} {playing && ( @@ -386,11 +396,16 @@ useEffect(() => { transform: "translate(-50%, -50%)", opacity: 1, zIndex: 2, + background: 'rgba(0,0,0,0.3)', + borderRadius: '50%', + padding: '5px' }} onClick={stopPlay} onTouchStart={stopPlay} > - + )} {!playing && ( @@ -402,11 +417,16 @@ useEffect(() => { left: "50%", transform: "translate(-50%, -50%)", zIndex: 2, + background: 'rgba(0,0,0,0.3)', + borderRadius: '50%', + padding: '5px' }} onClick={startPlay} onTouchStart={startPlay} > - + )}