diff --git a/src/components/player/AndroidVideoPlayer.tsx b/src/components/player/AndroidVideoPlayer.tsx index 2e754660..3ee2f386 100644 --- a/src/components/player/AndroidVideoPlayer.tsx +++ b/src/components/player/AndroidVideoPlayer.tsx @@ -234,6 +234,33 @@ const AndroidVideoPlayer: React.FC = () => { }).start(); }, [playerState.showControls]); + // Auto-hide controls after 3 seconds of inactivity + useEffect(() => { + // Clear any existing timeout + if (controlsTimeout.current) { + clearTimeout(controlsTimeout.current); + controlsTimeout.current = null; + } + + // Only set timeout if controls are visible and video is playing + if (playerState.showControls && !playerState.paused) { + controlsTimeout.current = setTimeout(() => { + // Don't hide if user is dragging the seek bar + if (!playerState.isDragging.current) { + playerState.setShowControls(false); + } + }, 2000); // 2 seconds delay + } + + // Cleanup on unmount or when dependencies change + return () => { + if (controlsTimeout.current) { + clearTimeout(controlsTimeout.current); + controlsTimeout.current = null; + } + }; + }, [playerState.showControls, playerState.paused, playerState.isDragging]); + useEffect(() => { openingAnimation.startOpeningAnimation(); }, []); @@ -459,7 +486,10 @@ const AndroidVideoPlayer: React.FC = () => { }, [playerState.currentTime, useCustomSubtitles, customSubtitles]); const toggleControls = useCallback(() => { - playerState.setShowControls(prev => !prev); + playerState.setShowControls(prev => { + // If we're showing controls, the useEffect will handle the auto-hide timer + return !prev; + }); }, []); const hideControls = useCallback(() => { @@ -881,6 +911,7 @@ const AndroidVideoPlayer: React.FC = () => { visible={speedControl.showSpeedActivatedOverlay} opacity={speedControl.speedActivatedOverlayOpacity} speed={speedControl.holdToSpeedValue} + screenDimensions={playerState.screenDimensions} /> = ({ visible, opacity, - speed + speed, + screenDimensions }) => { - if (!visible) return null; + // Safety check to prevent the 'height' of undefined error + if (!visible || !screenDimensions) return null; return ( - - - {speed}x Speed + + + + {speed}x + ); diff --git a/src/components/player/utils/playerStyles.ts b/src/components/player/utils/playerStyles.ts index a470e67b..a4418e84 100644 --- a/src/components/player/utils/playerStyles.ts +++ b/src/components/player/utils/playerStyles.ts @@ -274,8 +274,8 @@ export const styles = StyleSheet.create({ backgroundColor: 'rgba(0, 0, 0, 0.75)', borderRadius: 24, paddingVertical: 8, - paddingHorizontal: 14, - gap: 8, + paddingHorizontal: 8, + gap: 4, }, iconWrapper: { width: 28, @@ -289,7 +289,7 @@ export const styles = StyleSheet.create({ color: '#FFFFFF', fontSize: 16, fontWeight: '600', - minWidth: 48, + minWidth: 38, textAlign: 'center', }, @@ -1218,4 +1218,4 @@ export const styles = StyleSheet.create({ fontSize: skipTextFont, marginTop: 2, }, -}); \ No newline at end of file +});