diff --git a/app/(auth)/player/_layout.tsx b/app/(auth)/player/_layout.tsx index 97a3f7eb..5604160e 100644 --- a/app/(auth)/player/_layout.tsx +++ b/app/(auth)/player/_layout.tsx @@ -1,7 +1,33 @@ import { Stack } from "expo-router"; +import { useEffect } from "react"; +import { AppState } from "react-native"; import { SystemBars } from "react-native-edge-to-edge"; +import { useOrientation } from "@/hooks/useOrientation"; +import { useSettings } from "@/utils/atoms/settings"; + export default function Layout() { + const { settings } = useSettings(); + const { lockOrientation, unlockOrientation } = useOrientation(); + + useEffect(() => { + if (settings?.defaultVideoOrientation) { + lockOrientation(settings.defaultVideoOrientation); + } + + // Re-apply orientation lock when app returns to foreground (iOS resets it) + const subscription = AppState.addEventListener("change", (nextAppState) => { + if (nextAppState === "active" && settings?.defaultVideoOrientation) { + lockOrientation(settings.defaultVideoOrientation); + } + }); + + return () => { + subscription.remove(); + unlockOrientation(); + }; + }, [settings?.defaultVideoOrientation, lockOrientation, unlockOrientation]); + return ( <>