From dce3e5c2007f71398ceef7df03abb3cebf474c1f Mon Sep 17 00:00:00 2001 From: tapframe Date: Thu, 11 Sep 2025 13:26:49 +0530 Subject: [PATCH] fixed slider behaviour --- src/components/player/AndroidVideoPlayer.tsx | 27 ++++++++++++++++++++ src/components/player/VideoPlayer.tsx | 26 +++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/src/components/player/AndroidVideoPlayer.tsx b/src/components/player/AndroidVideoPlayer.tsx index f8e9b7d9..66209a01 100644 --- a/src/components/player/AndroidVideoPlayer.tsx +++ b/src/components/player/AndroidVideoPlayer.tsx @@ -291,6 +291,10 @@ const AndroidVideoPlayer: React.FC = () => { const END_EPSILON = 0.3; const hideControls = () => { + // Do not hide while user is interacting with the slider + if (isDragging) { + return; + } Animated.timing(fadeAnim, { toValue: 0, duration: 300, @@ -622,6 +626,12 @@ const AndroidVideoPlayer: React.FC = () => { const handleSlidingStart = () => { setIsDragging(true); + // Keep controls visible while dragging and cancel any hide timeout + if (!showControls) setShowControls(true); + if (controlsTimeout.current) { + clearTimeout(controlsTimeout.current); + controlsTimeout.current = null; + } // On iOS, pause during drag for more reliable seeks if (Platform.OS === 'ios') { wasPlayingBeforeDragRef.current = !paused; @@ -637,7 +647,24 @@ const AndroidVideoPlayer: React.FC = () => { seekToTime(seekTime); pendingSeekValue.current = null; } + // Restart auto-hide timer after interaction finishes + if (controlsTimeout.current) { + clearTimeout(controlsTimeout.current); + } + // Ensure controls are visible, then schedule auto-hide + if (!showControls) setShowControls(true); + controlsTimeout.current = setTimeout(hideControls, 5000); }; + + // Ensure auto-hide resumes after drag ends + useEffect(() => { + if (!isDragging && showControls) { + if (controlsTimeout.current) { + clearTimeout(controlsTimeout.current); + } + controlsTimeout.current = setTimeout(hideControls, 5000); + } + }, [isDragging, showControls]); // Removed processProgressTouch - no longer needed with React Native Community Slider diff --git a/src/components/player/VideoPlayer.tsx b/src/components/player/VideoPlayer.tsx index 11750f46..1af3bd50 100644 --- a/src/components/player/VideoPlayer.tsx +++ b/src/components/player/VideoPlayer.tsx @@ -315,6 +315,10 @@ const VideoPlayer: React.FC = () => { const END_EPSILON = 0.3; const hideControls = () => { + // Do not hide while user is interacting with the slider + if (isDragging) { + return; + } Animated.timing(fadeAnim, { toValue: 0, duration: 300, @@ -660,6 +664,12 @@ const VideoPlayer: React.FC = () => { const handleSlidingStart = () => { setIsDragging(true); + // Keep controls visible while dragging and cancel any hide timeout + if (!showControls) setShowControls(true); + if (controlsTimeout.current) { + clearTimeout(controlsTimeout.current); + controlsTimeout.current = null; + } }; const handleSlidingComplete = (value: number) => { @@ -669,8 +679,24 @@ const VideoPlayer: React.FC = () => { seekToTime(seekTime); pendingSeekValue.current = null; } + // Restart auto-hide timer after interaction finishes + if (controlsTimeout.current) { + clearTimeout(controlsTimeout.current); + } + if (!showControls) setShowControls(true); + controlsTimeout.current = setTimeout(hideControls, 5000); }; + // Ensure auto-hide resumes after drag ends + useEffect(() => { + if (!isDragging && showControls) { + if (controlsTimeout.current) { + clearTimeout(controlsTimeout.current); + } + controlsTimeout.current = setTimeout(hideControls, 5000); + } + }, [isDragging, showControls]); + // Removed processProgressTouch - no longer needed with React Native Community Slider const handleProgress = (event: any) => {