From 48c5a2c66c549d26fecadc6d2dad1924fdd1cc8b Mon Sep 17 00:00:00 2001 From: Davin <591807572@qq.com> Date: 星期四, 27 七月 2023 13:52:08 +0800 Subject: [PATCH] bugfix 猫眼呼叫问题修复 --- EZSDK/EZSDK/EZ/UIViewControllers/EZPlaybackViewController.m | 111 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 97 insertions(+), 14 deletions(-) diff --git a/EZSDK/EZSDK/EZ/UIViewControllers/EZPlaybackViewController.m b/EZSDK/EZSDK/EZ/UIViewControllers/EZPlaybackViewController.m index d7f2e5f..34cb569 100644 --- a/EZSDK/EZSDK/EZ/UIViewControllers/EZPlaybackViewController.m +++ b/EZSDK/EZSDK/EZ/UIViewControllers/EZPlaybackViewController.m @@ -10,27 +10,28 @@ #import "UIViewController+EZBackPop.h" #import "DDCollectionViewFlowLayout.h" #import "MJRefresh.h" -#import "EZRecordDownloader.h" -#import "EZDeviceRecordDownloadTask.h" -#import "EZCloudRecordDownloadTask.h" +#import <EZOpenSDKFramework/EZRecordDownloader.h> +#import <EZOpenSDKFramework/EZDeviceRecordDownloadTask.h> +#import <EZOpenSDKFramework/EZCloudRecordDownloadTask.h> #import "EZRecordCell.h" #import "DDKit.h" -#import "EZCloudRecordFile.h" -#import "EZDeviceRecordFile.h" -#import "EZPlayer.h" +#import <EZOpenSDKFramework/EZCloudRecordFile.h> +#import <EZOpenSDKFramework/EZDeviceRecordFile.h> +#import <EZOpenSDKFramework/EZPlayer.h> #import "HIKLoadView.h" #import "Masonry.h" -#import "EZCameraInfo.h" +#import <EZOpenSDKFramework/EZCameraInfo.h> #import "MBProgressHUD.h" #import "Toast+UIView.h" #import "EZCustomTableView.h" -#import "EZStreamPlayer.h" +#import <EZOpenSDKFramework/EZStreamPlayer.h> @interface EZPlaybackViewController ()<DDCollectionViewDelegateFlowLayout, UICollectionViewDataSource,EZPlayerDelegate, UIAlertViewDelegate, EZRecordCellDelegate, EZCustomTableViewDelegate,EZStreamPlayerDelegate> { BOOL _isOpenSound; BOOL _isPlaying; + BOOL _landscape; // 鏄惁鏃嬭浆 NSTimeInterval _playSeconds; //鎾斁绉掓暟 NSTimeInterval _duringSeconds; //褰曞儚鏃堕暱 @@ -57,6 +58,7 @@ @property (nonatomic, strong) HIKLoadView *loadingView; @property (nonatomic) BOOL isSelectedDevice; @property (nonatomic, weak) IBOutlet UIView *playerView; +@property (weak, nonatomic) IBOutlet NSLayoutConstraint *playViewWHScale; @property (nonatomic, weak) IBOutlet UILabel *largeTitleLabel; @property (nonatomic, weak) IBOutlet UIDatePicker *datePicker; @property (nonatomic, weak) IBOutlet UITextField *dateTextField; @@ -115,6 +117,7 @@ self.isAutorotate = YES; self.largeTitleLabel.text = self.deviceInfo.deviceName; self.largeTitleLabel.hidden = YES; + _landscape = NO; if(!_records) _records = [NSMutableArray new]; @@ -191,8 +194,9 @@ cloudRateStr = @[@"x1",@"x4",@"x8",@"x16",@"x32"]; sdCardRateStr = @[@"x1",@"x4",@"x8",@"x16"]; - //2021-07-21 闅愯棌streamPlayBtn + //2021-07-21 闅愯棌streamPlayBtn鍜宺ateBtn [self.streamPlayBtn setHidden:YES]; + [self.rateBtn setHidden:YES]; } @@ -226,7 +230,17 @@ - (UIInterfaceOrientationMask)supportedInterfaceOrientations { - return UIInterfaceOrientationMaskAllButUpsideDown; + if (@available(iOS 16.0, *)) { + if (_landscape) { + //妯睆 + return UIInterfaceOrientationMaskLandscape; + } else { + //绔栧睆 + return UIInterfaceOrientationMaskPortrait; + } + } else { + return UIInterfaceOrientationMaskAllButUpsideDown; + } } - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation @@ -241,6 +255,13 @@ self.largeButton.hidden = NO; self.voiceButton.hidden = NO; self.playButton.hidden = NO; + [self.playerView setTranslatesAutoresizingMaskIntoConstraints:NO]; + [NSLayoutConstraint deactivateConstraints:@[self.playViewWHScale]]; + self.playViewWHScale = [NSLayoutConstraint constraintWithItem:self.playerView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.playerView attribute:NSLayoutAttributeHeight multiplier:16/9. constant:0]; + [NSLayoutConstraint activateConstraints:@[self.playViewWHScale]]; + dispatch_async(dispatch_get_main_queue(), ^{ + [self.playerView layoutIfNeeded]; + }); if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) { @@ -253,6 +274,18 @@ self.playbackList.hidden = YES; self.largeBackButton.hidden = NO; self.navigationController.navigationBarHidden = YES; + + CGFloat tureScreenW = HDLEZ_APP_SCREEN_WIDTH > HDLEZ_APP_SCREEN_HEIGHT ? HDLEZ_APP_SCREEN_HEIGHT : HDLEZ_APP_SCREEN_WIDTH; + CGFloat tureScreenH = HDLEZ_APP_SCREEN_WIDTH < HDLEZ_APP_SCREEN_HEIGHT ? HDLEZ_APP_SCREEN_HEIGHT : HDLEZ_APP_SCREEN_WIDTH; + + + [self.playerView setTranslatesAutoresizingMaskIntoConstraints:NO]; + [NSLayoutConstraint deactivateConstraints:@[self.playViewWHScale]]; + self.playViewWHScale = [NSLayoutConstraint constraintWithItem:self.playerView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.playerView attribute:NSLayoutAttributeHeight multiplier:tureScreenH/(tureScreenW) constant:0]; + [NSLayoutConstraint activateConstraints:@[self.playViewWHScale]]; + dispatch_async(dispatch_get_main_queue(), ^{ + [self.playerView layoutIfNeeded]; + }); } } @@ -756,14 +789,60 @@ - (IBAction)large:(id)sender { - NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft]; - [[UIDevice currentDevice] setValue:value forKey:@"orientation"]; +// NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft]; +// [[UIDevice currentDevice] setValue:value forKey:@"orientation"]; + if (_landscape == YES) { + [self largeBack:self.largeBackButton]; + return; + } + _landscape = YES; + if (@available(iOS 16.0, *)) { + if (self.navigationController) { + dispatch_async(dispatch_get_main_queue(), ^{ + [self.navigationController setNeedsUpdateOfSupportedInterfaceOrientations]; + }); + } else { + dispatch_async(dispatch_get_main_queue(), ^{ + [self setNeedsUpdateOfSupportedInterfaceOrientations]; + }); + } + NSArray *array = [[[UIApplication sharedApplication] connectedScenes] allObjects]; + UIWindowScene *ws = (UIWindowScene *)array.firstObject; + UIWindowSceneGeometryPreferencesIOS *geometryPreferences = [[UIWindowSceneGeometryPreferencesIOS alloc] init]; + geometryPreferences.interfaceOrientations = UIInterfaceOrientationMaskLandscape; + [ws requestGeometryUpdateWithPreferences:geometryPreferences errorHandler:^(NSError * _Nonnull error) { + NSLog(@"iOS 16 Error: %@",error); + }]; + } else { + NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft]; + [[UIDevice currentDevice] setValue:value forKey:@"orientation"]; + } } - (IBAction)largeBack:(id)sender { - NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationPortrait]; - [[UIDevice currentDevice] setValue:value forKey:@"orientation"]; + _landscape = NO; + if (@available(iOS 16.0, *)) { + if (self.navigationController) { + dispatch_async(dispatch_get_main_queue(), ^{ + [self.navigationController setNeedsUpdateOfSupportedInterfaceOrientations]; + }); + } else { + dispatch_async(dispatch_get_main_queue(), ^{ + [self setNeedsUpdateOfSupportedInterfaceOrientations]; + }); + } + NSArray *array = [[[UIApplication sharedApplication] connectedScenes] allObjects]; + UIWindowScene *ws = (UIWindowScene *)array.firstObject; + UIWindowSceneGeometryPreferencesIOS *geometryPreferences = [[UIWindowSceneGeometryPreferencesIOS alloc] init]; + geometryPreferences.interfaceOrientations = UIInterfaceOrientationMaskPortrait; + [ws requestGeometryUpdateWithPreferences:geometryPreferences errorHandler:^(NSError * _Nonnull error) { + NSLog(@"iOS 16 Error: %@",error); + }]; + } else { + NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationPortrait]; + [[UIDevice currentDevice] setValue:value forKey:@"orientation"]; + } } - (IBAction)voiceButtonClicked:(id)sender @@ -1159,4 +1238,8 @@ } } +- (BOOL)prefersHomeIndicatorAutoHidden { + return YES; +} + @end -- Gitblit v1.8.0