mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-07-26 13:47:03 +02:00
Orient live camera feed for best screen fit when in fullscreen mode (#16947)
* Change orientation in fullscreen to best fit video * Refactor effect to simplify, add more comments
This commit is contained in:
parent
c23653338f
commit
389c707ad2
@ -362,6 +362,28 @@ export default function LiveCameraView({
|
|||||||
}
|
}
|
||||||
}, [fullscreen, isPortrait, cameraAspectRatio, containerAspectRatio]);
|
}, [fullscreen, isPortrait, cameraAspectRatio, containerAspectRatio]);
|
||||||
|
|
||||||
|
// On mobile devices that support it, try to orient screen
|
||||||
|
// to best fit the camera feed in fullscreen mode
|
||||||
|
useEffect(() => {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
const screenOrientation = screen.orientation as any;
|
||||||
|
if (!screenOrientation.lock || !screenOrientation.unlock) {
|
||||||
|
// Browser does not support ScreenOrientation APIs that we need
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fullscreen) {
|
||||||
|
const orientationForBestFit =
|
||||||
|
cameraAspectRatio > 1 ? "landscape" : "portrait";
|
||||||
|
|
||||||
|
// If the current device doesn't support locking orientation,
|
||||||
|
// this promise will reject with an error that we can ignore
|
||||||
|
screenOrientation.lock(orientationForBestFit).catch(() => {});
|
||||||
|
}
|
||||||
|
|
||||||
|
return () => screenOrientation.unlock();
|
||||||
|
}, [fullscreen, cameraAspectRatio]);
|
||||||
|
|
||||||
const handleError = useCallback(
|
const handleError = useCallback(
|
||||||
(e: LivePlayerError) => {
|
(e: LivePlayerError) => {
|
||||||
if (e) {
|
if (e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user