also check for media decode error to fallback to HLS

This commit is contained in:
Josh Hawkins 2024-03-13 15:23:07 -05:00
parent 5870cde614
commit d8129cceb5

View File

@ -21,6 +21,10 @@ import { MdForward10, MdReplay10 } from "react-icons/md";
import useKeyboardListener from "@/hooks/use-keyboard-listener"; import useKeyboardListener from "@/hooks/use-keyboard-listener";
const HLS_MIME_TYPE = "application/vnd.apple.mpegurl" as const; const HLS_MIME_TYPE = "application/vnd.apple.mpegurl" as const;
const unsupportedErrorCodes = [
MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED,
MediaError.MEDIA_ERR_DECODE,
];
type HlsVideoPlayerProps = { type HlsVideoPlayerProps = {
className: string; className: string;
@ -188,7 +192,7 @@ export default function HlsVideoPlayer({
if ( if (
!hlsRef.current && !hlsRef.current &&
// @ts-expect-error code does exist // @ts-expect-error code does exist
e.target.error.code == MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED && unsupportedErrorCodes.includes(e.target.error.code) &&
videoRef.current videoRef.current
) { ) {
setUseHlsCompat(true); setUseHlsCompat(true);