* Add onConnect to mqtt and doucment

* Add play pause via mouse click
This commit is contained in:
Nicolas Mowen 2024-09-26 08:12:15 -06:00 committed by GitHub
parent a6ccb37683
commit 35a4460334
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 28 additions and 12 deletions

View File

@ -147,6 +147,10 @@ Message published for each changed review item. The first message is published w
Same data available at `/api/stats` published at a configurable interval. Same data available at `/api/stats` published at a configurable interval.
### `frigate/camera_activity`
Returns data about each camera, its current features, and if it is detecting motion, objects, etc. Can be triggered by publising to `frigate/onConnect`
### `frigate/notifications/set` ### `frigate/notifications/set`
Topic to turn notifications on and off. Expected values are `ON` and `OFF`. Topic to turn notifications on and off. Expected values are `ON` and `OFF`.

View File

@ -222,6 +222,10 @@ class MqttClient(Communicator): # type: ignore[misc]
self.on_mqtt_command, self.on_mqtt_command,
) )
self.client.message_callback_add(
f"{self.mqtt_config.topic_prefix}/onConnect", self.on_mqtt_command
)
self.client.message_callback_add( self.client.message_callback_add(
f"{self.mqtt_config.topic_prefix}/restart", self.on_mqtt_command f"{self.mqtt_config.topic_prefix}/restart", self.on_mqtt_command
) )

View File

@ -123,6 +123,23 @@ export default function HlsVideoPlayer({
videoRef.current.playbackRate = currentPlaybackRate; videoRef.current.playbackRate = currentPlaybackRate;
}, [videoRef, hlsRef, useHlsCompat, currentSource]); }, [videoRef, hlsRef, useHlsCompat, currentSource]);
// state handling
const onPlayPause = useCallback(
(play: boolean) => {
if (!videoRef.current) {
return;
}
if (play) {
videoRef.current.play();
} else {
videoRef.current.pause();
}
},
[videoRef],
);
// controls // controls
const [tallCamera, setTallCamera] = useState(false); const [tallCamera, setTallCamera] = useState(false);
@ -191,17 +208,7 @@ export default function HlsVideoPlayer({
setMuted={(muted) => setMuted(muted, true)} setMuted={(muted) => setMuted(muted, true)}
playbackRate={playbackRate ?? 1} playbackRate={playbackRate ?? 1}
hotKeys={hotKeys} hotKeys={hotKeys}
onPlayPause={(play) => { onPlayPause={onPlayPause}
if (!videoRef.current) {
return;
}
if (play) {
videoRef.current.play();
} else {
videoRef.current.pause();
}
}}
onSeek={(diff) => { onSeek={(diff) => {
const currentTime = videoRef.current?.currentTime; const currentTime = videoRef.current?.currentTime;
@ -254,12 +261,13 @@ export default function HlsVideoPlayer({
> >
<video <video
ref={videoRef} ref={videoRef}
className={`size-full rounded-lg bg-black md:rounded-2xl ${loadedMetadata ? "" : "invisible"}`} className={`size-full rounded-lg bg-black md:rounded-2xl ${loadedMetadata ? "" : "invisible"} cursor-pointer`}
preload="auto" preload="auto"
autoPlay autoPlay
controls={!frigateControls} controls={!frigateControls}
playsInline playsInline
muted={muted} muted={muted}
onClick={() => onPlayPause(!isPlaying)}
onVolumeChange={() => onVolumeChange={() =>
setVolume(videoRef.current?.volume ?? 1.0, true) setVolume(videoRef.current?.volume ?? 1.0, true)
} }