import { useState, type ReactNode, type VideoHTMLAttributes } from "react";
import { cn } from "../../lib/cn";
export type VideoSource = {
src: string;
type?: string;
};
export type VideoPlayerProps = Omit, "children"> & {
aspectRatio?: number | string;
fallback?: ReactNode;
fit?: "contain" | "cover" | "fill" | "none" | "scale-down";
frameClassName?: string;
responsive?: boolean;
sources?: VideoSource[];
};
export function VideoPlayer({
aspectRatio = 16 / 9,
className,
controls = true,
fallback,
fit = "contain",
frameClassName,
playsInline = true,
onError,
poster,
responsive = true,
src,
style,
sources,
...props
}: VideoPlayerProps) {
const [failed, setFailed] = useState(false);
return (
{failed ? (
fallback ??
Unable to load video
) : (
)}
);
}