From d8129cceb55b301570536d75cb5232759cf3be86 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Wed, 13 Mar 2024 15:23:07 -0500 Subject: [PATCH] also check for media decode error to fallback to HLS --- web/src/components/player/HlsVideoPlayer.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/web/src/components/player/HlsVideoPlayer.tsx b/web/src/components/player/HlsVideoPlayer.tsx index 98be56e2a..cbf5e2b5d 100644 --- a/web/src/components/player/HlsVideoPlayer.tsx +++ b/web/src/components/player/HlsVideoPlayer.tsx @@ -21,6 +21,10 @@ import { MdForward10, MdReplay10 } from "react-icons/md"; import useKeyboardListener from "@/hooks/use-keyboard-listener"; const HLS_MIME_TYPE = "application/vnd.apple.mpegurl" as const; +const unsupportedErrorCodes = [ + MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED, + MediaError.MEDIA_ERR_DECODE, +]; type HlsVideoPlayerProps = { className: string; @@ -188,7 +192,7 @@ export default function HlsVideoPlayer({ if ( !hlsRef.current && // @ts-expect-error code does exist - e.target.error.code == MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED && + unsupportedErrorCodes.includes(e.target.error.code) && videoRef.current ) { setUseHlsCompat(true);