// // webRtcPlayerViewController+AppDelegate.m // 双子星云手机 // // Created by xd h on 2024/9/18. // #import "webRtcPlayerViewController+AppDelegate.h" @implementation webRtcPlayerViewController (AppDelegate) #pragma mark - UIApplication Delegate - (void)applicationWillResignActive:(NSNotification *)notification { //HLog(@"11111"); } - (void)applicationDidEnterBackground:(NSNotification *)notification { [self.mediaStream enterBackground]; // app进入后台时 [self pauseStream]; [self checkLanAndPrivacyModeTypeFun]; [cachesFileManager writeLogsWithMsg:@"applicationDidEnterBackground"]; } - (void)applicationDidBecomeActive:(NSNotification *)notification { if(!ksharedAppDelegate.isDidShowPwdType){ //[self resumeStream]; [self relinkWebRtcFunByBecomeActive]; } [cachesFileManager writeLogsWithMsg:@"applicationDidBecomeActive"]; } - (void)applicationWillTerminate:(UIApplication *)application { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. [self.mediaStream disconnect]; [cachesFileManager writeLogsWithMsg:@"applicationWillTerminate"]; } #pragma mark 云机停止拉流 - (void)pauseStream { [self.mediaStream pauseStream]; } #pragma mark 云机唤醒拉流 - (void)resumeStream { [self.mediaStream resumeStream]; } #pragma mark 检测是否为横屏而且 隐私模式 (密码界面只有竖屏 UI会乱) - (void)checkLanAndPrivacyModeTypeFun { if(!self.isLan){ return; } if(!ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode){ return; } self.isLan = YES; self->isLanAndPrivacyEnterBackground = YES; //旋转屏幕为竖屏 (已经在sceneDelegate 处理旋转) HLog(@"旋转屏幕为竖屏 (已经在sceneDelegate 处理旋转)") } #pragma mark 输入密码完成 - (void)didInpuPwdOkFun { //[self resumeStream]; [self relinkWebRtcFunByBecomeActive]; if(self->isLanAndPrivacyEnterBackground){ self->isLanAndPrivacyEnterBackground = NO; [self player_rotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight]; } } #pragma mark 旋转屏幕 - (BOOL)player_rotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { ksharedAppDelegate.supportScreenRotateType = YES; HLog(@"旋转屏幕") BOOL isSuc = [self hx_rotateToInterfaceOrientation:interfaceOrientation]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ ksharedAppDelegate.supportScreenRotateType = NO; if(interfaceOrientation == UIInterfaceOrientationLandscapeRight){ ksharedAppDelegate.isPlayerScreenLandscapeType = YES; } else{ ksharedAppDelegate.isPlayerScreenLandscapeType = NO; } }); return isSuc; } @end