| | |
| | | #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" |
| | | #import "HDLEZOPButton.h" |
| | | #import "HDLEZVideoDoorToolView.h" |
| | | #define MinimumZoomScale 1.0 |
| | | #define MaximumZoomScale 4.0 |
| | | |
| | |
| | | { |
| | | NSOperation *op; |
| | | BOOL _isPressed; |
| | | BOOL _landscape; // 是否旋转 |
| | | } |
| | | |
| | | @property (nonatomic) BOOL isOpenSound; |
| | | @property (nonatomic) BOOL isPlaying; |
| | | @property (nonatomic) BOOL isAnswering; // 正在接听中 |
| | | @property (nonatomic, strong) NSTimer *recordTimer; |
| | | @property (nonatomic) NSTimeInterval seconds; |
| | | @property (nonatomic, strong) CALayer *orangeLayer; |
| | |
| | | @property (nonatomic, strong) HIKLoadView *loadingView; |
| | | @property (nonatomic, weak) IBOutlet UIButton *playerPlayButton; |
| | | @property (nonatomic, weak) IBOutlet UIView *playerView; |
| | | @property (weak, nonatomic) IBOutlet NSLayoutConstraint *playerViewWHRatio; |
| | | @property (weak, nonatomic) IBOutlet NSLayoutConstraint *playerViewBottomMargin; |
| | | |
| | | @property (nonatomic, weak) IBOutlet UIView *toolBar; |
| | | @property (nonatomic, weak) IBOutlet UIView *bottomView; |
| | | @property (nonatomic, weak) IBOutlet UIButton *controlButton; |
| | |
| | | @property (nonatomic, weak) IBOutlet UIButton *captureButton; |
| | | @property (nonatomic, weak) IBOutlet UIButton *localRecordButton; |
| | | @property (nonatomic, weak) IBOutlet UIButton *playButton; |
| | | @property (weak, nonatomic) IBOutlet NSLayoutConstraint *playBtnLeftMargin; |
| | | @property (weak, nonatomic) IBOutlet UIButton *streamPlayBtn; |
| | | @property (nonatomic, weak) IBOutlet UIButton *voiceButton; |
| | | @property (nonatomic, weak) IBOutlet UIButton *qualityButton; |
| | | @property (nonatomic, weak) IBOutlet UIButton *emptyButton; |
| | | @property (weak, nonatomic) IBOutlet NSLayoutConstraint *emptyBtnLeftMargin; |
| | | @property (nonatomic, weak) IBOutlet UIButton *largeButton; |
| | | @property (weak, nonatomic) IBOutlet NSLayoutConstraint *largeBtnRightMargin; |
| | | @property (nonatomic, weak) IBOutlet UIButton *largeBackButton; |
| | | @property (weak, nonatomic) IBOutlet NSLayoutConstraint *largeBackBtnLeftMargin; |
| | | @property (nonatomic, weak) IBOutlet UIView *ptzView; |
| | | @property (nonatomic, weak) IBOutlet UIButton *ptzCloseButton; |
| | | @property (nonatomic, weak) IBOutlet UIButton *ptzControlButton; |
| | |
| | | @property (nonatomic, strong) EZCameraInfo *cameraInfo; |
| | | @property (weak, nonatomic) IBOutlet UILabel *streamTypeLabel; |
| | | @property (weak, nonatomic) IBOutlet UIScrollView *scrollView; |
| | | @property (weak, nonatomic) IBOutlet NSLayoutConstraint *scrollViewTopMargin; |
| | | @property (weak, nonatomic) IBOutlet UILabel *zoomSizeLabel; |
| | | @property (weak, nonatomic) IBOutlet NSLayoutConstraint *scrollViewWHRatio; // 滚动视图宽高比 |
| | | @property (nonatomic, strong) HDLEZButton *unlockButton;//开锁按钮 |
| | | |
| | | @property (nonatomic, copy) NSString *streamToken; |
| | | |
| | | @property (nonatomic, strong) UIView *doorPlayerView;//门锁播放view |
| | | @property (nonatomic, assign) CGFloat doorPlayerAspectRatio; // 门锁播放视图宽高比 |
| | | |
| | | // 呼叫视图相关控件 |
| | | @property (weak, nonatomic) IBOutlet UIView *videoCallOutView; // 呼叫弹框 |
| | | @property (weak, nonatomic) IBOutlet UILabel *callOutAlertLabel; // 提示语言 |
| | | @property (weak, nonatomic) IBOutlet HDLEZOPButton *hangUpButton; // 挂断按钮 |
| | | @property (weak, nonatomic) IBOutlet HDLEZOPButton *ignoreButton; // 忽略按钮 |
| | | @property (weak, nonatomic) IBOutlet HDLEZOPButton *answerButton; // 接听按钮 |
| | | |
| | | @property (strong, nonatomic) HDLEZVideoDoorToolView *fullSceneToolView; // 全屏工具视图 |
| | | |
| | | @end |
| | | |
| | |
| | | self.isStartingTalk = NO; |
| | | self.ptzView.hidden = YES; |
| | | self.talkView.hidden = YES; |
| | | self.isAnswering = NO; |
| | | self.videoCallOutView.hidden = YES; |
| | | self.doorPlayerAspectRatio = HDLEZ_APP_SCREEN_WIDTH / HDLEZ_APP_SCREEN_HEIGHT; |
| | | _landscape = NO; |
| | | |
| | | if (!self.deviceInfo) {//如果没有传deviceInfo,需主动获取 |
| | | [self getDeviceInfo]; |
| | | return; |
| | | } |
| | | |
| | | //初始化相关数据 |
| | | [self initialData]; |
| | | [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:HDLEZHEXCOLOR(0x1B2D4D, 1.),NSFontAttributeName:[UIFont systemFontOfSize:18]}]; |
| | | |
| | | // self.talkButton.enabled = self.deviceInfo.isSupportTalk; |
| | | // self.controlButton.enabled = self.deviceInfo.isSupportPTZ; |
| | | // self.captureButton.enabled = NO; |
| | | // self.localRecordButton.enabled = NO; |
| | | // self.streamPlayBtn.hidden = YES; |
| | | // |
| | | // if (_url) |
| | | // { |
| | | // _player = [EZOPENSDK createPlayerWithUrl:_url]; |
| | | // } |
| | | // else if([self.deviceInfo.deviceType containsString:@"CAS"]) //hub |
| | | // { |
| | | // _cameraInfo = [[EZCameraInfo alloc]init]; //兼容demo之前的业务逻辑,手动填充了cameraInfo,实际开发直接传入序列号和通道号生成EZPlayer即可 |
| | | // _cameraInfo.deviceSerial = _hubCoDevSerial; |
| | | // _cameraInfo.cameraNo = _cameraIndex; |
| | | // _player = [EZOPENSDK createPlayerWithDeviceSerial:_cameraInfo.deviceSerial cameraNo:_cameraInfo.cameraNo]; |
| | | // } |
| | | // else |
| | | // { |
| | | // _cameraInfo = [self.deviceInfo.cameraInfo dd_objectAtIndex:_cameraIndex]; |
| | | // _player = [EZOPENSDK createPlayerWithDeviceSerial:_cameraInfo.deviceSerial cameraNo:_cameraInfo.cameraNo]; |
| | | // _talkPlayer = [EZOPENSDK createPlayerWithDeviceSerial:_cameraInfo.deviceSerial cameraNo:_cameraInfo.cameraNo]; |
| | | // if (_cameraInfo.videoLevel == 2) |
| | | // { |
| | | // [self.qualityButton setTitle:NSLocalizedString(@"device_quality_high", @"高清") forState:UIControlStateNormal]; |
| | | // } |
| | | // else if (_cameraInfo.videoLevel == 1) |
| | | // { |
| | | // [self.qualityButton setTitle:NSLocalizedString(@"device_quality_median", @"均衡") forState:UIControlStateNormal]; |
| | | // } |
| | | // else |
| | | // { |
| | | // [self.qualityButton setTitle:NSLocalizedString(@"device_quality_low",@"流畅") forState:UIControlStateNormal]; |
| | | // } |
| | | // } |
| | | // if (_cameraInfo.cameraNo == 0 || [self.deviceInfo.deviceType containsString:@"CAS"]) { //不支持清晰度切换 |
| | | // self.qualityButton.hidden = YES; |
| | | // } |
| | | // |
| | | // if (self.deviceInfo.cameraInfo.count > 1) { |
| | | // self.title = [NSString stringWithFormat:@"Camera %ld", (long)_cameraInfo.cameraNo]; |
| | | // } |
| | | // else { |
| | | // self.title = _deviceInfo.deviceName; |
| | | // } |
| | | // self.largeTitleLabel.text = self.title; |
| | | // [self hidenWatchFunc]; |
| | | // |
| | | //#if DEBUG |
| | | // if (!_url) |
| | | // { |
| | | // //抓图接口演示代码 |
| | | // [EZOPENSDK captureCamera:_cameraInfo.deviceSerial cameraNo:_cameraInfo.cameraNo completion:^(NSString *url, NSError *error) { |
| | | // NSLog(@"[%@] capture cameraNo is [%d] url is %@, error is %@", _cameraInfo.deviceSerial, (int)_cameraInfo.cameraNo, url, error); |
| | | // }]; |
| | | // } |
| | | //#endif |
| | | // |
| | | // _player.delegate = self; |
| | | // _talkPlayer.delegate = self; |
| | | // //判断设备是否加密,加密就从demo的内存中获取设备验证码填入到播放器的验证码接口里,本demo只处理内存存储,本地持久化存储用户自行完成 |
| | | // if (self.deviceInfo.isEncrypt) |
| | | // { |
| | | // NSString *verifyCode = [[GlobalKit shareKit].deviceVerifyCodeBySerial objectForKey:self.deviceInfo.deviceSerial]; |
| | | // [_player setPlayVerifyCode:verifyCode]; |
| | | // [_talkPlayer setPlayVerifyCode:verifyCode]; |
| | | // } |
| | | // [_player setPlayerView:_playerView]; |
| | | // BOOL hdStatus = [[NSUserDefaults standardUserDefaults] boolForKey:[NSString stringWithFormat:@"EZVideoPlayHardDecodingStatus_%@", self.deviceInfo.deviceSerial]]; |
| | | // [_player setHDPriority:hdStatus]; |
| | | // [_player startRealPlay]; |
| | | // |
| | | // if(!_loadingView) |
| | | // _loadingView = [[HIKLoadView alloc] initWithHIKLoadViewStyle:HIKLoadViewStyleSqureClockWise]; |
| | | // [self.view insertSubview:_loadingView aboveSubview:self.playerView]; |
| | | // [_loadingView mas_makeConstraints:^(MASConstraintMaker *make) { |
| | | // make.width.height.mas_equalTo(@14); |
| | | // make.centerX.mas_equalTo(self.playerView.mas_centerX); |
| | | // make.centerY.mas_equalTo(self.playerView.mas_centerY); |
| | | // }]; |
| | | // [self.loadingView startSquareClcokwiseAnimation]; |
| | | // |
| | | // self.largeBackButton.hidden = YES; |
| | | // _isOpenSound = YES; |
| | | // |
| | | // [self.controlButton dd_centerImageAndTitle]; |
| | | // [self.talkButton dd_centerImageAndTitle]; |
| | | // [self.captureButton dd_centerImageAndTitle]; |
| | | // [self.localRecordButton dd_centerImageAndTitle]; |
| | | // |
| | | // [self.voiceButton setImage:[UIImage imageNamed:@"preview_unvoice_btn_sel"] forState:UIControlStateHighlighted]; |
| | | // [self addLine]; |
| | | // |
| | | // self.localRecordLabel.layer.borderColor = [UIColor whiteColor].CGColor; |
| | | // self.localRecordLabel.layer.cornerRadius = 12.0f; |
| | | // self.localRecordLabel.layer.borderWidth = 1.0f; |
| | | // self.localRecordLabel.clipsToBounds = YES; |
| | | // self.playButton.enabled = NO; |
| | | // |
| | | // |
| | | // self.scrollView.minimumZoomScale = MinimumZoomScale; |
| | | // self.scrollView.maximumZoomScale = MaximumZoomScale; |
| | | // self.scrollView.backgroundColor = [UIColor clearColor]; |
| | | // self.scrollView.delegate = self; |
| | | // self.scrollView.showsHorizontalScrollIndicator = NO; |
| | | // self.scrollView.showsVerticalScrollIndicator = NO; |
| | | // self.scrollView.userInteractionEnabled = YES; |
| | | // self.scrollView.multipleTouchEnabled = YES; |
| | | // self.scrollView.pagingEnabled = NO; |
| | | // |
| | | // if ([GlobalKit shareKit].deviceType==HDLEZDeviceType_Door) {//为门锁时,只显示麦克风和开门按钮 |
| | | // self.captureButton.hidden=YES; |
| | | // self.localRecordButton.hidden=YES; |
| | | // |
| | | // [self.controlButton setTitle:NSLocalizedString(@"device_open", @"开门") forState:UIControlStateNormal]; |
| | | // } |
| | | } |
| | | |
| | | /*添加门锁播放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)viewWillAppear:(BOOL)animated { |
| | | [super viewWillAppear:animated]; |
| | | if (self.navigationController) { |
| | | self.navigationController.navigationBar.hidden = NO; |
| | | [self.navigationController setNavigationBarHidden:NO]; |
| | | } |
| | | } |
| | | |
| | | - (void)viewDidAppear:(BOOL)animated { |
| | | [super viewDidAppear:animated]; |
| | | self.navigationController.navigationBar.hidden = NO;//2021-02-01 |
| | | self.ptzViewContraint.constant = self.bottomView.frame.size.height; |
| | | self.talkViewContraint.constant = self.ptzViewContraint.constant; |
| | | } |
| | | |
| | | - (void)viewWillDisappear:(BOOL)animated { |
| | | // self.navigationController.navigationBarHidden = YES;//2021-02-01 添加隐藏navigationBarHidden |
| | | [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(hideQualityView) object:nil]; |
| | | //结束本地录像 |
| | | if(self.localRecordButton.selected) |
| | | { |
| | | __weak __typeof(self)weakSelf = self; |
| | | [_player stopLocalRecordExt:^(BOOL ret) { |
| | | |
| | | NSLog(@"%d", ret); |
| | | |
| | | [weakSelf.recordTimer invalidate]; |
| | | weakSelf.recordTimer = nil; |
| | | weakSelf.localRecordLabel.hidden = YES; |
| | | [weakSelf saveRecordToPhotosAlbum:weakSelf.filePath]; |
| | | weakSelf.filePath = nil; |
| | | }]; |
| | | } |
| | | |
| | | NSLog(@"viewWillDisappear"); |
| | | [super viewWillDisappear:animated]; |
| | | } |
| | | |
| | | - (void)viewDidDisappear:(BOOL)animated |
| | | { |
| | | NSLog(@"viewDidDisappear"); |
| | | [super viewDidDisappear:animated]; |
| | | [_player stopRealPlay]; |
| | | if (_talkPlayer) |
| | | { |
| | | [_talkPlayer stopVoiceTalk]; |
| | | } |
| | | } |
| | | |
| | | - (void)didReceiveMemoryWarning { |
| | | [super didReceiveMemoryWarning]; |
| | | // Dispose of any resources that can be recreated. |
| | | } |
| | | |
| | | /*获取设备信息 |
| | | */ |
| | | -(void)getDeviceInfo{ |
| | | __weak __typeof(self)weakSelf = self; |
| | | //获取设备信息 |
| | | [EZOpenSDK getDeviceInfo:self.deviceSerial completion:^(EZDeviceInfo *deviceInfo, NSError *error) { |
| | | if(error) |
| | | { |
| | | NSLog(@"EZ 查询设备信息失败:%@",error); |
| | | [weakSelf.view makeToast:error.userInfo[@"NSLocalizedDescription"] |
| | | duration:1.5 |
| | | position:@"center"]; |
| | | return; |
| | | } |
| | | if (deviceInfo) { |
| | | self.deviceInfo=deviceInfo; |
| | | [self initialData]; |
| | | } |
| | | }]; |
| | | } |
| | | |
| | | /*初始化相关数据 |
| | | */ |
| | | -(void)initialData{ |
| | | self.talkButton.enabled = self.deviceInfo.isSupportTalk; |
| | | self.controlButton.enabled = self.deviceInfo.isSupportPTZ; |
| | | self.captureButton.enabled = NO; |
| | | self.localRecordButton.enabled = NO; |
| | | self.streamPlayBtn.hidden = YES; |
| | | // self.isShowAlert = YES; |
| | | |
| | | if (_url) |
| | | { |
| | |
| | | } |
| | | if (_cameraInfo.cameraNo == 0 || [self.deviceInfo.deviceType containsString:@"CAS"]) { //不支持清晰度切换 |
| | | self.qualityButton.hidden = YES; |
| | | [self.fullSceneToolView supportVideoLevelChange:NO]; |
| | | } |
| | | |
| | | if (self.deviceInfo.cameraInfo.count > 1) { |
| | |
| | | if (!_url) |
| | | { |
| | | //抓图接口演示代码 |
| | | __weak __typeof(self)weakSelf = self; |
| | | [EZOPENSDK captureCamera:_cameraInfo.deviceSerial cameraNo:_cameraInfo.cameraNo completion:^(NSString *url, NSError *error) { |
| | | NSLog(@"[%@] capture cameraNo is [%d] url is %@, error is %@", _cameraInfo.deviceSerial, (int)_cameraInfo.cameraNo, url, error); |
| | | NSLog(@"[%@] capture cameraNo is [%d] url is %@, error is %@", weakSelf.cameraInfo.deviceSerial, (int)weakSelf.cameraInfo.cameraNo, url, error); |
| | | }]; |
| | | } |
| | | #endif |
| | |
| | | [_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]; |
| | |
| | | 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; |
| | | |
| | | [self.controlButton setTitle:NSLocalizedString(@"device_open", @"开门") forState:UIControlStateNormal]; |
| | | } |
| | | } |
| | | |
| | | - (void)viewDidAppear:(BOOL)animated { |
| | | [super viewDidAppear:animated]; |
| | | self.navigationController.navigationBar.hidden = NO;//2021-02-01 |
| | | self.ptzViewContraint.constant = self.bottomView.frame.size.height; |
| | | self.talkViewContraint.constant = self.ptzViewContraint.constant; |
| | | } |
| | | |
| | | - (void)viewWillDisappear:(BOOL)animated { |
| | | // self.navigationController.navigationBarHidden = YES;//2021-02-01 添加隐藏navigationBarHidden |
| | | [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(hideQualityView) object:nil]; |
| | | //结束本地录像 |
| | | if(self.localRecordButton.selected) |
| | | { |
| | | [_player stopLocalRecordExt:^(BOOL ret) { |
| | | |
| | | NSLog(@"%d", ret); |
| | | |
| | | [_recordTimer invalidate]; |
| | | _recordTimer = nil; |
| | | self.localRecordLabel.hidden = YES; |
| | | [self saveRecordToPhotosAlbum:_filePath]; |
| | | _filePath = nil; |
| | | //重设控制台按钮 |
| | | _unlockButton=[[HDLEZButton alloc] init]; |
| | | [self.bottomView addSubview:_unlockButton]; |
| | | [_unlockButton mas_makeConstraints:^(MASConstraintMaker *make) { |
| | | make.top.left.right.bottom.equalTo( self.controlButton); |
| | | }]; |
| | | [_unlockButton setImage:[UIImage imageNamed:@"hdl_ez_ic_unlock_disable"] forState:UIControlStateNormal]; |
| | | [_unlockButton setTitle:NSLocalizedString(@"device_open", @"开门") forState:UIControlStateNormal]; |
| | | [_unlockButton dd_centerImageAndTitle]; |
| | | [_unlockButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal]; |
| | | _unlockButton.titleLabel.font=[UIFont systemFontOfSize:14]; |
| | | [_unlockButton addTarget:self action:@selector(unlockDoor) forControlEvents:UIControlEventTouchUpInside]; |
| | | _unlockButton.enabled=NO; |
| | | // self.controlButton.enabled=YES; |
| | | // [self.controlButton setImage:[UIImage imageNamed:@"hdl_ez_ic_unlock"] forState:UIControlStateNormal]; |
| | | // [self.controlButton setTitle:NSLocalizedString(@"device_open", @"开门") forState:UIControlStateNormal]; |
| | | } |
| | | |
| | | NSLog(@"viewWillDisappear"); |
| | | [super viewWillDisappear:animated]; |
| | | } |
| | | |
| | | - (void)viewDidDisappear:(BOOL)animated |
| | | { |
| | | NSLog(@"viewDidDisappear"); |
| | | [super viewDidDisappear:animated]; |
| | | [_player stopRealPlay]; |
| | | if (_talkPlayer) |
| | | { |
| | | [_talkPlayer stopVoiceTalk]; |
| | | self.callOutAlertLabel.text = HDLEZLocallizedString(@"device_callout_alert_message"); |
| | | [self.hangUpButton setTitle:HDLEZLocallizedString(@"device_callout_hang_up") forState:UIControlStateNormal]; |
| | | self.hangUpButton.imagePosition = HDLEZOPButtonImagePositionTop; |
| | | self.hangUpButton.spacingBetweenImageAndTitle = 12.; |
| | | [self.ignoreButton setTitle:HDLEZLocallizedString(@"device_callout_ignore") forState:UIControlStateNormal]; |
| | | self.ignoreButton.imagePosition = HDLEZOPButtonImagePositionTop; |
| | | self.ignoreButton.spacingBetweenImageAndTitle = 12.; |
| | | [self.answerButton setTitle:HDLEZLocallizedString(@"device_callout_answered") forState:UIControlStateNormal]; |
| | | self.answerButton.imagePosition = HDLEZOPButtonImagePositionTop; |
| | | self.answerButton.spacingBetweenImageAndTitle = 12.; |
| | | |
| | | // 门锁全屏状态下工具栏 |
| | | [self.view addSubview:self.fullSceneToolView]; |
| | | __weak __typeof(self)weakSelf = self; |
| | | [self.fullSceneToolView ringRingRing:YES]; // 默认显示挂断按钮 |
| | | [self.fullSceneToolView configPlayStatus:YES soundOn:YES videoLevel:_cameraInfo.videoLevel toolOperation:^(HDLEZVideoFullSceneOperation operationType) { |
| | | [weakSelf doorLockFullSceneOperation:operationType]; |
| | | }]; |
| | | |
| | | // 挂断弹框 |
| | | if (_isShowAlert) { |
| | | [self showCallOutAlertView]; |
| | | } else { |
| | | [self hiddenCallOutAlertView]; |
| | | } |
| | | } |
| | | |
| | | - (void)didReceiveMemoryWarning { |
| | | [super didReceiveMemoryWarning]; |
| | | // Dispose of any resources that can be recreated. |
| | | } |
| | | /*开锁 |
| | | */ |
| | | -(void)unlockDoor{ |
| | | if (![self isSupportOneKeyUnlockDoor]) { // 不支持一键开锁 |
| | | [UIView dd_showMessage:@"该设备不支持一键开锁"]; |
| | | return; |
| | | } |
| | | [HDLEZAlertInputView showInputAlertWithtitle:HDLEZLocallizedString(@"device_please_input_door_password") cancleTitle:HDLEZLocallizedString(@"device_temp_cancle") sureTitle:HDLEZLocallizedString(@"device_temp_sure") keyboardType:UIKeyboardTypeASCIICapableNumberPad cancleBlock:^{ |
| | | |
| | | } sureBlock:^(NSString * _Nonnull content) { |
| | | HDLEZLog(@"点击了确认:%@",content); |
| | | [MBProgressHUD showHUDAddedTo:self.view animated:YES]; |
| | | __weak __typeof(self)weakSelf = self; |
| | | [[EZHttpUtil sharedManager] authLockByHDL:content deviceId:self.deviceId completion:^(ResponseData * _Nonnull responseData) { |
| | | if (responseData.success) { |
| | | [[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") |
| | | duration:1.5 |
| | | position:@"center"]; |
| | | |
| | | }else{ |
| | | [weakSelf.view makeToast:responseData.message |
| | | duration:1.5 |
| | | position:@"center"]; |
| | | } |
| | | }]; |
| | | }else{ |
| | | [MBProgressHUD hideHUDForView:weakSelf.view animated:YES]; |
| | | [weakSelf.view makeToast:responseData.message |
| | | duration:1.5 |
| | | position:@"center"]; |
| | | } |
| | | }]; |
| | | |
| | | }]; |
| | | |
| | | |
| | | |
| | | } |
| | | /* |
| | | #pragma mark - Navigation |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | - (UIInterfaceOrientationMask)supportedInterfaceOrientations |
| | | { |
| | | return UIInterfaceOrientationMaskAllButUpsideDown; |
| | | //- (UIInterfaceOrientationMask)supportedInterfaceOrientations |
| | | //{ |
| | | // return UIInterfaceOrientationMaskAllButUpsideDown; |
| | | //} |
| | | - (UIInterfaceOrientationMask)supportedInterfaceOrientations { |
| | | if (@available(iOS 16.0, *)) { |
| | | if (_landscape && !self.isVideoDoorLock) { |
| | | //横屏 |
| | | return UIInterfaceOrientationMaskLandscape; |
| | | } else { |
| | | //竖屏 |
| | | return UIInterfaceOrientationMaskPortrait; |
| | | } |
| | | } else { |
| | | return UIInterfaceOrientationMaskAllButUpsideDown; |
| | | } |
| | | } |
| | | |
| | | - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation |
| | | duration:(NSTimeInterval)duration |
| | | { |
| | | if (self.isVideoDoorLock) return; |
| | | self.navigationController.navigationBarHidden = NO; |
| | | self.toolBar.hidden = NO; |
| | | self.largeBackButton.hidden = YES; |
| | | self.bottomView.hidden = NO; |
| | | self.largeTitleLabel.hidden = YES; |
| | | self.localRecrodContraint.constant = 10; |
| | | |
| | | [self.scrollView setTranslatesAutoresizingMaskIntoConstraints:NO]; |
| | | [self.toolBar setTranslatesAutoresizingMaskIntoConstraints:NO]; |
| | | [self.playButton setTranslatesAutoresizingMaskIntoConstraints:NO]; |
| | | [self.emptyButton setTranslatesAutoresizingMaskIntoConstraints:NO]; |
| | | [self.largeButton setTranslatesAutoresizingMaskIntoConstraints:NO]; |
| | | // [self.largeBackButton setTranslatesAutoresizingMaskIntoConstraints:NO]; |
| | | [NSLayoutConstraint deactivateConstraints:@[self.scrollViewWHRatio, self.playBtnLeftMargin, self.emptyBtnLeftMargin, self.largeBtnRightMargin]]; |
| | | self.scrollViewWHRatio = [NSLayoutConstraint constraintWithItem:self.scrollView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.scrollView attribute:NSLayoutAttributeHeight multiplier:16/9. constant:0]; |
| | | self.playBtnLeftMargin = [NSLayoutConstraint constraintWithItem:self.playButton attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self.toolBar attribute:NSLayoutAttributeLeading multiplier:1 constant:0]; |
| | | self.emptyBtnLeftMargin = [NSLayoutConstraint constraintWithItem:self.emptyButton attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self.qualityButton attribute:NSLayoutAttributeTrailing multiplier:1 constant:0]; |
| | | self.largeBtnRightMargin = [NSLayoutConstraint constraintWithItem:self.toolBar attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:self.largeButton attribute:NSLayoutAttributeTrailing multiplier:1 constant:0]; |
| | | [NSLayoutConstraint activateConstraints:@[self.scrollViewWHRatio, self.playBtnLeftMargin, self.emptyBtnLeftMargin, self.largeBtnRightMargin]]; |
| | | dispatch_async(dispatch_get_main_queue(), ^{ |
| | | [self.scrollView layoutIfNeeded]; |
| | | [self.toolBar layoutIfNeeded]; |
| | | [self.playButton layoutIfNeeded]; |
| | | [self.emptyButton layoutIfNeeded]; |
| | | [self.largeButton layoutIfNeeded]; |
| | | }); |
| | | |
| | | if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || |
| | | toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) |
| | | { |
| | | self.navigationController.navigationBarHidden = YES; |
| | | self.localRecrodContraint.constant = 50; |
| | | self.toolBar.hidden = YES; |
| | | // self.toolBar.hidden = YES; |
| | | self.largeTitleLabel.hidden = NO; |
| | | self.largeBackButton.hidden = NO; |
| | | self.bottomView.hidden = 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; |
| | | CGFloat marginSpace = 64; |
| | | |
| | | [self.scrollView setTranslatesAutoresizingMaskIntoConstraints:NO]; |
| | | [self.toolBar setTranslatesAutoresizingMaskIntoConstraints:NO]; |
| | | [self.playButton setTranslatesAutoresizingMaskIntoConstraints:NO]; |
| | | [self.emptyButton setTranslatesAutoresizingMaskIntoConstraints:NO]; |
| | | [self.largeButton setTranslatesAutoresizingMaskIntoConstraints:NO]; |
| | | [NSLayoutConstraint deactivateConstraints:@[self.scrollViewWHRatio, self.playBtnLeftMargin, self.emptyBtnLeftMargin, self.largeBtnRightMargin]]; |
| | | self.scrollViewWHRatio = [NSLayoutConstraint constraintWithItem:self.scrollView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.scrollView attribute:NSLayoutAttributeHeight multiplier:tureScreenH/(tureScreenW - 37) constant:0]; |
| | | self.playBtnLeftMargin = [NSLayoutConstraint constraintWithItem:self.playButton attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self.toolBar attribute:NSLayoutAttributeLeading multiplier:1 constant:marginSpace]; |
| | | self.emptyBtnLeftMargin = [NSLayoutConstraint constraintWithItem:self.emptyButton attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self.qualityButton attribute:NSLayoutAttributeTrailing multiplier:1 constant:(tureScreenH - tureScreenW - 2 * marginSpace)]; |
| | | self.largeBtnRightMargin = [NSLayoutConstraint constraintWithItem:self.toolBar attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:self.largeButton attribute:NSLayoutAttributeTrailing multiplier:1 constant:marginSpace]; |
| | | [NSLayoutConstraint activateConstraints:@[self.scrollViewWHRatio, self.playBtnLeftMargin, self.emptyBtnLeftMargin, self.largeBtnRightMargin]]; |
| | | dispatch_async(dispatch_get_main_queue(), ^{ |
| | | [self.scrollView layoutIfNeeded]; |
| | | [self.toolBar layoutIfNeeded]; |
| | | [self.playButton layoutIfNeeded]; |
| | | [self.emptyButton layoutIfNeeded]; |
| | | [self.largeButton layoutIfNeeded]; |
| | | }); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | [_emptyButton setTitle:[NSString stringWithFormat:fromatStr,value] forState:UIControlStateNormal]; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 收到的画面长宽值 |
| | | * |
| | | * @param player 播放器对象 |
| | | * @param height 高度 |
| | | * @param width 宽度 |
| | | */ |
| | | - (void)player:(EZPlayer *)player didReceivedDisplayHeight:(NSInteger)height displayWidth:(NSInteger)width{ |
| | | NSLog(@"画面长:%ld,宽:%ld",(long)height,(long)width); |
| | | CGFloat playerVH=self.playerView.frame.size.height; |
| | | // HDLEZLog(@"高:%ld",(long)playerVH); |
| | | CGFloat ratio=((CGFloat)width)/((CGFloat)height); |
| | | NSLog(@"比例:%f",ratio); |
| | | // CGFloat playerVW=playerVH*ratio; |
| | | self.doorPlayerAspectRatio = ratio; |
| | | // HDLEZLog(@"宽:%ld",(long)playerVW); |
| | | [self.doorPlayerView mas_updateConstraints:^(MASConstraintMaker *make) { |
| | | make.width.mas_equalTo(_doorPlayerView.mas_height).multipliedBy(ratio); |
| | | }]; |
| | | } |
| | | |
| | | |
| | |
| | | - (void)player:(EZPlayer *)player playPrivateTokenInfo:(EZPMPlayPrivateTokenInfo *)tokenInfo { |
| | | NSLog(@"开门token--->%@", tokenInfo.token); |
| | | self.streamToken=tokenInfo.token; |
| | | |
| | | if (!_unlockButton.isEnabled) { |
| | | if ([self isSupportOneKeyUnlockDoor]) { // 支持一键开锁 |
| | | [_unlockButton setImage:[UIImage imageNamed:@"hdl_ez_ic_unlock"] forState:UIControlStateNormal]; |
| | | } else { |
| | | [_unlockButton setImage:[UIImage imageNamed:@"hdl_ez_ic_unlock_disable"] forState:UIControlStateNormal]; |
| | | } |
| | | _unlockButton.enabled=YES; |
| | | } |
| | | } |
| | | #pragma mark - ValidateCode Methods |
| | | |
| | |
| | | |
| | | - (IBAction)large:(id)sender |
| | | { |
| | | NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft]; |
| | | [[UIDevice currentDevice] setValue:value forKey:@"orientation"]; |
| | | if (!self.isPlaying)return; // 未播放禁止全屏, |
| | | self.videoCallOutView.hidden = YES; |
| | | if (_landscape == YES) { |
| | | [self largeBack:self.largeBackButton]; |
| | | return; |
| | | } |
| | | _landscape = YES; |
| | | if (self.isVideoDoorLock) { |
| | | self.navigationController.navigationBarHidden = YES; |
| | | self.localRecrodContraint.constant = 50; |
| | | self.toolBar.hidden = YES; |
| | | self.largeTitleLabel.hidden = YES; |
| | | self.largeBackButton.hidden = YES; |
| | | self.bottomView.hidden = YES; |
| | | self.scrollView.backgroundColor = [UIColor blackColor]; |
| | | |
| | | [self.scrollView setTranslatesAutoresizingMaskIntoConstraints:NO]; |
| | | [self.playerView setTranslatesAutoresizingMaskIntoConstraints:NO]; |
| | | [NSLayoutConstraint deactivateConstraints:@[self.scrollViewTopMargin, self.scrollViewWHRatio, self.playerViewWHRatio, self.playerViewBottomMargin]]; |
| | | self.scrollViewTopMargin = [NSLayoutConstraint constraintWithItem:self.scrollView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.topLayoutGuide attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-[self hdlEZStatusBarHeight]]; |
| | | self.scrollViewWHRatio = [NSLayoutConstraint constraintWithItem:self.scrollView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.scrollView attribute:NSLayoutAttributeHeight multiplier:HDLEZ_APP_SCREEN_WIDTH/HDLEZ_APP_SCREEN_HEIGHT constant:0]; |
| | | |
| | | self.playerViewWHRatio = [NSLayoutConstraint constraintWithItem:self.playerView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.playerView attribute:NSLayoutAttributeHeight multiplier:self.doorPlayerAspectRatio constant:0]; |
| | | CGFloat playerBottomMargin = HDLEZ_APP_SCREEN_HEIGHT - (HDLEZ_APP_SCREEN_WIDTH / self.doorPlayerAspectRatio); |
| | | NSLog(@"########播放间隙:%lf", playerBottomMargin); |
| | | self.playerViewBottomMargin = [NSLayoutConstraint constraintWithItem:self.scrollView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.playerView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:playerBottomMargin]; |
| | | [NSLayoutConstraint activateConstraints:@[self.scrollViewTopMargin, self.scrollViewWHRatio, self.playerViewWHRatio, self.playerViewBottomMargin]]; |
| | | dispatch_async(dispatch_get_main_queue(), ^{ |
| | | [self.scrollView layoutIfNeeded]; |
| | | [self.playerView layoutIfNeeded]; |
| | | }); |
| | | self.fullSceneToolView.hidden = NO; |
| | | [self.view bringSubviewToFront:self.fullSceneToolView]; |
| | | return; |
| | | } |
| | | 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"]; |
| | | } |
| | | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ |
| | | [self.largeButton setImage:[UIImage imageNamed:@"preview_enlarge_full"] forState:UIControlStateNormal]; |
| | | [self.largeButton setImage:[UIImage imageNamed:@"preview_enlarge_full_btn_sel"] forState:UIControlStateHighlighted]; |
| | | }); |
| | | } |
| | | |
| | | - (IBAction)largeBack:(id)sender |
| | | { |
| | | NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationPortrait]; |
| | | [[UIDevice currentDevice] setValue:value forKey:@"orientation"]; |
| | | _landscape = NO; |
| | | if (self.isVideoDoorLock) { |
| | | self.navigationController.navigationBarHidden = NO; |
| | | self.toolBar.hidden = NO; |
| | | self.largeBackButton.hidden = YES; |
| | | self.bottomView.hidden = NO; |
| | | self.largeTitleLabel.hidden = YES; |
| | | self.localRecrodContraint.constant = 10; |
| | | self.videoCallOutView.hidden = !self.isShowAlert; |
| | | self.scrollView.backgroundColor = [UIColor clearColor]; |
| | | |
| | | [self.scrollView setTranslatesAutoresizingMaskIntoConstraints:NO]; |
| | | [self.playerView setTranslatesAutoresizingMaskIntoConstraints:NO]; |
| | | [NSLayoutConstraint deactivateConstraints:@[self.scrollViewTopMargin,self.scrollViewWHRatio, self.playerViewWHRatio, self.playerViewBottomMargin]]; |
| | | self.scrollViewTopMargin = [NSLayoutConstraint constraintWithItem:self.scrollView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.topLayoutGuide attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0]; |
| | | self.scrollViewWHRatio = [NSLayoutConstraint constraintWithItem:self.scrollView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.scrollView attribute:NSLayoutAttributeHeight multiplier:16/9. constant:0]; |
| | | |
| | | self.playerViewWHRatio = [NSLayoutConstraint constraintWithItem:self.playerView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.playerView attribute:NSLayoutAttributeHeight multiplier:16/9. constant:0]; |
| | | self.playerViewBottomMargin = [NSLayoutConstraint constraintWithItem:self.scrollView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.playerView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0]; |
| | | [NSLayoutConstraint activateConstraints:@[self.scrollViewTopMargin,self.scrollViewWHRatio, self.playerViewWHRatio, self.playerViewBottomMargin]]; |
| | | dispatch_async(dispatch_get_main_queue(), ^{ |
| | | [self.scrollView layoutIfNeeded]; |
| | | [self.playerView layoutIfNeeded]; |
| | | }); |
| | | self.fullSceneToolView.hidden = YES; |
| | | return; |
| | | } |
| | | 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"]; |
| | | } |
| | | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ |
| | | [self.largeButton setImage:[UIImage imageNamed:@"preview_enlarge"] forState:UIControlStateNormal]; |
| | | [self.largeButton setImage:[UIImage imageNamed:@"preview_enlarge_btn_sel"] forState:UIControlStateHighlighted]; |
| | | }); |
| | | } |
| | | |
| | | - (IBAction)capture:(id)sender |
| | |
| | | [self.voiceButton setImage:[UIImage imageNamed:@"preview_voice_btn"] forState:UIControlStateNormal]; |
| | | } |
| | | _isOpenSound = !_isOpenSound; |
| | | [self.fullSceneToolView soundOn:_isOpenSound]; |
| | | } |
| | | |
| | | - (IBAction)playButtonClicked:(id)sender |
| | |
| | | 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 |
| | | { |
| | |
| | | [self.loadingView startSquareClcokwiseAnimation]; |
| | | } |
| | | _isPlaying = !_isPlaying; |
| | | [self.fullSceneToolView playStatus:_isPlaying]; |
| | | } |
| | | |
| | | - (SEL)extracted { |
| | | return @selector(hideQualityView); |
| | | } |
| | | |
| | | - (IBAction)qualityButtonClicked:(id)sender |
| | |
| | | { |
| | | self.qualityView.hidden = NO; |
| | | //停留5s以后隐藏视频质量View. |
| | | [self performSelector:@selector(hideQualityView) withObject:nil afterDelay:5.0f]; |
| | | [self performSelector:[self extracted] withObject:nil afterDelay:5.0f]; |
| | | } |
| | | self.qualityButton.selected = !self.qualityButton.selected; |
| | | } |
| | |
| | | } |
| | | [weakSelf.player stopRealPlay]; |
| | | |
| | | _cameraInfo.videoLevel = type; |
| | | weakSelf.cameraInfo.videoLevel = type; |
| | | if (sender == weakSelf.highButton) |
| | | { |
| | | [weakSelf.qualityButton setTitle:NSLocalizedString(@"device_quality_high", @"高清") forState:UIControlStateNormal]; |
| | | [self.fullSceneToolView videoLevel:2]; |
| | | } |
| | | else if (sender == weakSelf.middleButton) |
| | | { |
| | | [weakSelf.qualityButton setTitle:NSLocalizedString(@"device_quality_median", @"均衡") forState:UIControlStateNormal]; |
| | | [self.fullSceneToolView videoLevel:1]; |
| | | } |
| | | else |
| | | { |
| | | [weakSelf.qualityButton setTitle:NSLocalizedString(@"device_quality_low", @"流畅") forState:UIControlStateNormal]; |
| | | [self.fullSceneToolView videoLevel:0]; |
| | | } |
| | | if (result) |
| | | { |
| | |
| | | |
| | | - (IBAction)ptzViewShow:(id)sender |
| | | { |
| | | if ([GlobalKit shareKit].deviceType==HDLEZDeviceType_Door) {//为门锁设备时,执行开门 |
| | | NSString *verifyCode = [[GlobalKit shareKit].deviceVerifyCodeBySerial objectForKey:self.deviceInfo.deviceSerial]; |
| | | |
| | | [[EZHttpUtil sharedManager] authLockByHDL:@"123456" deviceId:self.deviceInfo.deviceSerial verifyCode:verifyCode completion:^(ResponseData * _Nonnull responseData) { |
| | | NSLog(@"终端授权结果:%@",responseData.data); |
| | | [[EZHttpUtil sharedManager] remoteOpenByHDL:self.streamToken deviceId:self.deviceInfo.deviceSerial completion:^(ResponseData * _Nonnull responseData) { |
| | | NSLog(@"开门结果:%@",responseData.data); |
| | | }]; |
| | | }]; |
| | | return; |
| | | } |
| | | |
| | | self.ptzView.hidden = NO; |
| | | [self.bottomView bringSubviewToFront:self.ptzView]; |
| | | self.ptzControlButton.alpha = 0; |
| | |
| | | self.speakImageView.alpha = 0; |
| | | self.talkView.hidden = YES; |
| | | }]; |
| | | self.isAnswering = NO; |
| | | } |
| | | |
| | | - (IBAction)localButtonClicked:(id)sender |
| | |
| | | //结束本地录像 |
| | | if(self.localRecordButton.selected) |
| | | { |
| | | __weak __typeof(self)weakSelf = self; |
| | | [_player stopLocalRecordExt:^(BOOL ret) { |
| | | |
| | | NSLog(@"%d", ret); |
| | | |
| | | [_recordTimer invalidate]; |
| | | _recordTimer = nil; |
| | | self.localRecordLabel.hidden = YES; |
| | | [self saveRecordToPhotosAlbum:_filePath]; |
| | | _filePath = nil; |
| | | [weakSelf.recordTimer invalidate]; |
| | | weakSelf.recordTimer = nil; |
| | | weakSelf.localRecordLabel.hidden = YES; |
| | | [weakSelf saveRecordToPhotosAlbum:weakSelf.filePath]; |
| | | weakSelf.filePath = nil; |
| | | }]; |
| | | } |
| | | else |
| | |
| | | [self.talkPlayer audioTalkPressed:NO]; |
| | | } |
| | | _isPressed = !_isPressed; |
| | | } |
| | | |
| | | - (IBAction)clickCalloutHangupAction:(id)sender { |
| | | self.isShowAlert = NO; |
| | | [self closeTalkView:self.talkCloseButton]; |
| | | if (self.msgId && self.msgId.length > 0) { |
| | | [[EZHttpUtil sharedManager] updateAnswerStatusWithMsgId:self.msgId answerStatus:@"no_answer" completion:^(ResponseData * _Nonnull responseData) { |
| | | HDLEZLog(@"###########挂断####:%@", [responseData yy_modelToJSONString]); |
| | | }]; |
| | | } |
| | | [self.navigationController popViewControllerAnimated:YES]; |
| | | } |
| | | |
| | | - (IBAction)clickCalloutIgnoreAction:(id)sender { |
| | | // [UIView dd_showMessage:@"忽略开发中..."]; |
| | | self.isShowAlert = NO; |
| | | self.isAnswering = NO; |
| | | [self.navigationController popViewControllerAnimated:YES]; |
| | | } |
| | | |
| | | - (IBAction)clickCalloutAnswerAction:(id)sender { |
| | | self.isShowAlert = NO; |
| | | self.isAnswering = YES; |
| | | [self talkButtonClicked:self.talkButton]; |
| | | if (self.msgId && self.msgId.length > 0) { |
| | | [[EZHttpUtil sharedManager] updateAnswerStatusWithMsgId:self.msgId answerStatus:@"answer" completion:^(ResponseData * _Nonnull responseData) { |
| | | HDLEZLog(@"###########接听####:%@", [responseData yy_modelToJSONString]); |
| | | }]; |
| | | } |
| | | } |
| | | |
| | | |
| | | #pragma mark - Publish Methods |
| | | /// 展示呼叫弹框 |
| | | - (void)showCallOutAlertView { |
| | | self.videoCallOutView.hidden = NO; |
| | | } |
| | | |
| | | /// 隐藏呼叫弹框 |
| | | - (void)hiddenCallOutAlertView { |
| | | self.videoCallOutView.hidden = YES; |
| | | } |
| | | |
| | | #pragma mark - Private Methods |
| | |
| | | [view removeFromSuperview]; |
| | | } |
| | | } |
| | | CGFloat averageWidth = [UIScreen mainScreen].bounds.size.width/5.0; |
| | | UIImageView *lineImageView1 = [UIView dd_instanceVerticalLine:20 color:[UIColor grayColor]]; |
| | | lineImageView1.frame = CGRectMake(averageWidth, 7, lineImageView1.frame.size.width, lineImageView1.frame.size.height); |
| | | // CGFloat averageWidth = [UIScreen mainScreen].bounds.size.width/5.0; |
| | | UIImageView *lineImageView1 = [UIView dd_instanceVerticalLine:20 color:HDLEZHEXCOLOR(0xFFFFFF, 0.16)]; |
| | | // lineImageView1.frame = CGRectMake(averageWidth, 7, lineImageView1.frame.size.width, lineImageView1.frame.size.height); |
| | | [self.toolBar addSubview:lineImageView1]; |
| | | UIImageView *lineImageView2 = [UIView dd_instanceVerticalLine:20 color:[UIColor grayColor]]; |
| | | lineImageView2.frame = CGRectMake(averageWidth * 2, 7, lineImageView2.frame.size.width, lineImageView2.frame.size.height); |
| | | [lineImageView1 mas_makeConstraints:^(MASConstraintMaker *make) { |
| | | make.left.mas_equalTo(self.playButton.mas_right); |
| | | make.centerY.mas_equalTo(self.playButton.mas_centerY); |
| | | make.width.mas_equalTo(lineImageView1.frame.size.width); |
| | | make.height.mas_equalTo(lineImageView1.frame.size.height); |
| | | }]; |
| | | UIImageView *lineImageView2 = [UIView dd_instanceVerticalLine:20 color:HDLEZHEXCOLOR(0xFFFFFF, 0.16)]; |
| | | // lineImageView2.frame = CGRectMake(averageWidth * 2, 7, lineImageView2.frame.size.width, lineImageView2.frame.size.height); |
| | | [self.toolBar addSubview:lineImageView2]; |
| | | UIImageView *lineImageView3 = [UIView dd_instanceVerticalLine:20 color:[UIColor grayColor]]; |
| | | lineImageView3.frame = CGRectMake(averageWidth * 3, 7, lineImageView3.frame.size.width, lineImageView3.frame.size.height); |
| | | [lineImageView2 mas_makeConstraints:^(MASConstraintMaker *make) { |
| | | make.left.mas_equalTo(self.voiceButton.mas_right); |
| | | make.centerY.mas_equalTo(self.voiceButton.mas_centerY); |
| | | make.width.mas_equalTo(lineImageView2.frame.size.width); |
| | | make.height.mas_equalTo(lineImageView2.frame.size.height); |
| | | }]; |
| | | UIImageView *lineImageView3 = [UIView dd_instanceVerticalLine:20 color:HDLEZHEXCOLOR(0xFFFFFF, 0.16)]; |
| | | // lineImageView3.frame = CGRectMake(averageWidth * 3, 7, lineImageView3.frame.size.width, lineImageView3.frame.size.height); |
| | | [self.toolBar addSubview:lineImageView3]; |
| | | UIImageView *lineImageView4 = [UIView dd_instanceVerticalLine:20 color:[UIColor grayColor]]; |
| | | lineImageView4.frame = CGRectMake(averageWidth * 4, 7, lineImageView4.frame.size.width, lineImageView4.frame.size.height); |
| | | [lineImageView3 mas_makeConstraints:^(MASConstraintMaker *make) { |
| | | make.left.mas_equalTo(self.qualityButton.mas_right); |
| | | make.centerY.mas_equalTo(self.qualityButton.mas_centerY); |
| | | make.width.mas_equalTo(lineImageView3.frame.size.width); |
| | | make.height.mas_equalTo(lineImageView3.frame.size.height); |
| | | }]; |
| | | UIImageView *lineImageView4 = [UIView dd_instanceVerticalLine:20 color:HDLEZHEXCOLOR(0xFFFFFF, 0.16)]; |
| | | // lineImageView4.frame = CGRectMake(averageWidth * 4, 7, lineImageView4.frame.size.width, lineImageView4.frame.size.height); |
| | | [self.toolBar addSubview:lineImageView4]; |
| | | [lineImageView4 mas_makeConstraints:^(MASConstraintMaker *make) { |
| | | make.left.mas_equalTo(self.emptyButton.mas_right); |
| | | make.centerY.mas_equalTo(self.emptyButton.mas_centerY); |
| | | make.width.mas_equalTo(lineImageView4.frame.size.width); |
| | | make.height.mas_equalTo(lineImageView4.frame.size.height); |
| | | }]; |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | #pragma mark - PrivateMethod (门锁全屏时的一系列操作) |
| | | - (void)doorLockFullSceneOperation:(HDLEZVideoFullSceneOperation)operation { |
| | | switch (operation) { |
| | | case HDLEZVideoFullSceneOperationOfHangUp: { // 挂断 |
| | | [self largeBack:self.largeButton]; |
| | | [self closeTalkView:self.talkCloseButton]; |
| | | [self hiddenCallOutAlertView]; |
| | | [self.navigationController popViewControllerAnimated:YES]; |
| | | } |
| | | break; |
| | | case HDLEZVideoFullSceneOperationOfPlay: { // 播放 |
| | | [self playButtonClicked:self.playButton]; |
| | | } |
| | | break; |
| | | case HDLEZVideoFullSceneOperationOfPause: { // 暂停 |
| | | [self playButtonClicked:self.playButton]; |
| | | } |
| | | break; |
| | | case HDLEZVideoFullSceneOperationOfSound: { // 开启音量 |
| | | [self voiceButtonClicked:self.voiceButton]; |
| | | } |
| | | break; |
| | | case HDLEZVideoFullSceneOperationOfSoundOff: { // 静音 |
| | | [self voiceButtonClicked:self.voiceButton]; |
| | | } |
| | | break; |
| | | case HDLEZVideoFullSceneOperationOfSmooth: { // 流畅 |
| | | [self qualitySelectedClicked:self.lowButton]; |
| | | } |
| | | break; |
| | | case HDLEZVideoFullSceneOperationOfBalance: { // 均衡 |
| | | [self qualitySelectedClicked:self.middleButton]; |
| | | } |
| | | break; |
| | | case HDLEZVideoFullSceneOperationOfHDFull: { // 高清 |
| | | [self qualitySelectedClicked:self.highButton]; |
| | | } |
| | | break; |
| | | case HDLEZVideoFullSceneOperationOfExitFull: { // 退出全屏 |
| | | [self largeBack:self.largeButton]; |
| | | } |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | |
| | | - (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { |
| | | if (!self.fullSceneToolView.hidden) { |
| | | [self.fullSceneToolView qualityStatusChanged:YES]; |
| | | } |
| | | } |
| | | |
| | | #pragma Setter |
| | | - (void)setIsShowAlert:(BOOL)isShowAlert { |
| | | _isShowAlert = isShowAlert; |
| | | if (_isShowAlert) { |
| | | [self showCallOutAlertView]; |
| | | } else { |
| | | [self hiddenCallOutAlertView]; |
| | | } |
| | | } |
| | | |
| | | #pragma mark - Getter |
| | | - (HDLEZVideoDoorToolView *)fullSceneToolView { |
| | | if (!_fullSceneToolView) { |
| | | _fullSceneToolView = [[HDLEZVideoDoorToolView alloc] initWithFrame:CGRectMake(0, HDLEZ_APP_SCREEN_HEIGHT - 280, HDLEZ_APP_SCREEN_WIDTH, 280)]; |
| | | _fullSceneToolView.hidden = YES; |
| | | } |
| | | return _fullSceneToolView; |
| | | } |
| | | |
| | | - (BOOL)prefersHomeIndicatorAutoHidden { |
| | | return YES; |
| | | } |
| | | |
| | | - (CGFloat)hdlEZStatusBarHeight { |
| | | if (@available(iOS 13.0, *)) { |
| | | NSSet *set = [UIApplication sharedApplication].connectedScenes; |
| | | UIWindowScene *windowScene = [set anyObject]; |
| | | UIStatusBarManager *statusBarManager = windowScene.statusBarManager; |
| | | return statusBarManager.statusBarFrame.size.height; |
| | | } else { |
| | | return [UIApplication sharedApplication].statusBarFrame.size.height; |
| | | } |
| | | } |
| | | |
| | | /// 是否支持一键开锁 |
| | | - (BOOL)isSupportOneKeyUnlockDoor { |
| | | BOOL isSupport = YES; |
| | | if (self.deviceInfo && self.deviceInfo.deviceType && ([self.deviceInfo.deviceType containsString:@"LT20VC"] || [self.deviceInfo.deviceType containsString:@"LT20VC"])) { |
| | | isSupport = NO; |
| | | } |
| | | return isSupport; |
| | | } |
| | | |
| | | @end |