diff --git a/src/app/[pohid]/claim/Video.tsx b/src/app/[pohid]/claim/Video.tsx index 72d4d3d..7b7d770 100644 --- a/src/app/[pohid]/claim/Video.tsx +++ b/src/app/[pohid]/claim/Video.tsx @@ -140,29 +140,34 @@ function VideoStep({ advance, video$, isRenewal, videoError }: PhotoProps) { className="bg-whiteBackground flex h-full items-center justify-center rounded p-2 outline-dotted outline-white" type="video" onDrop={async (received) => { - const file = received[0]; - const blob = new Blob([file], { type: file.type }); - const uri = URL.createObjectURL(blob); - - await checkVideoDuration(blob); - checkVideoSize(blob); - const vid = document.createElement("video"); - vid.crossOrigin = "anonymous"; - vid.src = uri; - vid.preload = "auto"; - - vid.addEventListener("loadeddata", async () => { - if ( - vid.videoWidth < MIN_DIMS.width || - vid.videoHeight < MIN_DIMS.height - ) { - videoError(ERROR_MSG.dimensions); - return console.error(ERROR_MSG.dimensions); - } - - setRecording(false); - video$.set({ uri, content: blob }); - }); + try { + const file = received[0]; + const blob = new Blob([file], { type: file.type }); + const uri = URL.createObjectURL(blob); + + await checkVideoDuration(blob); + checkVideoSize(blob); + const vid = document.createElement("video"); + vid.crossOrigin = "anonymous"; + vid.src = uri; + vid.preload = "auto"; + + vid.addEventListener("loadeddata", async () => { + if ( + vid.videoWidth < MIN_DIMS.width || + vid.videoHeight < MIN_DIMS.height + ) { + videoError(ERROR_MSG.dimensions); + return console.error(ERROR_MSG.dimensions); + } + + setRecording(false); + video$.set({ uri, content: blob }); + }); + } catch (error: any) { + videoError("Unexpected error. Check format/codecs used."); + return console.error(error); + } }} >