From 92ee6260c1f889f350b7138c4abd537bc4424abc Mon Sep 17 00:00:00 2001
From: Samuel Newman <mozzius@protonmail.com>
Date: Fri, 20 Jun 2025 19:50:21 +0300
Subject: Ignore common video errors (#8548)

---
 .../VideoEmbed/VideoEmbedInner/web-controls/utils.tsx | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

(limited to 'src/components/Post/Embed/VideoEmbed/VideoEmbedInner/web-controls/utils.tsx')

diff --git a/src/components/Post/Embed/VideoEmbed/VideoEmbedInner/web-controls/utils.tsx b/src/components/Post/Embed/VideoEmbed/VideoEmbedInner/web-controls/utils.tsx
index 320f61a5f..db5ae6ac3 100644
--- a/src/components/Post/Embed/VideoEmbed/VideoEmbedInner/web-controls/utils.tsx
+++ b/src/components/Post/Embed/VideoEmbed/VideoEmbedInner/web-controls/utils.tsx
@@ -1,6 +1,7 @@
 import {type RefObject, useCallback, useEffect, useRef, useState} from 'react'
 
 import {isSafari} from '#/lib/browser'
+import {logger} from '#/logger'
 import {useVideoVolumeState} from '#/components/Post/Embed/VideoEmbed/VideoVolumeContext'
 
 export function useVideoElement(ref: RefObject<HTMLVideoElement>) {
@@ -79,7 +80,12 @@ export function useVideoElement(ref: RefObject<HTMLVideoElement>) {
           await ref.current.play()
         } catch (e: any) {
           if (
-            !e.message?.includes(`The request is not allowed by the user agent`)
+            !e.message?.includes(
+              `The request is not allowed by the user agent`,
+            ) &&
+            !e.message?.includes(
+              `The play() request was interrupted by a call to pause()`,
+            )
           ) {
             throw e
           }
@@ -176,8 +182,15 @@ export function useVideoElement(ref: RefObject<HTMLVideoElement>) {
     } else {
       const promise = ref.current.play()
       if (promise !== undefined) {
-        promise.catch(err => {
-          console.error('Error playing video:', err)
+        promise.catch((err: any) => {
+          if (
+            // ignore this common error. it's fine
+            !err.message?.includes(
+              `The play() request was interrupted by a call to pause()`,
+            )
+          ) {
+            logger.error('Error playing video:', {message: err})
+          }
         })
       }
     }
-- 
cgit 1.4.1

