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";
|
2023-12-20 15:34:27 +01:00
|
|
|
|
|
|
|
type LivePlayerProps = {
|
|
|
|
birdseyeConfig: BirdseyeConfig;
|
|
|
|
liveMode: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
export default function BirdseyeLivePlayer({
|
|
|
|
birdseyeConfig,
|
|
|
|
liveMode,
|
|
|
|
}: 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 = (
|
|
|
|
<WebRtcPlayer className={`rounded-2xl size-full`} 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 = (
|
|
|
|
<MSEPlayer className={`rounded-2xl size-full`} 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
|
|
|
|
className="size-full flex justify-center rounded-2xl overflow-hidden"
|
|
|
|
camera="birdseye"
|
|
|
|
width={birdseyeConfig.width}
|
|
|
|
height={birdseyeConfig.height}
|
|
|
|
/>
|
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 (
|
|
|
|
<div className={`relative flex justify-center w-full cursor-pointer`}>
|
|
|
|
<div className="absolute top-0 inset-x-0 rounded-2xl z-10 w-full h-[30%] bg-gradient-to-b from-black/20 to-transparent pointer-events-none"></div>
|
|
|
|
<div className="absolute bottom-0 inset-x-0 rounded-2xl z-10 w-full h-[10%] bg-gradient-to-t from-black/20 to-transparent pointer-events-none"></div>
|
|
|
|
<div className="size-full">{player}</div>
|
|
|
|
</div>
|
|
|
|
);
|
2023-12-20 15:34:27 +01:00
|
|
|
}
|