From c25874ced5e1e2912194d68a23927c102a4cec9b Mon Sep 17 00:00:00 2001 From: Robin Townsend Date: Mon, 31 Oct 2022 12:34:56 -0400 Subject: [PATCH] Don't log AbortErrors from videos that are never played It's normal for the play operation on video feeds to be cancelled due to tiles unmounting quickly (especially with React 18's strict mode), but it logs a scary error which can be misleading during debugging. --- src/video-grid/useMediaStream.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/video-grid/useMediaStream.ts b/src/video-grid/useMediaStream.ts index ef3fb5d0..aae942d0 100644 --- a/src/video-grid/useMediaStream.ts +++ b/src/video-grid/useMediaStream.ts @@ -86,7 +86,9 @@ export const useMediaStream = ( if (stream) { mediaEl.muted = mute; mediaEl.srcObject = stream; - mediaEl.play(); + mediaEl.play().catch((e) => { + if (e.name !== "AbortError") throw e; + }); // Unmuting the tab in Safari causes all video elements to be individually // unmuted, so we need to reset the mute state here to prevent audio loops