From 1b70f09bee2f9fbc61ba08ca4970f172d7dd0d30 Mon Sep 17 00:00:00 2001 From: roo hutton Date: Mon, 14 Jul 2025 10:51:28 +0100 Subject: [PATCH] Merge pull request #27031 from overleaf/rh-safari-video-el Catch video autoplay errors from Safari GitOrigin-RevId: c2ed2b0a720603bfb80ebb3025c4ed107eec7f06 --- .../frontend/js/features/autoplay-video/index.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/services/web/frontend/js/features/autoplay-video/index.js b/services/web/frontend/js/features/autoplay-video/index.js index d706f9058b..0f66f67d65 100644 --- a/services/web/frontend/js/features/autoplay-video/index.js +++ b/services/web/frontend/js/features/autoplay-video/index.js @@ -1,3 +1,5 @@ +import { debugConsole } from '@/utils/debugging' + function setup(videoEl) { const reducedMotionReduce = window.matchMedia( '(prefers-reduced-motion: reduce)' @@ -35,10 +37,18 @@ function setup(videoEl) { videoIsVisible = true if (videoEl.readyState >= videoEl.HAVE_FUTURE_DATA) { if (!videoEl.ended) { - videoEl.play() + videoEl + .play() + .catch(error => + debugConsole.error('Video autoplay failed:', error) + ) + } else { + videoEl + .play() + .catch(error => + debugConsole.error('Video autoplay failed:', error) + ) } - } else { - videoEl.play() } } else { videoIsVisible = false