Skip to content

Commit 22d91b7

Browse files
committed
Remove showPlayIcon useEffect
1 parent e8d456c commit 22d91b7

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

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

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ export const SelfHostedVideo = ({
177177
const [isPlayable, setIsPlayable] = useState(false);
178178
const [isMuted, setIsMuted] = useState(true);
179179
const [hasAudio, setHasAudio] = useState(true);
180-
const [showPlayIcon, setShowPlayIcon] = useState(false);
181180
const [preloadPartialData, setPreloadPartialData] = useState(false);
182181
const [showPosterImage, setShowPosterImage] = useState<boolean>(false);
183182
const [currentTime, setCurrentTime] = useState(0);
@@ -497,19 +496,6 @@ export const SelfHostedVideo = ({
497496
atomId,
498497
]);
499498

500-
/**
501-
* Show the play icon when the video is not playing, except for when it is scrolled
502-
* out of view. In this case, the intersection observer will resume playback and
503-
* having a play icon would falsely indicate a user action is required to resume playback.
504-
*/
505-
useEffect(() => {
506-
const shouldShowPlayIcon =
507-
playerState === 'PAUSED_BY_USER' ||
508-
playerState === 'PAUSED_BY_BROWSER' ||
509-
(playerState === 'NOT_STARTED' && !isAutoplayAllowed);
510-
setShowPlayIcon(shouldShowPlayIcon);
511-
}, [playerState, isAutoplayAllowed]);
512-
513499
/**
514500
* Show a poster image if a video does NOT play automatically. Otherwise, we do not need
515501
* to download the image as the video will be autoplayed and the image will not be seen.
@@ -685,6 +671,16 @@ export const SelfHostedVideo = ({
685671
}
686672
};
687673

674+
/**
675+
* Show the play icon when the video is not playing, except for when it is scrolled
676+
* out of view. In this case, the intersection observer will resume playback and
677+
* having a play icon would falsely indicate a user action is required to resume playback.
678+
*/
679+
const showPlayIcon =
680+
playerState === 'PAUSED_BY_USER' ||
681+
playerState === 'PAUSED_BY_BROWSER' ||
682+
(playerState === 'NOT_STARTED' && !isAutoplayAllowed);
683+
688684
const aspectRatio = width / height;
689685

690686
const AudioIcon = isMuted ? SvgAudioMute : SvgAudio;

0 commit comments

Comments
 (0)