webRtcPlayerViewController+AppDelegate.m 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. //
  2. // webRtcPlayerViewController+AppDelegate.m
  3. // 双子星云手机
  4. //
  5. // Created by xd h on 2024/9/18.
  6. //
  7. #import "webRtcPlayerViewController+AppDelegate.h"
  8. @implementation webRtcPlayerViewController (AppDelegate)
  9. #pragma mark - UIApplication Delegate
  10. - (void)applicationWillResignActive:(NSNotification *)notification
  11. {
  12. //HLog(@"11111");
  13. }
  14. - (void)applicationDidEnterBackground:(NSNotification *)notification {
  15. // app进入后台时
  16. [self pauseStream];
  17. [self checkLanAndPrivacyModeTypeFun];
  18. [cachesFileManager writeLogsWithMsg:@"applicationDidEnterBackground"];
  19. }
  20. - (void)applicationDidBecomeActive:(NSNotification *)notification
  21. {
  22. if(!ksharedAppDelegate.isDidShowPwdType){
  23. //[self resumeStream];
  24. [self relinkWebRtcFunByBecomeActive];
  25. }
  26. [cachesFileManager writeLogsWithMsg:@"applicationDidBecomeActive"];
  27. }
  28. - (void)applicationWillTerminate:(UIApplication *)application {
  29. // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
  30. [self.mediaStream disconnect];
  31. [cachesFileManager writeLogsWithMsg:@"applicationWillTerminate"];
  32. }
  33. #pragma mark 云机停止拉流
  34. - (void)pauseStream
  35. {
  36. [self.mediaStream pauseStream];
  37. }
  38. #pragma mark 云机唤醒拉流
  39. - (void)resumeStream
  40. {
  41. [self.mediaStream resumeStream];
  42. }
  43. #pragma mark 检测是否为横屏而且 隐私模式 (密码界面只有竖屏 UI会乱)
  44. - (void)checkLanAndPrivacyModeTypeFun
  45. {
  46. if(!self.isLan){
  47. return;
  48. }
  49. if(!ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode){
  50. return;
  51. }
  52. self.isLan = YES;
  53. self->isLanAndPrivacyEnterBackground = YES;
  54. //旋转屏幕为竖屏 (已经在sceneDelegate 处理旋转)
  55. HLog(@"旋转屏幕为竖屏 (已经在sceneDelegate 处理旋转)")
  56. }
  57. #pragma mark 输入密码完成
  58. - (void)didInpuPwdOkFun
  59. {
  60. //[self resumeStream];
  61. [self relinkWebRtcFunByBecomeActive];
  62. if(self->isLanAndPrivacyEnterBackground){
  63. self->isLanAndPrivacyEnterBackground = NO;
  64. [self player_rotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight];
  65. }
  66. }
  67. #pragma mark 旋转屏幕
  68. - (BOOL)player_rotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
  69. {
  70. ksharedAppDelegate.supportScreenRotateType = YES;
  71. HLog(@"旋转屏幕")
  72. BOOL isSuc = [self hx_rotateToInterfaceOrientation:interfaceOrientation];
  73. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  74. ksharedAppDelegate.supportScreenRotateType = NO;
  75. if(interfaceOrientation == UIInterfaceOrientationLandscapeRight){
  76. ksharedAppDelegate.isPlayerScreenLandscapeType = YES;
  77. }
  78. else{
  79. ksharedAppDelegate.isPlayerScreenLandscapeType = NO;
  80. }
  81. });
  82. return isSuc;
  83. }
  84. @end