fixed slider behaviour

This commit is contained in:
tapframe 2025-09-11 13:26:49 +05:30
parent b516fe74d3
commit dce3e5c200
2 changed files with 53 additions and 0 deletions

View file

@ -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

View file

@ -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) => {