webRtcPlayerViewController+AppDelegate.m 2.7 KB

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