forked from Github/frigate
See a preview when using the timeline to export footage (#14321)
* custom hook and generic video player component * add export preview dialog * export preview dialog when using timeline export * refactor search detail dialog to use new generic video player component * clean up
This commit is contained in:
52
web/src/components/player/GenericVideoPlayer.tsx
Normal file
52
web/src/components/player/GenericVideoPlayer.tsx
Normal file
@@ -0,0 +1,52 @@
|
||||
import React, { useState, useRef } from "react";
|
||||
import { useVideoDimensions } from "@/hooks/use-video-dimensions";
|
||||
import HlsVideoPlayer from "./HlsVideoPlayer";
|
||||
import ActivityIndicator from "../indicators/activity-indicator";
|
||||
|
||||
type GenericVideoPlayerProps = {
|
||||
source: string;
|
||||
onPlaying?: () => void;
|
||||
children?: React.ReactNode;
|
||||
};
|
||||
|
||||
export function GenericVideoPlayer({
|
||||
source,
|
||||
onPlaying,
|
||||
children,
|
||||
}: GenericVideoPlayerProps) {
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const videoRef = useRef<HTMLVideoElement | null>(null);
|
||||
const containerRef = useRef<HTMLDivElement | null>(null);
|
||||
const { videoDimensions, setVideoResolution } =
|
||||
useVideoDimensions(containerRef);
|
||||
|
||||
return (
|
||||
<div ref={containerRef} className="relative flex h-full w-full flex-col">
|
||||
<div className="relative flex flex-grow items-center justify-center">
|
||||
{isLoading && (
|
||||
<ActivityIndicator className="absolute left-1/2 top-1/2 z-10 -translate-x-1/2 -translate-y-1/2" />
|
||||
)}
|
||||
<div
|
||||
className="relative flex items-center justify-center"
|
||||
style={videoDimensions}
|
||||
>
|
||||
<HlsVideoPlayer
|
||||
videoRef={videoRef}
|
||||
currentSource={source}
|
||||
hotKeys
|
||||
visible
|
||||
frigateControls={false}
|
||||
fullscreen={false}
|
||||
supportsFullscreen={false}
|
||||
onPlaying={() => {
|
||||
setIsLoading(false);
|
||||
onPlaying?.();
|
||||
}}
|
||||
setFullResolution={setVideoResolution}
|
||||
/>
|
||||
{!isLoading && children}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user