萤石云 iOSSDK,移植跨平台相关工程
chenqiyang
2023-06-05 cf977559d6821a1ccce2acae076835a8037f2a90
EZSDK/EZSDK/EZ/UIViewControllers/EZLivePlayViewController.m
@@ -11,18 +11,18 @@
#import <Photos/Photos.h>
#import "EZLivePlayViewController.h"
#import "UIViewController+EZBackPop.h"
#import "EZDeviceInfo.h"
#import "EZPlayer.h"
#import <EZOpenSDKFramework/EZDeviceInfo.h>
#import <EZOpenSDKFramework/EZPlayer.h>
#import "DDKit.h"
#import "Masonry.h"
#import "HIKLoadView.h"
#import "MBProgressHUD.h"
#import "EZCameraInfo.h"
#import <EZOpenSDKFramework/EZCameraInfo.h>
#import <AVFoundation/AVFoundation.h>
#import "Toast+UIView.h"
#import "EZStreamPlayer.h"
#import <EZOpenSDKFramework/EZStreamPlayer.h>
#import "MBProgressHUD.h"
#import "EZPMPlayPrivateTokenInfo.h"
#import <EZOpenSDKFramework/EZPMPlayPrivateTokenInfo.h>
#import "HDLEZAlertInputView.h"
#define MinimumZoomScale 1.0
#define MaximumZoomScale 4.0
@@ -93,6 +93,8 @@
@property (nonatomic, strong) HDLEZButton *unlockButton;//开锁按钮
@property (nonatomic, copy) NSString *streamToken;
@property (nonatomic, strong) UIView *doorPlayerView;//门锁播放view
@end
@@ -240,6 +242,21 @@
//    }
}
/*添加门锁播放view
 */
-(UIView*)doorPlayerView{
    if (!_doorPlayerView) {
        _doorPlayerView=[[UIView alloc] init];
        [_playerView addSubview:_doorPlayerView];
        [_doorPlayerView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(_playerView.mas_centerX);
            make.top.bottom.equalTo(_playerView);
            make.width.mas_equalTo(_doorPlayerView.mas_height).multipliedBy(1);
        }];
    }
    return _doorPlayerView;
}
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    self.navigationController.navigationBar.hidden = NO;//2021-02-01
@@ -288,11 +305,15 @@
/*获取设备信息
 */
-(void)getDeviceInfo{
    __weak __typeof(self)weakSelf = self;
    //获取设备信息
    [EZOpenSDK getDeviceInfo:self.deviceSerial completion:^(EZDeviceInfo *deviceInfo, NSError *error) {
        if(error)
        {
            NSLog(@"EZ 查询设备信息失败");
            NSLog(@"EZ 查询设备信息失败:%@",error);
            [weakSelf.view makeToast:error.userInfo[@"NSLocalizedDescription"]
                            duration:1.5
                            position:@"center"];
            return;
        }
        if (deviceInfo) {
@@ -372,7 +393,11 @@
        [_player setPlayVerifyCode:verifyCode];
        [_talkPlayer setPlayVerifyCode:verifyCode];
    }
    [_player setPlayerView:_playerView];
//    if ([GlobalKit shareKit].deviceType==HDLEZDeviceType_Door) {//为门锁时
        [_player setPlayerView:self.doorPlayerView];
//    }else{
//        [_player setPlayerView:_playerView];
//    }
    BOOL hdStatus = [[NSUserDefaults standardUserDefaults] boolForKey:[NSString stringWithFormat:@"EZVideoPlayHardDecodingStatus_%@", self.deviceInfo.deviceSerial]];
    [_player setHDPriority:hdStatus];
    [_player startRealPlay];
@@ -415,9 +440,9 @@
    self.scrollView.multipleTouchEnabled = YES;
    self.scrollView.pagingEnabled = NO;
    
    if ([GlobalKit shareKit].deviceType==HDLEZDeviceType_Door) {//为门锁时,只显示麦克风和开门按钮
        self.captureButton.hidden=YES;
        self.localRecordButton.hidden=YES;
    if ([GlobalKit shareKit].deviceType==HDLEZDeviceType_Door) {//为门锁时,显示麦克风
//        self.captureButton.hidden=YES;
//        self.localRecordButton.hidden=YES;
        self.controlButton.hidden=YES;
        
        //重设控制台按钮
@@ -450,7 +475,7 @@
        __weak __typeof(self)weakSelf = self;
        [[EZHttpUtil sharedManager] authLockByHDL:content deviceId:self.deviceId  completion:^(ResponseData * _Nonnull responseData) {
            if (responseData.success) {
                [[EZHttpUtil sharedManager] remoteOpenByHDL:self.streamToken deviceId:self.deviceId completion:^(ResponseData * _Nonnull responseData) {
                [[EZHttpUtil sharedManager] remoteOpenByHDL:weakSelf.streamToken deviceId:weakSelf.deviceId completion:^(ResponseData * _Nonnull responseData) {
                    [MBProgressHUD hideHUDForView:weakSelf.view animated:YES];
                    if (responseData.success) {
                        [weakSelf.view makeToast:HDLEZLocallizedString(@"device_open_success")
@@ -578,6 +603,27 @@
    }
    [_emptyButton setTitle:[NSString stringWithFormat:fromatStr,value] forState:UIControlStateNormal];
}
/**
 *  收到的画面长宽值
 *
 *  @param player 播放器对象
 *  @param height 高度
 *  @param width  宽度
 */
- (void)player:(EZPlayer *)player didReceivedDisplayHeight:(NSInteger)height displayWidth:(NSInteger)width{
//    HDLEZLog(@"画面长:%ld,宽:%ld",(long)height,(long)width);
    CGFloat playerVH=self.playerView.frame.size.height;
//    HDLEZLog(@"高:%ld",(long)playerVH);
    CGFloat ratio=((CGFloat)width)/((CGFloat)height);
//    HDLEZLog(@"比例:%f",ratio);
    CGFloat playerVW=playerVH*ratio;
//    HDLEZLog(@"宽:%ld",(long)playerVW);
    [self.doorPlayerView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(_doorPlayerView.mas_height).multipliedBy(ratio);
    }];
}
@@ -859,6 +905,11 @@
        self.localRecordButton.enabled = NO;
        self.captureButton.enabled = NO;
        self.playerPlayButton.hidden = NO;
        //开门按钮置灰,不给点击(暂停的情况下不给开门)
        [_unlockButton setImage:[UIImage imageNamed:@"hdl_ez_ic_unlock_disable"] forState:UIControlStateNormal];
        _unlockButton.enabled=NO;
    }
    else
    {