mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-15 15:45:27 +03:00
Add play pause via mouse click
This commit is contained in:
parent
ed1ad26c29
commit
7beded9731
@ -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)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user