mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-04-05 22:57:40 +03:00
Sync dev with history-stuff snapshot timestamp fixes
This commit is contained in:
parent
7cc235ae93
commit
88daf1dc2d
@ -22,6 +22,11 @@ import { ASPECT_VERTICAL_LAYOUT, RecordingPlayerError } from "@/types/record";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import ObjectTrackOverlay from "@/components/overlay/ObjectTrackOverlay";
|
import ObjectTrackOverlay from "@/components/overlay/ObjectTrackOverlay";
|
||||||
import { useIsAdmin } from "@/hooks/use-is-admin";
|
import { useIsAdmin } from "@/hooks/use-is-admin";
|
||||||
|
import {
|
||||||
|
downloadSnapshot,
|
||||||
|
generateSnapshotFilename,
|
||||||
|
grabVideoSnapshot,
|
||||||
|
} from "@/utils/snapshotUtil";
|
||||||
|
|
||||||
// Android native hls does not seek correctly
|
// Android native hls does not seek correctly
|
||||||
const USE_NATIVE_HLS = false;
|
const USE_NATIVE_HLS = false;
|
||||||
@ -89,7 +94,7 @@ export default function HlsVideoPlayer({
|
|||||||
currentTimeOverride,
|
currentTimeOverride,
|
||||||
transformedOverlay,
|
transformedOverlay,
|
||||||
}: HlsVideoPlayerProps) {
|
}: HlsVideoPlayerProps) {
|
||||||
const { t } = useTranslation("components/player");
|
const { t } = useTranslation(["components/player", "views/live"]);
|
||||||
const { data: config } = useSWR<FrigateConfig>("config");
|
const { data: config } = useSWR<FrigateConfig>("config");
|
||||||
const isAdmin = useIsAdmin();
|
const isAdmin = useIsAdmin();
|
||||||
|
|
||||||
@ -317,6 +322,7 @@ export default function HlsVideoPlayer({
|
|||||||
seek: true,
|
seek: true,
|
||||||
playbackRate: true,
|
playbackRate: true,
|
||||||
plusUpload: isAdmin && config?.plus?.enabled == true,
|
plusUpload: isAdmin && config?.plus?.enabled == true,
|
||||||
|
snapshot: true,
|
||||||
fullscreen: supportsFullscreen,
|
fullscreen: supportsFullscreen,
|
||||||
}}
|
}}
|
||||||
setControlsOpen={setControlsOpen}
|
setControlsOpen={setControlsOpen}
|
||||||
|
|||||||
@ -34,12 +34,14 @@ import {
|
|||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { FaCompress, FaExpand } from "react-icons/fa";
|
import { FaCompress, FaExpand } from "react-icons/fa";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { TbCameraDown } from "react-icons/tb";
|
||||||
|
|
||||||
type VideoControls = {
|
type VideoControls = {
|
||||||
volume?: boolean;
|
volume?: boolean;
|
||||||
seek?: boolean;
|
seek?: boolean;
|
||||||
playbackRate?: boolean;
|
playbackRate?: boolean;
|
||||||
plusUpload?: boolean;
|
plusUpload?: boolean;
|
||||||
|
snapshot?: boolean;
|
||||||
fullscreen?: boolean;
|
fullscreen?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -48,6 +50,7 @@ const CONTROLS_DEFAULT: VideoControls = {
|
|||||||
seek: true,
|
seek: true,
|
||||||
playbackRate: true,
|
playbackRate: true,
|
||||||
plusUpload: false,
|
plusUpload: false,
|
||||||
|
snapshot: false,
|
||||||
fullscreen: false,
|
fullscreen: false,
|
||||||
};
|
};
|
||||||
const PLAYBACK_RATE_DEFAULT = isSafari ? [0.5, 1, 2] : [0.5, 1, 2, 4, 8, 16];
|
const PLAYBACK_RATE_DEFAULT = isSafari ? [0.5, 1, 2] : [0.5, 1, 2, 4, 8, 16];
|
||||||
@ -71,6 +74,8 @@ type VideoControlsProps = {
|
|||||||
onSeek: (diff: number) => void;
|
onSeek: (diff: number) => void;
|
||||||
onSetPlaybackRate: (rate: number) => void;
|
onSetPlaybackRate: (rate: number) => void;
|
||||||
onUploadFrame?: () => void;
|
onUploadFrame?: () => void;
|
||||||
|
onSnapshot?: () => void;
|
||||||
|
snapshotTitle?: string;
|
||||||
toggleFullscreen?: () => void;
|
toggleFullscreen?: () => void;
|
||||||
containerRef?: React.MutableRefObject<HTMLDivElement | null>;
|
containerRef?: React.MutableRefObject<HTMLDivElement | null>;
|
||||||
};
|
};
|
||||||
@ -92,6 +97,8 @@ export default function VideoControls({
|
|||||||
onSeek,
|
onSeek,
|
||||||
onSetPlaybackRate,
|
onSetPlaybackRate,
|
||||||
onUploadFrame,
|
onUploadFrame,
|
||||||
|
onSnapshot,
|
||||||
|
snapshotTitle,
|
||||||
toggleFullscreen,
|
toggleFullscreen,
|
||||||
containerRef,
|
containerRef,
|
||||||
}: VideoControlsProps) {
|
}: VideoControlsProps) {
|
||||||
@ -292,6 +299,17 @@ export default function VideoControls({
|
|||||||
fullscreen={fullscreen}
|
fullscreen={fullscreen}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
{features.snapshot && onSnapshot && (
|
||||||
|
<TbCameraDown
|
||||||
|
aria-label={snapshotTitle}
|
||||||
|
className="size-5 cursor-pointer"
|
||||||
|
title={snapshotTitle}
|
||||||
|
onClick={(e: React.MouseEvent<SVGElement>) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
onSnapshot();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
{features.fullscreen && toggleFullscreen && (
|
{features.fullscreen && toggleFullscreen && (
|
||||||
<div className="cursor-pointer" onClick={toggleFullscreen}>
|
<div className="cursor-pointer" onClick={toggleFullscreen}>
|
||||||
{fullscreen ? <FaCompress /> : <FaExpand />}
|
{fullscreen ? <FaCompress /> : <FaExpand />}
|
||||||
|
|||||||
@ -119,12 +119,13 @@ export function generateSnapshotFilename(
|
|||||||
return `${cameraName}_snapshot_${safeTimestamp}.jpg`;
|
return `${cameraName}_snapshot_${safeTimestamp}.jpg`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function grabVideoSnapshot(): Promise<SnapshotResult> {
|
export async function grabVideoSnapshot(
|
||||||
|
targetVideo?: HTMLVideoElement | null,
|
||||||
|
): Promise<SnapshotResult> {
|
||||||
try {
|
try {
|
||||||
// Find the video element in the player
|
const videoElement =
|
||||||
const videoElement = document.querySelector(
|
targetVideo ??
|
||||||
"#player-container video",
|
(document.querySelector("#player-container video") as HTMLVideoElement);
|
||||||
) as HTMLVideoElement;
|
|
||||||
|
|
||||||
if (!videoElement) {
|
if (!videoElement) {
|
||||||
return {
|
return {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user