From e9659ee3057ff74e9c10ac2eef0fcbfe480833bf Mon Sep 17 00:00:00 2001 From: tapframe Date: Thu, 25 Sep 2025 23:00:07 +0530 Subject: [PATCH] auto lock player fix --- ios/Nuvio.xcodeproj/project.pbxproj | 14 ++++----- src/components/player/AndroidVideoPlayer.tsx | 32 ++++++++++++++++++++ 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/ios/Nuvio.xcodeproj/project.pbxproj b/ios/Nuvio.xcodeproj/project.pbxproj index fe4dddd..4cc21bd 100644 --- a/ios/Nuvio.xcodeproj/project.pbxproj +++ b/ios/Nuvio.xcodeproj/project.pbxproj @@ -174,8 +174,8 @@ LastUpgradeCheck = 1130; TargetAttributes = { 13B07F861A680F5B00A75B9A = { + DevelopmentTeam = NLXTHANK2N; LastSwiftMigration = 1250; - DevelopmentTeam = "NLXTHANK2N"; ProvisioningStyle = Automatic; }; }; @@ -389,7 +389,10 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Nuvio/Nuvio.entitlements; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = NLXTHANK2N; ENABLE_BITCODE = NO; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", @@ -412,9 +415,6 @@ SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; - DEVELOPMENT_TEAM = "NLXTHANK2N"; - CODE_SIGN_IDENTITY = "Apple Development"; - CODE_SIGN_STYLE = Automatic; }; name = Debug; }; @@ -425,7 +425,10 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Nuvio/Nuvio.entitlements; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = NLXTHANK2N; INFOPLIST_FILE = Nuvio/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 15.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -442,9 +445,6 @@ SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; - DEVELOPMENT_TEAM = "NLXTHANK2N"; - CODE_SIGN_IDENTITY = "Apple Development"; - CODE_SIGN_STYLE = Automatic; }; name = Release; }; diff --git a/src/components/player/AndroidVideoPlayer.tsx b/src/components/player/AndroidVideoPlayer.tsx index ee24732..8be1d95 100644 --- a/src/components/player/AndroidVideoPlayer.tsx +++ b/src/components/player/AndroidVideoPlayer.tsx @@ -1833,6 +1833,38 @@ const AndroidVideoPlayer: React.FC = () => { } } }; + + // Keep screen awake during active playback (Android) + const keepAwakeModuleRef = useRef(null); + useEffect(() => { + try { + // Use require to avoid TS dynamic import constraints + // If the module is unavailable, catch and ignore + // eslint-disable-next-line @typescript-eslint/no-var-requires + const mod = require('expo-keep-awake'); + keepAwakeModuleRef.current = mod; + } catch (_e) { + keepAwakeModuleRef.current = null; + } + }, []); + + // Toggle keep-awake based on playback state + useEffect(() => { + const mod = keepAwakeModuleRef.current; + if (!mod) return; + const activate = mod.activateKeepAwakeAsync || mod.activateKeepAwake; + const deactivate = mod.deactivateKeepAwakeAsync || mod.deactivateKeepAwake; + try { + if (!paused && isPlayerReady && duration > 0) { + activate && activate(); + } else { + deactivate && deactivate(); + } + } catch (_e) {} + return () => { + try { deactivate && deactivate(); } catch (_e) {} + }; + }, [paused, isPlayerReady, duration]); const handleErrorExit = () => { try {