feat: update single tap behavior in MobileVideoPlayer to improve control visibility and play/pause functionality

This commit is contained in:
kuekhaoyang
2025-11-18 13:22:21 +08:00
parent bda49259f1
commit 25f0722d82
+27 -13
View File
@@ -100,19 +100,33 @@ export function MobileVideoPlayer({
onSkipContinueRight: () => skipVideo(10, 'right'),
isSkipModeActive: showSkipIndicator,
onSingleTap: () => {
// Single tap toggles play/pause immediately
togglePlay();
// Show controls
setShowControls(true);
// If playing, set timeout to hide controls
// If paused, keep controls visible
if (controlsTimeoutRef.current) {
clearTimeout(controlsTimeoutRef.current);
}
if (isPlaying) {
controlsTimeoutRef.current = setTimeout(() => {
setShowControls(false);
}, 3000);
// Single tap behavior:
// - If controls are hidden, show them (don't toggle play/pause)
// - If controls are visible, toggle play/pause
if (!showControls) {
// Just show controls, don't toggle play state
setShowControls(true);
// Set timeout to hide controls if playing
if (controlsTimeoutRef.current) {
clearTimeout(controlsTimeoutRef.current);
}
if (isPlaying) {
controlsTimeoutRef.current = setTimeout(() => {
setShowControls(false);
}, 3000);
}
} else {
// Controls are visible, now toggle play/pause
togglePlay();
// Reset hide timer
if (controlsTimeoutRef.current) {
clearTimeout(controlsTimeoutRef.current);
}
if (isPlaying) {
controlsTimeoutRef.current = setTimeout(() => {
setShowControls(false);
}, 3000);
}
}
},
});