mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-05-03 06:50:58 +00:00
Compare commits
2 Commits
d27e8c1bbf
...
95cea06dd3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
95cea06dd3 | ||
|
|
ec2543c23f |
@ -1,4 +1,10 @@
|
|||||||
import React, { useState, useRef, useEffect, useCallback } from "react";
|
import React, {
|
||||||
|
useState,
|
||||||
|
useRef,
|
||||||
|
useEffect,
|
||||||
|
useCallback,
|
||||||
|
useMemo,
|
||||||
|
} from "react";
|
||||||
import { useVideoDimensions } from "@/hooks/use-video-dimensions";
|
import { useVideoDimensions } from "@/hooks/use-video-dimensions";
|
||||||
import HlsVideoPlayer from "./HlsVideoPlayer";
|
import HlsVideoPlayer from "./HlsVideoPlayer";
|
||||||
import ActivityIndicator from "../indicators/activity-indicator";
|
import ActivityIndicator from "../indicators/activity-indicator";
|
||||||
@ -89,6 +95,12 @@ export function GenericVideoPlayer({
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const hlsSource = useMemo(() => {
|
||||||
|
return {
|
||||||
|
playlist: source,
|
||||||
|
};
|
||||||
|
}, [source]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div ref={containerRef} className="relative flex h-full w-full flex-col">
|
<div ref={containerRef} className="relative flex h-full w-full flex-col">
|
||||||
<div className="relative flex flex-grow items-center justify-center">
|
<div className="relative flex flex-grow items-center justify-center">
|
||||||
@ -107,9 +119,7 @@ export function GenericVideoPlayer({
|
|||||||
>
|
>
|
||||||
<HlsVideoPlayer
|
<HlsVideoPlayer
|
||||||
videoRef={videoRef}
|
videoRef={videoRef}
|
||||||
currentSource={{
|
currentSource={hlsSource}
|
||||||
playlist: source,
|
|
||||||
}}
|
|
||||||
hotKeys
|
hotKeys
|
||||||
visible
|
visible
|
||||||
frigateControls={false}
|
frigateControls={false}
|
||||||
|
|||||||
@ -17,7 +17,7 @@ export function useVideoDimensions(
|
|||||||
});
|
});
|
||||||
|
|
||||||
const videoAspectRatio = useMemo(() => {
|
const videoAspectRatio = useMemo(() => {
|
||||||
return videoResolution.width / videoResolution.height;
|
return videoResolution.width / videoResolution.height || 16 / 9;
|
||||||
}, [videoResolution]);
|
}, [videoResolution]);
|
||||||
|
|
||||||
const containerAspectRatio = useMemo(() => {
|
const containerAspectRatio = useMemo(() => {
|
||||||
@ -25,7 +25,7 @@ export function useVideoDimensions(
|
|||||||
}, [containerWidth, containerHeight]);
|
}, [containerWidth, containerHeight]);
|
||||||
|
|
||||||
const videoDimensions = useMemo(() => {
|
const videoDimensions = useMemo(() => {
|
||||||
if (!containerWidth || !containerHeight || !videoAspectRatio)
|
if (!containerWidth || !containerHeight)
|
||||||
return { width: "100%", height: "100%" };
|
return { width: "100%", height: "100%" };
|
||||||
if (containerAspectRatio > videoAspectRatio) {
|
if (containerAspectRatio > videoAspectRatio) {
|
||||||
const height = containerHeight;
|
const height = containerHeight;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user