From 074222050a1a55c9ce080668c5d059228a1dbfba Mon Sep 17 00:00:00 2001 From: Alex Kim Date: Sun, 7 Dec 2025 02:22:09 +1100 Subject: [PATCH] Working --- app/(auth)/player/_layout.tsx | 26 +++++++++++++++++ app/(auth)/player/direct-player.tsx | 14 +-------- hooks/useOrientation.ts | 29 ++++++++++--------- .../mpv-player/ios/MPVSoftwareRenderer.swift | 2 ++ modules/mpv-player/ios/MpvPlayerView.swift | 4 +++ 5 files changed, 48 insertions(+), 27 deletions(-) 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 ( <>