webRtcPlayerViewController+AppDelegate~.m 2.9 KB

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