Fix tall videos from covering height in export page

This commit is contained in:
Nicolas Mowen 2024-08-02 06:49:37 -06:00
parent 8e7b83d2f1
commit 612562c009

View File

@ -13,6 +13,7 @@ import { Button } from "@/components/ui/button";
import { Dialog, DialogContent, DialogTitle } from "@/components/ui/dialog"; import { Dialog, DialogContent, DialogTitle } from "@/components/ui/dialog";
import { Input } from "@/components/ui/input"; import { Input } from "@/components/ui/input";
import { Toaster } from "@/components/ui/sonner"; import { Toaster } from "@/components/ui/sonner";
import { cn } from "@/lib/utils";
import { DeleteClipType, Export } from "@/types/export"; import { DeleteClipType, Export } from "@/types/export";
import axios from "axios"; import axios from "axios";
import { useCallback, useEffect, useMemo, useState } from "react"; import { useCallback, useEffect, useMemo, useState } from "react";
@ -92,6 +93,7 @@ function Exports() {
// Viewing // Viewing
const [selected, setSelected] = useState<Export>(); const [selected, setSelected] = useState<Export>();
const [selectedAspect, setSelectedAspect] = useState(0.0);
return ( return (
<div className="flex size-full flex-col gap-2 overflow-hidden px-1 pt-2 md:p-2"> <div className="flex size-full flex-col gap-2 overflow-hidden px-1 pt-2 md:p-2">
@ -129,15 +131,25 @@ function Exports() {
} }
}} }}
> >
<DialogContent className="max-w-7xl"> <DialogContent className="max-w-[80%]">
<DialogTitle>{selected?.name}</DialogTitle> <DialogTitle className="capitalize">
{selected?.name?.replaceAll("_", " ")}
</DialogTitle>
<video <video
className="size-full rounded-lg md:rounded-2xl" className={cn(
"size-full rounded-lg md:rounded-2xl",
selectedAspect < 1.5 ? "aspect-video h-full" : "",
)}
playsInline playsInline
preload="auto" preload="auto"
autoPlay autoPlay
controls controls
muted muted
onLoadedData={(e) =>
setSelectedAspect(
e.currentTarget.videoWidth / e.currentTarget.videoHeight,
)
}
> >
<source <source
src={`${baseUrl}${selected?.video_path?.replace("/media/frigate/", "")}`} src={`${baseUrl}${selected?.video_path?.replace("/media/frigate/", "")}`}