11import { css } from '@emotion/react' ;
2- import { log } from '@guardian/libs' ;
2+ import { log , storage } from '@guardian/libs' ;
33import { SvgAudio , SvgAudioMute } from '@guardian/source/react-components' ;
44import { useEffect , useRef , useState } from 'react' ;
55import { getZIndex } from '../lib/getZIndex' ;
@@ -80,8 +80,8 @@ export const LoopVideo = ({
8080 /**
8181 * Setup.
8282 *
83- * Register the users motion preferences.
84- * Creates event listeners to control playback when there are multiple videos.
83+ * 1. Register the user's motion preferences.
84+ * 2. Creates event listeners to control playback when there are multiple videos.
8585 */
8686 useEffect ( ( ) => {
8787 /**
@@ -90,7 +90,18 @@ export const LoopVideo = ({
9090 const userPrefersReducedMotion = window . matchMedia (
9191 '(prefers-reduced-motion: reduce)' ,
9292 ) . matches ;
93- setIsAutoplayAllowed ( ! userPrefersReducedMotion ) ;
93+
94+ const flashingPreferences = storage . local . get (
95+ 'gu.prefs.accessibility.flashing-elements' ,
96+ ) ;
97+
98+ /**
99+ * `flashingPreference` is `null` if no preference exists and explicitly
100+ * `false` when the reader has said they don't want flashing
101+ */
102+ setIsAutoplayAllowed (
103+ ! userPrefersReducedMotion || flashingPreferences === null ,
104+ ) ;
94105
95106 /**
96107 * Mutes the current video when another video is unmuted
@@ -110,7 +121,7 @@ export const LoopVideo = ({
110121 } ;
111122
112123 /**
113- * Mute the current video when a Youtube video is played
124+ * Mute the current video when a YouTube video is played
114125 * Triggered by the CustomEvent in YoutubeAtomPlayer.
115126 */
116127 const handleCustomPlayYoutubeEvent = ( ) => {
0 commit comments