import { cn } from "@/lib/utils"; import { PlayerStatsType } from "@/types/live"; import { useTranslation } from "react-i18next"; type PlayerStatsProps = { stats: PlayerStatsType; minimal: boolean; }; export function PlayerStats({ stats, minimal }: PlayerStatsProps) { const { t } = useTranslation(["components/player"]); const fullStatsContent = ( <>

{t("stats.streamType")}{" "} {stats.streamType}

{t("stats.bandwidth")}{" "} {stats.bandwidth.toFixed(2)} kbps

{stats.latency != undefined && (

{t("stats.latency")}{" "} 2 ? "text-danger" : ""}`} > {t("stats.latency.value", { secounds: stats.latency.toFixed(2) })}

)}

{t("stats.totalFrames")}{" "} {stats.totalFrames}

{stats.droppedFrames != undefined && (

{t("stats.droppedFrames")}{" "} {stats.droppedFrames}

)} {stats.decodedFrames != undefined && (

{t("stats.decodedFrames")}{" "} {stats.decodedFrames}

)} {stats.droppedFrameRate != undefined && (

{t("stats.droppedFrameRate")}{" "} {stats.droppedFrameRate.toFixed(2)}%

)} ); const minimalStatsContent = (
{t("stats.streamType.short")} {stats.streamType}
{t("stats.bandwidth.short")}{" "} {stats.bandwidth.toFixed(2)} kbps
{stats.latency != undefined && (
{t("stats.latency.short")} = 2 ? "text-danger" : ""}`} > {t("stats.latency.short.value", { secounds: stats.latency.toFixed(2), })}
)} {stats.droppedFrames != undefined && (
{t("stats.droppedFrames.short")} {t("stats.droppedFrames.short.value", { droppedFrames: stats.droppedFrames, })}
)}
); return ( <>
{minimal ? minimalStatsContent : fullStatsContent}
); }