Skip to content

Commit 46a1934

Browse files
committed
Mute video when out of view
1 parent 9081824 commit 46a1934

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

dotcom-rendering/src/components/LoopVideo.importable.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export const LoopVideo = ({
9595
if (isNoLongerInView) {
9696
setPlayerState('PAUSED_BY_INTERSECTION_OBSERVER');
9797
void vidRef.current.pause();
98+
setIsMuted(true);
9899
}
99100

100101
// If a user action paused the video, they have indicated
@@ -104,6 +105,7 @@ export const LoopVideo = ({
104105
playerState === 'PAUSED_BY_INTERSECTION_OBSERVER' && isInView;
105106
if (isBackInView) {
106107
setPlayerState('PLAYING');
108+
107109
void vidRef.current.play();
108110
}
109111
}, [isInView, hasBeenInView, playerState]);

0 commit comments

Comments
 (0)