mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-08 20:25:26 +03:00
Add button for camera audio
This commit is contained in:
parent
b9d4a3d51a
commit
7a0db8abb6
@ -20,6 +20,7 @@ type LivePlayerProps = {
|
|||||||
preferredLiveMode?: LivePlayerMode;
|
preferredLiveMode?: LivePlayerMode;
|
||||||
showStillWithoutActivity?: boolean;
|
showStillWithoutActivity?: boolean;
|
||||||
windowVisible?: boolean;
|
windowVisible?: boolean;
|
||||||
|
playAudio?: boolean;
|
||||||
onClick?: () => void;
|
onClick?: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -29,6 +30,7 @@ export default function LivePlayer({
|
|||||||
preferredLiveMode,
|
preferredLiveMode,
|
||||||
showStillWithoutActivity = true,
|
showStillWithoutActivity = true,
|
||||||
windowVisible = true,
|
windowVisible = true,
|
||||||
|
playAudio = false,
|
||||||
onClick,
|
onClick,
|
||||||
}: LivePlayerProps) {
|
}: LivePlayerProps) {
|
||||||
// camera activity
|
// camera activity
|
||||||
@ -95,6 +97,7 @@ export default function LivePlayer({
|
|||||||
className={`rounded-2xl h-full ${liveReady ? "" : "hidden"}`}
|
className={`rounded-2xl h-full ${liveReady ? "" : "hidden"}`}
|
||||||
camera={cameraConfig.live.stream_name}
|
camera={cameraConfig.live.stream_name}
|
||||||
playbackEnabled={cameraActive}
|
playbackEnabled={cameraActive}
|
||||||
|
audioEnabled={playAudio}
|
||||||
onPlaying={() => setLiveReady(true)}
|
onPlaying={() => setLiveReady(true)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@ -105,6 +108,7 @@ export default function LivePlayer({
|
|||||||
className={`rounded-2xl h-full ${liveReady ? "" : "hidden"}`}
|
className={`rounded-2xl h-full ${liveReady ? "" : "hidden"}`}
|
||||||
camera={cameraConfig.name}
|
camera={cameraConfig.name}
|
||||||
playbackEnabled={cameraActive}
|
playbackEnabled={cameraActive}
|
||||||
|
audioEnabled={playAudio}
|
||||||
onPlaying={() => setLiveReady(true)}
|
onPlaying={() => setLiveReady(true)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -5,6 +5,7 @@ type MSEPlayerProps = {
|
|||||||
camera: string;
|
camera: string;
|
||||||
className?: string;
|
className?: string;
|
||||||
playbackEnabled?: boolean;
|
playbackEnabled?: boolean;
|
||||||
|
audioEnabled?: boolean;
|
||||||
onPlaying?: () => void;
|
onPlaying?: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -12,6 +13,7 @@ function MSEPlayer({
|
|||||||
camera,
|
camera,
|
||||||
className,
|
className,
|
||||||
playbackEnabled = true,
|
playbackEnabled = true,
|
||||||
|
audioEnabled = false,
|
||||||
onPlaying,
|
onPlaying,
|
||||||
}: MSEPlayerProps) {
|
}: MSEPlayerProps) {
|
||||||
let connectTS: number = 0;
|
let connectTS: number = 0;
|
||||||
@ -273,7 +275,7 @@ function MSEPlayer({
|
|||||||
playsInline
|
playsInline
|
||||||
preload="auto"
|
preload="auto"
|
||||||
onLoadedData={onPlaying}
|
onLoadedData={onPlaying}
|
||||||
muted
|
muted={!audioEnabled}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,7 @@ type WebRtcPlayerProps = {
|
|||||||
className?: string;
|
className?: string;
|
||||||
camera: string;
|
camera: string;
|
||||||
playbackEnabled?: boolean;
|
playbackEnabled?: boolean;
|
||||||
|
audioEnabled?: boolean;
|
||||||
onPlaying?: () => void;
|
onPlaying?: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -12,6 +13,7 @@ export default function WebRtcPlayer({
|
|||||||
className,
|
className,
|
||||||
camera,
|
camera,
|
||||||
playbackEnabled = true,
|
playbackEnabled = true,
|
||||||
|
audioEnabled = false,
|
||||||
onPlaying,
|
onPlaying,
|
||||||
}: WebRtcPlayerProps) {
|
}: WebRtcPlayerProps) {
|
||||||
// camera states
|
// camera states
|
||||||
@ -160,7 +162,7 @@ export default function WebRtcPlayer({
|
|||||||
className={className}
|
className={className}
|
||||||
autoPlay
|
autoPlay
|
||||||
playsInline
|
playsInline
|
||||||
muted
|
muted={!audioEnabled}
|
||||||
onLoadedData={onPlaying}
|
onLoadedData={onPlaying}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -18,7 +18,7 @@ import { TooltipProvider } from "@/components/ui/tooltip";
|
|||||||
import useKeyboardListener from "@/hooks/use-keyboard-listener";
|
import useKeyboardListener from "@/hooks/use-keyboard-listener";
|
||||||
import { CameraConfig } from "@/types/frigateConfig";
|
import { CameraConfig } from "@/types/frigateConfig";
|
||||||
import { CameraPtzInfo } from "@/types/ptz";
|
import { CameraPtzInfo } from "@/types/ptz";
|
||||||
import React, { useCallback, useMemo } from "react";
|
import React, { useCallback, useMemo, useState } from "react";
|
||||||
import { isSafari } from "react-device-detect";
|
import { isSafari } from "react-device-detect";
|
||||||
import { BsThreeDotsVertical } from "react-icons/bs";
|
import { BsThreeDotsVertical } from "react-icons/bs";
|
||||||
import {
|
import {
|
||||||
@ -27,6 +27,7 @@ import {
|
|||||||
FaAngleRight,
|
FaAngleRight,
|
||||||
FaAngleUp,
|
FaAngleUp,
|
||||||
} from "react-icons/fa";
|
} from "react-icons/fa";
|
||||||
|
import { GiSpeaker, GiSpeakerOff } from "react-icons/gi";
|
||||||
import { IoMdArrowBack } from "react-icons/io";
|
import { IoMdArrowBack } from "react-icons/io";
|
||||||
import { LuEar, LuEarOff, LuVideo, LuVideoOff } from "react-icons/lu";
|
import { LuEar, LuEarOff, LuVideo, LuVideoOff } from "react-icons/lu";
|
||||||
import {
|
import {
|
||||||
@ -34,6 +35,7 @@ import {
|
|||||||
MdPersonOff,
|
MdPersonOff,
|
||||||
MdPersonSearch,
|
MdPersonSearch,
|
||||||
MdPhotoCamera,
|
MdPhotoCamera,
|
||||||
|
MdSpeaker,
|
||||||
MdZoomIn,
|
MdZoomIn,
|
||||||
MdZoomOut,
|
MdZoomOut,
|
||||||
} from "react-icons/md";
|
} from "react-icons/md";
|
||||||
@ -59,6 +61,10 @@ export default function LiveCameraView({ camera }: LiveCameraViewProps) {
|
|||||||
);
|
);
|
||||||
const { payload: audioState, send: sendAudio } = useAudioState(camera.name);
|
const { payload: audioState, send: sendAudio } = useAudioState(camera.name);
|
||||||
|
|
||||||
|
// playback state
|
||||||
|
|
||||||
|
const [audio, setAudio] = useState(false);
|
||||||
|
|
||||||
const growClassName = useMemo(() => {
|
const growClassName = useMemo(() => {
|
||||||
if (camera.detect.width / camera.detect.height > 2) {
|
if (camera.detect.width / camera.detect.height > 2) {
|
||||||
return "absolute left-2 right-2 top-[50%] -translate-y-[50%]";
|
return "absolute left-2 right-2 top-[50%] -translate-y-[50%]";
|
||||||
@ -76,6 +82,12 @@ export default function LiveCameraView({ camera }: LiveCameraViewProps) {
|
|||||||
</Button>
|
</Button>
|
||||||
<TooltipProvider>
|
<TooltipProvider>
|
||||||
<div className="flex items-center gap-1 mr-1 *:rounded-lg">
|
<div className="flex items-center gap-1 mr-1 *:rounded-lg">
|
||||||
|
<CameraFeatureToggle
|
||||||
|
Icon={audio ? GiSpeaker : GiSpeakerOff}
|
||||||
|
isActive={audio}
|
||||||
|
title={`${audio ? "Disable" : "Enable"} Camera Audio`}
|
||||||
|
onClick={() => setAudio(!audio)}
|
||||||
|
/>
|
||||||
<CameraFeatureToggle
|
<CameraFeatureToggle
|
||||||
Icon={detectState == "ON" ? MdPersonSearch : MdPersonOff}
|
Icon={detectState == "ON" ? MdPersonSearch : MdPersonOff}
|
||||||
isActive={detectState == "ON"}
|
isActive={detectState == "ON"}
|
||||||
@ -117,6 +129,7 @@ export default function LiveCameraView({ camera }: LiveCameraViewProps) {
|
|||||||
windowVisible
|
windowVisible
|
||||||
showStillWithoutActivity={false}
|
showStillWithoutActivity={false}
|
||||||
cameraConfig={camera}
|
cameraConfig={camera}
|
||||||
|
playAudio={audio}
|
||||||
preferredLiveMode={isSafari ? "webrtc" : "mse"}
|
preferredLiveMode={isSafari ? "webrtc" : "mse"}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user