import { getElement, store } from '@wordpress/interactivity'; import { prefersReducedMotion } from '../utils/reduced-motion'; store( 'core/video', { callbacks: { stopAutoplay() { if ( ! prefersReducedMotion() ) { return; } // The video is saved with `autoplay`, so it is stopped here // rather than never started. Clearing the attribute as well // keeps it from playing again if the source reloads. const { ref } = getElement(); ( ref as HTMLVideoElement ).autoplay = false; ( ref as HTMLVideoElement ).pause(); }, }, }, { lock: true } );