From 60b74f7ab82328de5ec9cea7c40e1db705d40d6b Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Thu, 5 Sep 2024 15:56:10 +0100 Subject: [Video] Disable autoplay option (preview + web player) (#5167) * rename setting * preview (web) * preview (native) * improve autoplay disabled behaviour on web --- .../util/post-embeds/VideoEmbedInner/VideoWebControls.tsx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/view/com/util/post-embeds/VideoEmbedInner/VideoWebControls.tsx') diff --git a/src/view/com/util/post-embeds/VideoEmbedInner/VideoWebControls.tsx b/src/view/com/util/post-embeds/VideoEmbedInner/VideoWebControls.tsx index d9b99ef3a..82c0ab7a6 100644 --- a/src/view/com/util/post-embeds/VideoEmbedInner/VideoWebControls.tsx +++ b/src/view/com/util/post-embeds/VideoEmbedInner/VideoWebControls.tsx @@ -111,9 +111,9 @@ export function Controls({ // autoplay/pause based on visibility const autoplayDisabled = useAutoplayDisabled() useEffect(() => { - if (active && !autoplayDisabled) { + if (active) { if (onScreen) { - play() + if (!autoplayDisabled) play() } else { pause() } @@ -151,10 +151,11 @@ export function Controls({ const onPressEmptySpace = useCallback(() => { if (!focused) { drawFocus() + if (autoplayDisabled) play() } else { togglePlayPause() } - }, [togglePlayPause, drawFocus, focused]) + }, [togglePlayPause, drawFocus, focused, autoplayDisabled, play]) const onPressPlayPause = useCallback(() => { drawFocus() @@ -240,7 +241,8 @@ export function Controls({ }, []) const showControls = - (focused && !playing) || (interactingViaKeypress ? hasFocus : hovered) + ((focused || autoplayDisabled) && !playing) || + (interactingViaKeypress ? hasFocus : hovered) return (
{!showControls && !focused && duration > 0 && ( -- cgit 1.4.1