Skip to content

Commit

Permalink
Merge pull request #139 from martillansky/testnets
Browse files Browse the repository at this point in the history
fix: catch unrecognized video uploading
  • Loading branch information
martillansky authored Nov 5, 2024
2 parents 669d215 + e8f6a27 commit 3974851
Showing 1 changed file with 28 additions and 23 deletions.
51 changes: 28 additions & 23 deletions src/app/[pohid]/claim/Video.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}}
>
<div className="bg-orange mr-4 flex h-12 w-12 items-center justify-center rounded-full">
Expand Down

0 comments on commit 3974851

Please sign in to comment.