diff --git a/SwiftProject/Pods/Pods.xcodeproj/project.pbxproj b/SwiftProject/Pods/Pods.xcodeproj/project.pbxproj index 8421bb2..f3cde94 100644 --- a/SwiftProject/Pods/Pods.xcodeproj/project.pbxproj +++ b/SwiftProject/Pods/Pods.xcodeproj/project.pbxproj @@ -6401,6 +6401,10 @@ DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; GCC_PREFIX_HEADER = "Target Support Files/SVProgressHUD/SVProgressHUD-prefix.pch"; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + "COCOAPODS=1", + ); INFOPLIST_FILE = "Target Support Files/SVProgressHUD/SVProgressHUD-Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 13.0; @@ -7461,6 +7465,10 @@ DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; GCC_PREFIX_HEADER = "Target Support Files/SVProgressHUD/SVProgressHUD-prefix.pch"; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + "COCOAPODS=1", + ); INFOPLIST_FILE = "Target Support Files/SVProgressHUD/SVProgressHUD-Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 13.0; diff --git a/SwiftProject/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.m b/SwiftProject/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.m index 2b66992..f8ddc8f 100644 --- a/SwiftProject/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.m +++ b/SwiftProject/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.m @@ -635,7 +635,8 @@ static const CGFloat SVProgressHUDLabelSpacing = 8.0f; double animationDuration = 0.0; #if !defined(SV_APP_EXTENSIONS) && TARGET_OS_IOS - self.frame = [[[UIApplication sharedApplication] delegate] window].bounds; +// self.frame = [[[UIApplication sharedApplication] delegate] window].bounds; + self.frame = [UIApplication sharedApplication].keyWindow.bounds; UIInterfaceOrientation orientation = UIApplication.sharedApplication.statusBarOrientation; #elif !defined(SV_APP_EXTENSIONS) && !TARGET_OS_IOS self.frame= [UIApplication sharedApplication].keyWindow.bounds; diff --git a/SwiftProject/SwiftProject.xcodeproj/project.pbxproj b/SwiftProject/SwiftProject.xcodeproj/project.pbxproj index a379674..98d08e1 100644 --- a/SwiftProject/SwiftProject.xcodeproj/project.pbxproj +++ b/SwiftProject/SwiftProject.xcodeproj/project.pbxproj @@ -12,6 +12,10 @@ 009661F82BAD6C7100FCA65F /* CCSpaceAlbumFilterPopView2.swift in Sources */ = {isa = PBXBuildFile; fileRef = 009661F72BAD6C7100FCA65F /* CCSpaceAlbumFilterPopView2.swift */; }; 009661FA2BAD876200FCA65F /* PhotosUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 009661F92BAD876200FCA65F /* PhotosUI.framework */; }; 009661FC2BADB20D00FCA65F /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 009661FB2BADB20D00FCA65F /* CoreMotion.framework */; }; + 009662442BB2B93C00FCA65F /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 009662432BB2B93C00FCA65F /* SceneDelegate.swift */; }; + 009662462BB3B39900FCA65F /* External.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 009662452BB3B39900FCA65F /* External.storyboard */; }; + 0096624A2BB3B45200FCA65F /* ExternalSceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 009662492BB3B45200FCA65F /* ExternalSceneDelegate.swift */; }; + 0096624D2BB3BA3B00FCA65F /* ZZHExternalViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0096624C2BB3BA3B00FCA65F /* ZZHExternalViewController.swift */; }; 00B946232B67B26D00DA668F /* ddd_video.mp4 in Resources */ = {isa = PBXBuildFile; fileRef = 00B946222B67B26D00DA668F /* ddd_video.mp4 */; }; 00B946252B67B7DE00DA668F /* CCSpatialPlayView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00B946242B67B7DE00DA668F /* CCSpatialPlayView.swift */; }; 00C665732BAA81F900C309C3 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 00C665722BAA81F900C309C3 /* GoogleService-Info.plist */; }; @@ -102,6 +106,10 @@ 009661F72BAD6C7100FCA65F /* CCSpaceAlbumFilterPopView2.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CCSpaceAlbumFilterPopView2.swift; sourceTree = ""; }; 009661F92BAD876200FCA65F /* PhotosUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PhotosUI.framework; path = System/Library/Frameworks/PhotosUI.framework; sourceTree = SDKROOT; }; 009661FB2BADB20D00FCA65F /* CoreMotion.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMotion.framework; path = System/Library/Frameworks/CoreMotion.framework; sourceTree = SDKROOT; }; + 009662432BB2B93C00FCA65F /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; + 009662452BB3B39900FCA65F /* External.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = External.storyboard; sourceTree = ""; }; + 009662492BB3B45200FCA65F /* ExternalSceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExternalSceneDelegate.swift; sourceTree = ""; }; + 0096624C2BB3BA3B00FCA65F /* ZZHExternalViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZZHExternalViewController.swift; sourceTree = ""; }; 00B946222B67B26D00DA668F /* ddd_video.mp4 */ = {isa = PBXFileReference; lastKnownFileType = file; path = ddd_video.mp4; sourceTree = ""; }; 00B946242B67B7DE00DA668F /* CCSpatialPlayView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CCSpatialPlayView.swift; sourceTree = ""; }; 00C665722BAA81F900C309C3 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; @@ -209,6 +217,16 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 0096624B2BB3BA0100FCA65F /* ExternalScreen */ = { + isa = PBXGroup; + children = ( + 009662452BB3B39900FCA65F /* External.storyboard */, + 009662492BB3B45200FCA65F /* ExternalSceneDelegate.swift */, + 0096624C2BB3BA3B00FCA65F /* ZZHExternalViewController.swift */, + ); + path = ExternalScreen; + sourceTree = ""; + }; 1E02C9302B89909000DD3143 /* DeviceOperation */ = { isa = PBXGroup; children = ( @@ -359,6 +377,8 @@ AF2120A12B4E83AF00400B7F /* CCKit */, AF2120A62B4E83B000400B7F /* Project */, AF21208D2B4E7F1A00400B7F /* AppDelegate.swift */, + 0096624B2BB3BA0100FCA65F /* ExternalScreen */, + 009662432BB2B93C00FCA65F /* SceneDelegate.swift */, 00C665772BAA941E00C309C3 /* CopyCrashHandler.swift */, AF2120932B4E7F1A00400B7F /* Main.storyboard */, AF2120962B4E7F1C00400B7F /* Assets.xcassets */, @@ -577,6 +597,7 @@ AF2120972B4E7F1C00400B7F /* Assets.xcassets in Resources */, 00B946232B67B26D00DA668F /* ddd_video.mp4 in Resources */, AF2120952B4E7F1A00400B7F /* Main.storyboard in Resources */, + 009662462BB3B39900FCA65F /* External.storyboard in Resources */, 00C665732BAA81F900C309C3 /* GoogleService-Info.plist in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -640,6 +661,7 @@ 00C665792BAA94EA00C309C3 /* CopyCrashHandler.swift in Sources */, AF2120AD2B4E92B000400B7F /* RootTabBarController.swift in Sources */, 00B946252B67B7DE00DA668F /* CCSpatialPlayView.swift in Sources */, + 0096624A2BB3B45200FCA65F /* ExternalSceneDelegate.swift in Sources */, AFD9F5932B58C34A008716DE /* ImageProcessingShaders.metal in Sources */, AF2120F02B4EA39D00400B7F /* BaseTableViewGroupedController.swift in Sources */, 1E1EA2962B936C9600A5D5D2 /* VideoConvertor2.swift in Sources */, @@ -677,6 +699,7 @@ AF2120C82B4E95DA00400B7F /* NSString+Add.swift in Sources */, 1E1EA2902B933C8200A5D5D2 /* VideoWriter.swift in Sources */, AF2120E62B4E9DE000400B7F /* CCTableSwitchView.swift in Sources */, + 0096624D2BB3BA3B00FCA65F /* ZZHExternalViewController.swift in Sources */, 00D33BFA2B9AB21A00604A44 /* ZZHAVExtension.swift in Sources */, 009661F82BAD6C7100FCA65F /* CCSpaceAlbumFilterPopView2.swift in Sources */, AF2120E02B4E9C8000400B7F /* Timer+Add.swift in Sources */, @@ -691,6 +714,7 @@ AF2120D22B4E99E600400B7F /* CCAddImage.swift in Sources */, AF2120E42B4E9D5A00400B7F /* CCSMSView.swift in Sources */, 1E1EA28E2B93393A00A5D5D2 /* UIButton+CCExtension.swift in Sources */, + 009662442BB2B93C00FCA65F /* SceneDelegate.swift in Sources */, AF2120AB2B4E848400400B7F /* RootNavigationController.swift in Sources */, AF2120C92B4E95DA00400B7F /* UIDevice+Add.swift in Sources */, AF2120AF2B4E930400400B7F /* RootManager.swift in Sources */, @@ -863,6 +887,14 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1.0; DEVELOPMENT_TEAM = 8DQD6BV6H9; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + "COCOAPODS=1", + "$(inherited)", + "PB_FIELD_32BIT=1", + "PB_NO_PACKED_STRUCTS=1", + "PB_ENABLE_MALLOC=1", + ); GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = SwiftProject/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = VPCamera; @@ -881,6 +913,8 @@ "@executable_path/Frameworks", ); MARKETING_VERSION = 1.1; + OTHER_CFLAGS = ""; + OTHER_SWIFT_FLAGS = "$(inherited) -D COCOAPODS"; PRODUCT_BUNDLE_IDENTIFIER = com.nsk.tdvideo; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -904,6 +938,14 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1.0; DEVELOPMENT_TEAM = 8DQD6BV6H9; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + "COCOAPODS=1", + "$(inherited)", + "PB_FIELD_32BIT=1", + "PB_NO_PACKED_STRUCTS=1", + "PB_ENABLE_MALLOC=1", + ); GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = SwiftProject/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = VPCamera; @@ -922,6 +964,8 @@ "@executable_path/Frameworks", ); MARKETING_VERSION = 1.1; + OTHER_CFLAGS = ""; + OTHER_SWIFT_FLAGS = "$(inherited) -D COCOAPODS"; PRODUCT_BUNDLE_IDENTIFIER = com.nsk.tdvideo; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/SwiftProject/SwiftProject.xcworkspace/xcuserdata/aaa.xcuserdatad/UserInterfaceState.xcuserstate b/SwiftProject/SwiftProject.xcworkspace/xcuserdata/aaa.xcuserdatad/UserInterfaceState.xcuserstate index d760806..e101380 100644 Binary files a/SwiftProject/SwiftProject.xcworkspace/xcuserdata/aaa.xcuserdatad/UserInterfaceState.xcuserstate and b/SwiftProject/SwiftProject.xcworkspace/xcuserdata/aaa.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/SwiftProject/SwiftProject.xcworkspace/xcuserdata/aaa.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/SwiftProject/SwiftProject.xcworkspace/xcuserdata/aaa.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index ed09ad4..b35b1ca 100644 --- a/SwiftProject/SwiftProject.xcworkspace/xcuserdata/aaa.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/SwiftProject/SwiftProject.xcworkspace/xcuserdata/aaa.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -217,300 +217,6 @@ stopOnStyle = "0"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SwiftProject/SwiftProject/AppDelegate.swift b/SwiftProject/SwiftProject/AppDelegate.swift index a941f7e..9e1d283 100644 --- a/SwiftProject/SwiftProject/AppDelegate.swift +++ b/SwiftProject/SwiftProject/AppDelegate.swift @@ -18,11 +18,13 @@ import UIKit import SVProgressHUD import Firebase @main + + class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - var root:RootManager? - +// var root:RootManager? + var newWindow:UIWindow? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { Task { FirebaseApp.configure() @@ -30,10 +32,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate { SVProgressHUD.setDefaultStyle(.dark) - self.window = UIWindow(frame: UIScreen.main.bounds) - self.window?.backgroundColor = UIColor.white - self.window?.makeKeyAndVisible() - self.window?.rootViewController = RootTabBarController() +// self.window = UIWindow(frame: UIScreen.main.bounds) +// self.window?.backgroundColor = UIColor.white +// self.window?.makeKeyAndVisible() + Analytics.logEvent("user_launch", parameters: ["type":"new"]) exceptionLogWithData() @@ -63,6 +65,25 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func applicationWillTerminate(_ application: UIApplication) { } + +// func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { +// print("configurationForConnecting....") +// let scene = UIWindowScene(session: connectingSceneSession, connectionOptions: options) +// +// // Configure a window for the screen. +// self.newWindow = UIWindow(frame: CGRect(x: 0, y: 0, width: 2000, height: 1000)) +// self.newWindow!.backgroundColor = UIColor.yellow +// // Install a custom root view controller in the window. +// +// let viewController = UIViewController() +// self.newWindow!.rootViewController = viewController +// self.newWindow!.windowScene = scene +// +// // You must show the window explicitly. +// self.newWindow!.isHidden = false +// NotificationCenter.default.post(name: Notification.Name(rawValue: "NSZZHHasNewWindowExternal"), object: self, userInfo: ["newwindow":self.newWindow!]) +// return UISceneConfiguration(name: "External configuration", sessionRole: connectingSceneSession.role) +// } } diff --git a/SwiftProject/SwiftProject/Assets.xcassets/externalScreenBg.imageset/Contents.json b/SwiftProject/SwiftProject/Assets.xcassets/externalScreenBg.imageset/Contents.json new file mode 100644 index 0000000..573638a --- /dev/null +++ b/SwiftProject/SwiftProject/Assets.xcassets/externalScreenBg.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "编组 6.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "编组 5.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/SwiftProject/SwiftProject/Assets.xcassets/externalScreenBg.imageset/编组 5.png b/SwiftProject/SwiftProject/Assets.xcassets/externalScreenBg.imageset/编组 5.png new file mode 100644 index 0000000..bda1291 Binary files /dev/null and b/SwiftProject/SwiftProject/Assets.xcassets/externalScreenBg.imageset/编组 5.png differ diff --git a/SwiftProject/SwiftProject/Assets.xcassets/externalScreenBg.imageset/编组 6.png b/SwiftProject/SwiftProject/Assets.xcassets/externalScreenBg.imageset/编组 6.png new file mode 100644 index 0000000..bda1291 Binary files /dev/null and b/SwiftProject/SwiftProject/Assets.xcassets/externalScreenBg.imageset/编组 6.png differ diff --git a/SwiftProject/SwiftProject/CCKit/Config/CCCommonFile.swift b/SwiftProject/SwiftProject/CCKit/Config/CCCommonFile.swift index d6a7eaf..03f2696 100644 --- a/SwiftProject/SwiftProject/CCKit/Config/CCCommonFile.swift +++ b/SwiftProject/SwiftProject/CCKit/Config/CCCommonFile.swift @@ -56,11 +56,37 @@ let KInvite_Cell_orginal_Height:CGFloat = KHZSize(100) ///1. 获得当前窗口 var KWindow: UIWindow? { get{ - if let app = UIApplication.shared.delegate as? AppDelegate { - return app.window + var window:UIWindow? = nil + UIApplication.shared.connectedScenes.forEach { us in + if let uws = us as? UIWindowScene , uws.session.role.rawValue == "UIWindowSceneSessionRoleApplication" { + window = uws.windows.first + } } - return nil + return window + +// if let windowsScene = UIApplication.shared.connectedScenes.first as? UIWindowScene { +// return windowsScene.windows.first +// } +// else { +// return nil +// } +// if let app = UIApplication.shared.delegate as? AppDelegate { +// return app.window +// } +// return nil } + +// if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene, +// let firstWindow = windowScene.windows.first{ +// if let delegate = windowScene.delegate as? UIWindowSceneDelegate, +// let window = delegate.window as? UIWindow{ +// print(firstWindow) +// print(window) +// } +// if let key = windowScene.keyWindow{ +// print(key) +// } +// } } var KAppDelegate: AppDelegate? { diff --git a/SwiftProject/SwiftProject/CCKit/Kit/CCAlert.swift b/SwiftProject/SwiftProject/CCKit/Kit/CCAlert.swift index 1675f88..371fe90 100644 --- a/SwiftProject/SwiftProject/CCKit/Kit/CCAlert.swift +++ b/SwiftProject/SwiftProject/CCKit/Kit/CCAlert.swift @@ -30,7 +30,7 @@ class CCAlert: NSObject { cancelAction.setValue(TitleColor, forKey: "_titleTextColor") alert.addAction(cancelAction) } - let controller:UIViewController = AppDelegate.sharedAppDelegate().window!.rootViewController! + let controller:UIViewController = KWindow!.rootViewController! controller.present(alert, animated: true, completion: nil) } diff --git a/SwiftProject/SwiftProject/ExternalScreen/External.storyboard b/SwiftProject/SwiftProject/ExternalScreen/External.storyboard new file mode 100644 index 0000000..3549c1b --- /dev/null +++ b/SwiftProject/SwiftProject/ExternalScreen/External.storyboard @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SwiftProject/SwiftProject/ExternalScreen/ExternalSceneDelegate.swift b/SwiftProject/SwiftProject/ExternalScreen/ExternalSceneDelegate.swift new file mode 100644 index 0000000..3c8a5e4 --- /dev/null +++ b/SwiftProject/SwiftProject/ExternalScreen/ExternalSceneDelegate.swift @@ -0,0 +1,68 @@ +// +// SceneDelegate.swift +// KeybaordTest +// +// Created by aaa on 2024/3/18. +// + +import UIKit + +class ExternalSceneDelegate: UIResponder, UIWindowSceneDelegate { + + var window: UIWindow? + + + func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { + print("ExternalSceneDelegate scene.......") + +// self.window?.rootViewController = ZZHExternalViewController() +// guard let _ = (scene as? UIWindowScene) else { return } +// guard let rootViewController = window?.rootViewController else { +// return +// } + + } + + func sceneDidDisconnect(_ scene: UIScene) { + // Called as the scene is being released by the system. + // This occurs shortly after the scene enters the background, or when its session is discarded. + // Release any resources associated with this scene that can be re-created the next time the scene connects. + // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). + print("ExternalSceneDelegate sceneDidDisconnect") + } + + func sceneDidBecomeActive(_ scene: UIScene) { + // Called when the scene has moved from an inactive state to an active state. + // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. + print("ExternalSceneDelegate sceneDidBecomeActive") + } + + func sceneWillResignActive(_ scene: UIScene) { + // Called when the scene will move from an active state to an inactive state. + // This may occur due to temporary interruptions (ex. an incoming phone call). + print("ExternalSceneDelegate sceneWillResignActive") + } + + func sceneWillEnterForeground(_ scene: UIScene) { + // Called as the scene transitions from the background to the foreground. + // Use this method to undo the changes made on entering the background. + print("ExternalSceneDelegate sceneWillEnterForeground") +// DispatchQueue.main.async { +// NotificationCenter.default.post(name: Notification.Name(rawValue: "NSZZHHasNewWindowExternal"), object: self, userInfo: nil) +// print("已发送 NSZZHHasNewWindowExternal 通知。。。。") +// } + + + } + + func sceneDidEnterBackground(_ scene: UIScene) { + // Called as the scene transitions from the foreground to the background. + // Use this method to save data, release shared resources, and store enough scene-specific state information + // to restore the scene back to its current state. + + print("ExternalSceneDelegate sceneDidEnterBackground") + } + + +} + diff --git a/SwiftProject/SwiftProject/ExternalScreen/ZZHExternalViewController.swift b/SwiftProject/SwiftProject/ExternalScreen/ZZHExternalViewController.swift new file mode 100644 index 0000000..508ff62 --- /dev/null +++ b/SwiftProject/SwiftProject/ExternalScreen/ZZHExternalViewController.swift @@ -0,0 +1,26 @@ +// +// ZZHExternalViewController.swift +// SwiftProject +// +// Created by aaa on 2024/3/27. +// + +import Foundation +import UIKit +class ZZHExternalViewController: UIViewController { + + var imageView: UIImageView? + + override func viewDidLoad() { + super.viewDidLoad() + print("ZZHExternalViewController viewDidLoad..") + imageView = UIImageView() + imageView?.image = UIImage(named: "externalScreenBg") + imageView?.contentMode = .scaleAspectFill + self.view .addSubview(imageView!) + imageView?.snp.makeConstraints({ make in + make.left.top.right.bottom.equalTo(0) + }) + + } +} diff --git a/SwiftProject/SwiftProject/Info.plist b/SwiftProject/SwiftProject/Info.plist index 5347efe..cfb9a95 100644 --- a/SwiftProject/SwiftProject/Info.plist +++ b/SwiftProject/SwiftProject/Info.plist @@ -9,5 +9,35 @@ NSAllowsArbitraryLoads + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + UISceneStoryboardFile + Main + + + UIWindowSceneSessionRoleExternalDisplay + + + UISceneConfigurationName + External + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).ExternalSceneDelegate + UISceneStoryboardFile + External + + + + diff --git a/SwiftProject/SwiftProject/Project/Controller/RecordingVideo/CCSpatialPhotoDisplayController.swift b/SwiftProject/SwiftProject/Project/Controller/RecordingVideo/CCSpatialPhotoDisplayController.swift index 3b9b88f..e3ad24f 100644 --- a/SwiftProject/SwiftProject/Project/Controller/RecordingVideo/CCSpatialPhotoDisplayController.swift +++ b/SwiftProject/SwiftProject/Project/Controller/RecordingVideo/CCSpatialPhotoDisplayController.swift @@ -23,10 +23,12 @@ enum VideoReaderError : Error { class CCSpatialPhotoDisplayController: BaseController { let kNowTimeToUserDefaultKey_PhotoDisplayController:String = "kNowTimeToUserDefaultKey_PhotoDisplayController" //保留外联屏幕 - lazy var externalWindow:UIWindow = { - return UIWindow(frame: self.view.bounds) - }() +// lazy var externalWindow:UIWindow = { +// return UIWindow(frame: self.view.bounds) +// }() + var externalVC:ZZHExternalViewController? + var externalDispalylink:CADisplayLink? var externalImageView:UIImageView? // var player:AVPlayer = AVPlayer() @@ -148,17 +150,20 @@ class CCSpatialPhotoDisplayController: BaseController { NotificationCenter.default.removeObserver(self) } + + override func viewDidLoad() { super.viewDidLoad() ZZHHelper.setNowTimeToUserDefaultWithKey(kNowTimeToUserDefaultKey_PhotoDisplayController) print("spatioal photo viewdidload...\(self)") // return //添加外接屏幕链接通知 -// NotificationCenter.default.addObserver(self, selector: #selector(exScreenWillConnectNotification(notification:)), name: UIScene.willConnectNotification, object: nil) -// NotificationCenter.default.addObserver(self, selector: #selector(exScreenDisConnectNotification(notification:)), name: UIScene.didDisconnectNotification, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(exScreenWillConnectNotification(notification:)), name: UIScene.willConnectNotification, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(exScreenDisConnectNotification(notification:)), name: UIScene.didDisconnectNotification, object: nil) + // 监听 AirPlay 设备的连接状态 - NotificationCenter.default.addObserver(self, selector: #selector(airPlayStatusDidChange(notification:)), name: AVAudioSession.routeChangeNotification, object: nil) +// NotificationCenter.default.addObserver(self, selector: #selector(airPlayStatusDidChange(notification:)), name: AVAudioSession.routeChangeNotification, object: nil) self.view.backgroundColor = UIColor(hexString: "#060507") outputVideoURL = URL.documentsDirectory.appending(path:"output11114.jpg") @@ -169,7 +174,7 @@ class CCSpatialPhotoDisplayController: BaseController { imgData = originalData //展示 - var image = UIImage(data: originalData!) + let image = UIImage(data: originalData!) mImgView.image = image imgOritentation = image?.imageOrientation ?? .left @@ -205,7 +210,17 @@ class CCSpatialPhotoDisplayController: BaseController { } //MARK: - 外接屏幕 链接 与 断开 - @objc func airPlayStatusDidChange(notification:Notification) { + @objc func exScreenWillConnectNotification(notification:Notification){ + print("exScreenWillConnectNotification>>>>>") + airPlayStatusDidChange(notification: notification) + } + + @objc func exScreenDisConnectNotification(notification:Notification){ + print("exScreenDisConnectNotification>>>>>") + airPlayStatusDidChange(notification: notification) + } + + func airPlayStatusDidChange(notification:Notification) { checkAirPlayStatus() if(isAirPlayActive) { @@ -216,15 +231,8 @@ class CCSpatialPhotoDisplayController: BaseController { let sec:TimeInterval = ZZHHelper.getSecFromUserDefaultByKey("kNowTimeToUserDefaultKey_PhotoDisplayController_airplay") Analytics.logEvent("streaming_live", parameters: ["refer_page":"图片预览页面","duration":sec]) } - - } - -// @objc func exScreenDisConnectNotification(notification:Notification) { -// print("已断开 屏幕。。。。。") -// -// checkAirPlayStatus() -// } + private func checkAirPlayStatus() { print("设备连接变化 photodisplaycontroller>>>>>") @@ -239,47 +247,100 @@ class CCSpatialPhotoDisplayController: BaseController { //已连接 if(isScreenMirroring){ print("变化为已连接。。。。") - // 获取所有打开的会话 - let sessions:Set = UIApplication.shared.openSessions - - // 过滤会话以找到来自其他屏幕的场景 - let otherScreenSessions:Set = sessions.filter { - $0.role.rawValue.contains("External") - } + UIApplication.shared.connectedScenes.forEach { us in + print("uisence:\(us)\n") + let ws = us as! UIWindowScene + if ws.session.role.rawValue == "UIWindowSceneSessionRoleExternalDisplayNonInteractive"{ + externalVC = ws.windows.first?.rootViewController as? ZZHExternalViewController +// if let has_exvc = exvc { +// has_exvc.imageView?.image = mImgView.image +// } + + externalDispalylink = ws.windows.first?.screen.displayLink(withTarget: self, selector: #selector(displayUpdate(caDisplayLink:))) + externalDispalylink?.add(to: RunLoop.main, forMode: RunLoop.Mode.common) + + } + - if let session = otherScreenSessions.first, - let scene = session.scene { - self.externalWindow.windowScene = scene as! UIWindowScene - let nvc = UIViewController() - self.externalWindow.rootViewController = nvc - var imageView = UIImageView(frame: CGRectMake(0, 0, KScreenHeight*2, KScreenHeight*2)) - imageView.contentMode = .scaleAspectFit - externalImageView = imageView - nvc.view.addSubview(imageView) - self.externalWindow.isHidden = false - var dispalylink:CADisplayLink? = self.externalWindow.windowScene?.windows.first?.screen.displayLink(withTarget: self, selector: #selector(displayUpdate(caDisplayLink:))) - dispalylink?.add(to: RunLoop.main, forMode: RunLoop.Mode.common) - } - else { - print("未发现外接屏....") } + // 获取所有打开的会话 +// let sessions:Set = UIApplication.shared.openSessions +// sessions.forEach { ss in +// print("role:\(ss.role.rawValue)") +// } +// // 过滤会话以找到来自其他屏幕的场景 +// let otherScreenSessions:Set = sessions.filter { +// $0.role.rawValue.contains("External") +// } +// +// otherScreenSessions.forEach { ssn in +// print("ssn role:\(ssn.role.rawValue) first:\(otherScreenSessions.first)") +// } +// +// UIApplication.shared.connectedScenes.forEach { us in +// print("conn sc:\(us)") +// } + + + +// if let session = otherScreenSessions.first{ +// let ssar = UISceneSessionActivationRequest.init(session: session) +// UIApplication.shared.activateSceneSession(for: ssar) { err in +// print("error:\(err)") +// } +// guard let scene = session.scene else { +// return +// } +// self.externalWindow.windowScene = scene as! UIWindowScene +// let nvc = UIViewController() +// self.externalWindow.rootViewController = nvc +// var imageView = UIImageView(frame: CGRectMake(0, 0, KScreenHeight*2, KScreenHeight*2)) +// imageView.contentMode = .scaleAspectFit +// externalImageView = imageView +// nvc.view.addSubview(imageView) +// self.externalWindow.isHidden = false +// var dispalylink:CADisplayLink? = self.externalWindow.windowScene?.windows.first?.screen.displayLink(withTarget: self, selector: #selector(displayUpdate(caDisplayLink:))) +// dispalylink?.add(to: RunLoop.main, forMode: RunLoop.Mode.common) +// } +// else { +// print("未发现外接屏....") +// } } else{ print("变化为 断开。。。。") - if let imv = externalImageView{ - imv .removeFromSuperview() - } - externalImageView = nil - self.externalWindow.isHidden = true - self.externalWindow.rootViewController = nil + externalVC = nil + externalDispalylink?.invalidate() + externalDispalylink = nil +// if let imv = externalImageView{ +// imv .removeFromSuperview() +// } +// externalImageView = nil +// self.externalWindow.isHidden = true +// self.externalWindow.rootViewController = nil } } +// @objc func hasNewWindowExternal(notification:Notification){ +// print("hasNewWindowExternal notifi...") +// let window = notification.userInfo?["newwindow"] as! UIWindow +// let imageView = UIImageView(frame: CGRectMake(0, 0, KScreenHeight*2, KScreenHeight*2)) +// imageView.contentMode = .scaleAspectFit +// externalImageView = imageView +// window.rootViewController?.view.addSubview(imageView) +// let dispalylink:CADisplayLink? = window.screen.displayLink(withTarget: self, selector: #selector(displayUpdate(caDisplayLink:))) +// dispalylink?.add(to: RunLoop.main, forMode: RunLoop.Mode.common) +// +// } + @objc func displayUpdate(caDisplayLink:CADisplayLink) { - if externalImageView?.image != mImgView.image { - externalImageView?.image = mImgView.image +// if externalImageView?.image != mImgView.image { +// externalImageView?.image = mImgView.image +// } + + if let has_exvc = externalVC { + has_exvc.imageView?.image = mImgView.image } } @@ -318,7 +379,6 @@ class CCSpatialPhotoDisplayController: BaseController { print("选中了第 \(selectedIndex) 个选项") // player.pause() - NotificationCenter.default.removeObserver(self) mImgView.frame = CGRect.init(x: 0, y: 200, width: self.view.frame.size.width, height: 240) guard let imageSource = CGImageSourceCreateWithData(imgData! as CFData, nil) else { diff --git a/SwiftProject/SwiftProject/SceneDelegate.swift b/SwiftProject/SwiftProject/SceneDelegate.swift new file mode 100644 index 0000000..bfcad20 --- /dev/null +++ b/SwiftProject/SwiftProject/SceneDelegate.swift @@ -0,0 +1,58 @@ +// +// SceneDelegate.swift +// KeybaordTest +// +// Created by aaa on 2024/3/18. +// + +import UIKit + +class SceneDelegate: UIResponder, UIWindowSceneDelegate { + + var window: UIWindow? + + + func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { + print("scene.......") + + self.window?.rootViewController = RootTabBarController() + guard let _ = (scene as? UIWindowScene) else { return } + } + + func sceneDidDisconnect(_ scene: UIScene) { + // Called as the scene is being released by the system. + // This occurs shortly after the scene enters the background, or when its session is discarded. + // Release any resources associated with this scene that can be re-created the next time the scene connects. + // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). + print("sceneDidDisconnect") + } + + func sceneDidBecomeActive(_ scene: UIScene) { + // Called when the scene has moved from an inactive state to an active state. + // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. + print("sceneDidBecomeActive") + } + + func sceneWillResignActive(_ scene: UIScene) { + // Called when the scene will move from an active state to an inactive state. + // This may occur due to temporary interruptions (ex. an incoming phone call). + print("sceneWillResignActive") + } + + func sceneWillEnterForeground(_ scene: UIScene) { + // Called as the scene transitions from the background to the foreground. + // Use this method to undo the changes made on entering the background. + print("sceneWillEnterForeground") + } + + func sceneDidEnterBackground(_ scene: UIScene) { + // Called as the scene transitions from the foreground to the background. + // Use this method to save data, release shared resources, and store enough scene-specific state information + // to restore the scene back to its current state. + + print("sceneDidEnterBackground") + } + + +} +