2023-12-20 15:34:27 +01:00
|
|
|
import WebRtcPlayer from "./WebRTCPlayer";
|
|
|
|
import { BirdseyeConfig } from "@/types/frigateConfig";
|
2024-03-03 17:32:47 +01:00
|
|
|
import ActivityIndicator from "../indicators/activity-indicator";
|
2023-12-20 15:34:27 +01:00
|
|
|
import JSMpegPlayer from "./JSMpegPlayer";
|
2024-01-04 00:38:52 +01:00
|
|
|
import MSEPlayer from "./MsePlayer";
|
2024-03-16 00:28:32 +01:00
|
|
|
import { LivePlayerMode } from "@/types/live";
|
2024-05-07 16:00:25 +02:00
|
|
|
import { cn } from "@/lib/utils";
|
2024-05-28 00:18:04 +02:00
|
|
|
import React from "react";
|
2023-12-20 15:34:27 +01:00
|
|
|
|
|
|
|
type LivePlayerProps = {
|
2024-03-16 00:28:32 +01:00
|
|
|
className?: string;
|
2023-12-20 15:34:27 +01:00
|
|
|
birdseyeConfig: BirdseyeConfig;
|
2024-03-16 00:28:32 +01:00
|
|
|
liveMode: LivePlayerMode;
|
|
|
|
onClick?: () => void;
|
2024-05-28 00:18:04 +02:00
|
|
|
containerRef?: React.MutableRefObject<HTMLDivElement | null>;
|
2023-12-20 15:34:27 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
export default function BirdseyeLivePlayer({
|
2024-03-16 00:28:32 +01:00
|
|
|
className,
|
2023-12-20 15:34:27 +01:00
|
|
|
birdseyeConfig,
|
|
|
|
liveMode,
|
2024-03-16 00:28:32 +01:00
|
|
|
onClick,
|
2024-05-28 00:18:04 +02:00
|
|
|
containerRef,
|
2023-12-20 15:34:27 +01:00
|
|
|
}: LivePlayerProps) {
|
2024-03-12 20:53:01 +01:00
|
|
|
let player;
|
2023-12-20 15:34:27 +01:00
|
|
|
if (liveMode == "webrtc") {
|
2024-03-12 20:53:01 +01:00
|
|
|
player = (
|
2024-04-22 17:12:45 +02:00
|
|
|
<WebRtcPlayer
|
2024-05-14 17:06:44 +02:00
|
|
|
className={`size-full rounded-lg md:rounded-2xl`}
|
2024-04-22 17:12:45 +02:00
|
|
|
camera="birdseye"
|
|
|
|
/>
|
2023-12-20 15:34:27 +01:00
|
|
|
);
|
|
|
|
} else if (liveMode == "mse") {
|
2024-01-04 00:38:52 +01:00
|
|
|
if ("MediaSource" in window || "ManagedMediaSource" in window) {
|
2024-03-12 20:53:01 +01:00
|
|
|
player = (
|
2024-04-22 17:12:45 +02:00
|
|
|
<MSEPlayer
|
2024-05-14 17:06:44 +02:00
|
|
|
className={`size-full rounded-lg md:rounded-2xl`}
|
2024-04-22 17:12:45 +02:00
|
|
|
camera="birdseye"
|
|
|
|
/>
|
2024-01-04 00:38:52 +01:00
|
|
|
);
|
|
|
|
} else {
|
2024-03-12 20:53:01 +01:00
|
|
|
player = (
|
2024-01-04 00:38:52 +01:00
|
|
|
<div className="w-5xl text-center text-sm">
|
|
|
|
MSE is only supported on iOS 17.1+. You'll need to update if available
|
|
|
|
or use jsmpeg / webRTC streams. See the docs for more info.
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2023-12-20 15:34:27 +01:00
|
|
|
} else if (liveMode == "jsmpeg") {
|
2024-03-12 20:53:01 +01:00
|
|
|
player = (
|
|
|
|
<JSMpegPlayer
|
2024-05-14 17:06:44 +02:00
|
|
|
className="flex size-full justify-center overflow-hidden rounded-lg md:rounded-2xl"
|
2024-03-12 20:53:01 +01:00
|
|
|
camera="birdseye"
|
|
|
|
width={birdseyeConfig.width}
|
|
|
|
height={birdseyeConfig.height}
|
2024-05-28 00:18:04 +02:00
|
|
|
containerRef={containerRef}
|
2024-03-12 20:53:01 +01:00
|
|
|
/>
|
2023-12-20 15:34:27 +01:00
|
|
|
);
|
|
|
|
} else {
|
2024-03-12 20:53:01 +01:00
|
|
|
player = <ActivityIndicator />;
|
2023-12-20 15:34:27 +01:00
|
|
|
}
|
2024-03-12 20:53:01 +01:00
|
|
|
|
|
|
|
return (
|
2024-03-16 00:28:32 +01:00
|
|
|
<div
|
2024-05-07 16:00:25 +02:00
|
|
|
className={cn(
|
2024-05-14 17:06:44 +02:00
|
|
|
"relative flex w-full cursor-pointer justify-center",
|
2024-05-07 16:00:25 +02:00
|
|
|
className,
|
|
|
|
)}
|
2024-03-16 00:28:32 +01:00
|
|
|
onClick={onClick}
|
|
|
|
>
|
2024-05-14 17:06:44 +02:00
|
|
|
<div className="pointer-events-none absolute inset-x-0 top-0 z-10 h-[30%] w-full rounded-lg bg-gradient-to-b from-black/20 to-transparent md:rounded-2xl"></div>
|
|
|
|
<div className="pointer-events-none absolute inset-x-0 bottom-0 z-10 h-[10%] w-full rounded-lg bg-gradient-to-t from-black/20 to-transparent md:rounded-2xl"></div>
|
2024-03-12 20:53:01 +01:00
|
|
|
<div className="size-full">{player}</div>
|
|
|
|
</div>
|
|
|
|
);
|
2023-12-20 15:34:27 +01:00
|
|
|
}
|