@@ -18,6 +18,7 @@ import {
1818 customSelfHostedVideoPlayAudioEventName ,
1919 customYoutubePlayEventName ,
2020} from '../lib/video' ;
21+ import type { VideoPlayerFormat } from '../types/mainMedia' ;
2122import { CardPicture , type Props as CardPictureProps } from './CardPicture' ;
2223import { useConfig } from './ConfigContext' ;
2324import type {
@@ -33,6 +34,10 @@ const videoContainerStyles = css`
3334 position : relative;
3435` ;
3536
37+ const cinemagraphContainerStyles = css `
38+ pointer-events : none;
39+ ` ;
40+
3641/**
3742 * Dispatches a custom play audio event so that other videos listening
3843 * for this event will be muted.
@@ -116,6 +121,7 @@ type Props = {
116121 uniqueId : string ;
117122 height : number ;
118123 width : number ;
124+ videoStyle : VideoPlayerFormat ;
119125 posterImage : string ;
120126 fallbackImage : CardPictureProps [ 'mainImage' ] ;
121127 fallbackImageSize : CardPictureProps [ 'imageSize' ] ;
@@ -133,6 +139,7 @@ export const SelfHostedVideo = ({
133139 uniqueId,
134140 height,
135141 width,
142+ videoStyle,
136143 posterImage,
137144 fallbackImage,
138145 fallbackImageSize,
@@ -170,6 +177,12 @@ export const SelfHostedVideo = ({
170177
171178 const VISIBILITY_THRESHOLD = 0.5 ;
172179
180+ /**
181+ * All controls on the video are hidden: the video looks like a GIF.
182+ * This includes but may not be limited to: audio icon, play/pause icon, subtitles, progress bar.
183+ */
184+ const isCinemagraph = videoStyle === 'Cinemagraph' ;
185+
173186 const [ isInView , setNode ] = useIsInView ( {
174187 repeat : true ,
175188 threshold : VISIBILITY_THRESHOLD ,
@@ -534,11 +547,15 @@ export const SelfHostedVideo = ({
534547 } ;
535548
536549 const handlePlayPauseClick = ( event : React . SyntheticEvent ) => {
550+ if ( isCinemagraph ) return ;
551+
537552 event . preventDefault ( ) ;
538553 playPauseVideo ( ) ;
539554 } ;
540555
541556 const handleAudioClick = ( event : React . SyntheticEvent ) => {
557+ if ( isCinemagraph ) return ;
558+
542559 void submitClickComponentEvent ( event . currentTarget , renderingTarget ) ;
543560
544561 event . stopPropagation ( ) ; // Don't pause the video
@@ -558,6 +575,8 @@ export const SelfHostedVideo = ({
558575 * browser. Therefore we need to apply the pause state to the video.
559576 */
560577 const handlePause = ( ) => {
578+ if ( isCinemagraph ) return ;
579+
561580 if (
562581 playerState === 'PAUSED_BY_USER' ||
563582 playerState === 'PAUSED_BY_INTERSECTION_OBSERVER'
@@ -581,6 +600,7 @@ export const SelfHostedVideo = ({
581600 new Error ( message ) ,
582601 'self-hosted-video' ,
583602 ) ;
603+
584604 log ( 'dotcom' , message ) ;
585605 } ;
586606
@@ -612,6 +632,8 @@ export const SelfHostedVideo = ({
612632 const handleKeyDown = (
613633 event : React . KeyboardEvent < HTMLVideoElement > ,
614634 ) : void => {
635+ if ( isCinemagraph ) return ;
636+
615637 switch ( event . key ) {
616638 case 'Enter' :
617639 case ' ' :
@@ -642,8 +664,11 @@ export const SelfHostedVideo = ({
642664 return (
643665 < figure
644666 ref = { setNode }
645- css = { videoContainerStyles }
646- className = "video-container"
667+ css = { [
668+ videoContainerStyles ,
669+ isCinemagraph && cinemagraphContainerStyles ,
670+ ] }
671+ className = { `video-container ${ videoStyle . toLocaleLowerCase ( ) } ` }
647672 data-component = "gu-video-loop"
648673 >
649674 < SelfHostedVideoPlayer
@@ -652,6 +677,7 @@ export const SelfHostedVideo = ({
652677 uniqueId = { uniqueId }
653678 width = { width }
654679 height = { height }
680+ videoStyle = { videoStyle }
655681 posterImage = { optimisedPosterImage }
656682 FallbackImageComponent = { FallbackImageComponent }
657683 currentTime = { currentTime }
@@ -671,8 +697,8 @@ export const SelfHostedVideo = ({
671697 AudioIcon = { hasAudio ? AudioIcon : null }
672698 preloadPartialData = { preloadPartialData }
673699 showPlayIcon = { showPlayIcon }
674- subtitleSource = { subtitleSource }
675700 subtitleSize = { subtitleSize }
701+ subtitleSource = { subtitleSource }
676702 activeCue = { activeCue }
677703 />
678704 </ figure >
0 commit comments