mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-23 09:16:53 +00:00
fix(webui): auto-hide fullscreen controls on idle regardless of play state
The fullscreen control bar only auto-hid while playing, and a separate effect force-showed it whenever paused, so it stayed visible permanently when paused in fullscreen. Now in fullscreen the bar shows on cursor move and hides after the cursor is idle (~2s) whether playing or paused; windowed mode keeps the bar always visible.
This commit is contained in:
@@ -348,22 +348,22 @@ const VideoPlayer: React.FC<VideoPlayerProps> = ({
|
||||
clearTimeout(controlsTimeoutRef.current)
|
||||
}
|
||||
|
||||
// Only set auto-hide timer if we are in fullscreen and playing
|
||||
// If paused, controls should remain visible so user can see what to do
|
||||
if (state.isFullScreen && state.isPlaying) {
|
||||
// In fullscreen, hide the controls after the cursor stays idle, regardless
|
||||
// of play/pause (YouTube-style). In windowed mode controls stay visible.
|
||||
if (state.isFullScreen) {
|
||||
controlsTimeoutRef.current = setTimeout(() => {
|
||||
setIsControlsVisible(false)
|
||||
}, 2000)
|
||||
}
|
||||
}, [state.isFullScreen, state.isPlaying])
|
||||
}, [state.isFullScreen])
|
||||
|
||||
const handleMouseLeave = useCallback(() => {
|
||||
// If we leave the player area in fullscreen, hide controls (optional preference, usually good)
|
||||
if (state.isFullScreen && state.isPlaying) {
|
||||
// If the cursor leaves the player while fullscreen, hide the controls.
|
||||
if (state.isFullScreen) {
|
||||
if (controlsTimeoutRef.current) clearTimeout(controlsTimeoutRef.current)
|
||||
setIsControlsVisible(false)
|
||||
}
|
||||
}, [state.isFullScreen, state.isPlaying])
|
||||
}, [state.isFullScreen])
|
||||
|
||||
// Clean up timeout on unmount or state change
|
||||
useEffect(() => {
|
||||
@@ -372,13 +372,13 @@ const VideoPlayer: React.FC<VideoPlayerProps> = ({
|
||||
}
|
||||
}, [])
|
||||
|
||||
// Ensure controls are visible when pausing or entering fullscreen initially
|
||||
// Windowed mode: controls are always visible. Fullscreen: show now and let
|
||||
// the idle timer hide them (re-runs on play/pause so pausing re-reveals them).
|
||||
useEffect(() => {
|
||||
if (!state.isPlaying) {
|
||||
if (!state.isFullScreen) {
|
||||
setIsControlsVisible(true)
|
||||
if (controlsTimeoutRef.current) clearTimeout(controlsTimeoutRef.current)
|
||||
} else {
|
||||
// If we just started playing (or re-entered playing state), trigger the timer logic
|
||||
handleMouseMove()
|
||||
}
|
||||
}, [state.isPlaying, state.isFullScreen, handleMouseMove])
|
||||
|
||||
Reference in New Issue
Block a user