mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-04-05 14:47: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 ObjectTrackOverlay from "@/components/overlay/ObjectTrackOverlay";
|
||||
import { useIsAdmin } from "@/hooks/use-is-admin";
|
||||
import {
|
||||
downloadSnapshot,
|
||||
generateSnapshotFilename,
|
||||
grabVideoSnapshot,
|
||||
} from "@/utils/snapshotUtil";
|
||||
|
||||
// Android native hls does not seek correctly
|
||||
const USE_NATIVE_HLS = false;
|
||||
@ -89,7 +94,7 @@ export default function HlsVideoPlayer({
|
||||
currentTimeOverride,
|
||||
transformedOverlay,
|
||||
}: HlsVideoPlayerProps) {
|
||||
const { t } = useTranslation("components/player");
|
||||
const { t } = useTranslation(["components/player", "views/live"]);
|
||||
const { data: config } = useSWR<FrigateConfig>("config");
|
||||
const isAdmin = useIsAdmin();
|
||||
|
||||
@ -317,6 +322,7 @@ export default function HlsVideoPlayer({
|
||||
seek: true,
|
||||
playbackRate: true,
|
||||
plusUpload: isAdmin && config?.plus?.enabled == true,
|
||||
snapshot: true,
|
||||
fullscreen: supportsFullscreen,
|
||||
}}
|
||||
setControlsOpen={setControlsOpen}
|
||||
|
||||
@ -34,12 +34,14 @@ import {
|
||||
import { cn } from "@/lib/utils";
|
||||
import { FaCompress, FaExpand } from "react-icons/fa";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { TbCameraDown } from "react-icons/tb";
|
||||
|
||||
type VideoControls = {
|
||||
volume?: boolean;
|
||||
seek?: boolean;
|
||||
playbackRate?: boolean;
|
||||
plusUpload?: boolean;
|
||||
snapshot?: boolean;
|
||||
fullscreen?: boolean;
|
||||
};
|
||||
|
||||
@ -48,6 +50,7 @@ const CONTROLS_DEFAULT: VideoControls = {
|
||||
seek: true,
|
||||
playbackRate: true,
|
||||
plusUpload: false,
|
||||
snapshot: false,
|
||||
fullscreen: false,
|
||||
};
|
||||
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;
|
||||
onSetPlaybackRate: (rate: number) => void;
|
||||
onUploadFrame?: () => void;
|
||||
onSnapshot?: () => void;
|
||||
snapshotTitle?: string;
|
||||
toggleFullscreen?: () => void;
|
||||
containerRef?: React.MutableRefObject<HTMLDivElement | null>;
|
||||
};
|
||||
@ -92,6 +97,8 @@ export default function VideoControls({
|
||||
onSeek,
|
||||
onSetPlaybackRate,
|
||||
onUploadFrame,
|
||||
onSnapshot,
|
||||
snapshotTitle,
|
||||
toggleFullscreen,
|
||||
containerRef,
|
||||
}: VideoControlsProps) {
|
||||
@ -292,6 +299,17 @@ export default function VideoControls({
|
||||
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 && (
|
||||
<div className="cursor-pointer" onClick={toggleFullscreen}>
|
||||
{fullscreen ? <FaCompress /> : <FaExpand />}
|
||||
|
||||
@ -119,12 +119,13 @@ export function generateSnapshotFilename(
|
||||
return `${cameraName}_snapshot_${safeTimestamp}.jpg`;
|
||||
}
|
||||
|
||||
export async function grabVideoSnapshot(): Promise<SnapshotResult> {
|
||||
export async function grabVideoSnapshot(
|
||||
targetVideo?: HTMLVideoElement | null,
|
||||
): Promise<SnapshotResult> {
|
||||
try {
|
||||
// Find the video element in the player
|
||||
const videoElement = document.querySelector(
|
||||
"#player-container video",
|
||||
) as HTMLVideoElement;
|
||||
const videoElement =
|
||||
targetVideo ??
|
||||
(document.querySelector("#player-container video") as HTMLVideoElement);
|
||||
|
||||
if (!videoElement) {
|
||||
return {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user