萤石云 iOSSDK,移植跨平台相关工程
Davin
2023-07-27 48c5a2c66c549d26fecadc6d2dad1924fdd1cc8b
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和rateBtn
    [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