From 528b4ad7acdaf5d66dd45e4436cab7b0208797fc Mon Sep 17 00:00:00 2001 From: Fredrik Burmester Date: Sun, 9 Feb 2025 11:45:32 +0100 Subject: [PATCH] fix: orientation in video player and app i general --- app/(auth)/player/_layout.tsx | 22 ++++++++++++++++++++- app/(auth)/player/direct-player.tsx | 16 +++++++-------- app/(auth)/player/transcoding-player.tsx | 5 ++--- app/_layout.tsx | 25 ++++++++++++++---------- 4 files changed, 46 insertions(+), 22 deletions(-) diff --git a/app/(auth)/player/_layout.tsx b/app/(auth)/player/_layout.tsx index 4b0ae1c1..1d6c7188 100644 --- a/app/(auth)/player/_layout.tsx +++ b/app/(auth)/player/_layout.tsx @@ -1,8 +1,28 @@ import { Stack } from "expo-router"; -import React from "react"; +import React, { useEffect } from "react"; import { SystemBars } from "react-native-edge-to-edge"; +import * as ScreenOrientation from "@/packages/expo-screen-orientation"; +import { useSettings } from "@/utils/atoms/settings"; export default function Layout() { + const [settings] = useSettings(); + + useEffect(() => { + if (settings.defaultVideoOrientation) { + ScreenOrientation.lockAsync(settings.defaultVideoOrientation); + } + + return () => { + if (settings.autoRotate === true) { + ScreenOrientation.unlockAsync(); + } else { + ScreenOrientation.lockAsync( + ScreenOrientation.OrientationLock.PORTRAIT_UP + ); + } + }; + }, [settings]); + return ( <>