Skip to content

Commit

Permalink
fix: hidden video playing automatically on iphone (#1514)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieujacq authored Oct 27, 2023
1 parent f7ae27b commit d5437ee
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ export const VideoPlayer = ({ videoSrc }: VideoPlayerProps): JSX.Element => {
if (!videoElement) {
return;
}

const videoRect = videoElement.getBoundingClientRect();
const isVideoVisible =
videoRect.top >= 0 && videoRect.bottom <= window.innerHeight;
videoRect.top >= 0 &&
videoRect.bottom <= window.innerHeight &&
videoElement.checkVisibility();

if (isVideoVisible && videoElement.paused) {
void videoElement.play();
Expand Down

0 comments on commit d5437ee

Please sign in to comment.