From ea6c28a5de8ab50e9d9e7ceaea9b30b022b8c4b7 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Sat, 27 Nov 2021 17:41:25 +0100 Subject: [PATCH] Video: Fix auto-pausing on iOS --- .../middle/message/hooks/useVideoAutoPause.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/components/middle/message/hooks/useVideoAutoPause.ts b/src/components/middle/message/hooks/useVideoAutoPause.ts index 91d3fb02..00783501 100644 --- a/src/components/middle/message/hooks/useVideoAutoPause.ts +++ b/src/components/middle/message/hooks/useVideoAutoPause.ts @@ -15,11 +15,11 @@ export default function useVideoAutoPause(playerRef: { current: HTMLVideoElement return; } - if (!wasPlaying.current) { - wasPlaying.current = !playerRef.current.paused; - } + wasPlaying.current = !playerRef.current.paused; - playerRef.current.pause(); + if (wasPlaying.current) { + playerRef.current.pause(); + } }, [playerRef]); const unfreezePlaying = useCallback(() => { @@ -30,8 +30,6 @@ export default function useVideoAutoPause(playerRef: { current: HTMLVideoElement ) { safePlay(playerRef.current); } - - wasPlaying.current = false; }, [playerRef]); const unfreezePlayingOnRaf = useCallback(() => {