From b2aef1f803d67d1f9874b3e740e9cbb0a60b839c Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Thu, 12 Jun 2025 11:08:44 -0500 Subject: [PATCH] Add back silenced error handling --- .../VideoEmbedInner/web-controls/utils.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) 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 ae129415e0..7258616d98 100644 --- a/src/components/Post/Embed/VideoEmbed/VideoEmbedInner/web-controls/utils.tsx +++ b/src/components/Post/Embed/VideoEmbed/VideoEmbedInner/web-controls/utils.tsx @@ -1,4 +1,5 @@ -import React, {useCallback, useEffect, useRef, useState} from 'react' +import {useCallback, useEffect, useRef, useState} from 'react' +import type React from 'react'; import {isSafari} from '#/lib/browser' import {useVideoVolumeState} from '#/components/Post/Embed/VideoEmbed/VideoVolumeContext' @@ -68,14 +69,22 @@ export function useVideoElement(ref: React.RefObject) { setError(true) } - const handleCanPlay = () => { + const handleCanPlay = async () => { if (bufferingTimeout) clearTimeout(bufferingTimeout) setBuffering(false) setCanPlay(true) if (!ref.current) return if (playWhenReadyRef.current) { - ref.current.play() + try { + await ref.current.play() + } catch (e: any) { + if ( + !e.message?.includes(`The request is not allowed by the user agent`) + ) { + throw e + } + } playWhenReadyRef.current = false } }