webRtcPlayerViewController+AppDelegate.m 2.6 KB

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