// // Copyright © 2020 dahua. All rights reserved. // #import "LCLandscapeControlView.h" #import "LCLivePreviewPresenter+LandscapeControlView.h" @interface LCLandscapeControlView () @property (strong,nonatomic) UIView * topView; @property (strong,nonatomic) UIView * bottomView; @property (strong,nonatomic) LCButton * lockBtn; //底部控制按钮 @property (strong, nonatomic) NSMutableArray *items; @property (strong,nonatomic)UILabel * startLab; @property (strong,nonatomic)UILabel * endLab; @end @implementation LCLandscapeControlView -(instancetype)initWithFrame:(CGRect)frame{ if (self=[super initWithFrame:frame]) { } return self; } -(NSMutableArray *)items{ if (!_items) { _items = [self.delegate currentButtonItem]; } return _items; } -(void)setPresenter:(LCLivePreviewPresenter *)presenter{ _presenter = presenter; [self setupView]; } -(void)changeAlpha{ [UIView animateWithDuration:0.3 animations:^{ self.topView.alpha = self.topView.alpha==1 ? 0 : 1; self.bottomView.alpha = self.bottomView.alpha==1 ? 0 : 1; self.lockBtn.alpha = self.lockBtn.alpha==1 ? 0 : 1; }]; } -(void)setupView{ LCButton * hideBtn = [LCButton lcButtonWithType:LCButtonTypeCustom]; [self addSubview:hideBtn]; [hideBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.top.left.bottom.right.mas_equalTo(self); }]; weakSelf(self); hideBtn.touchUpInsideblock = ^(LCButton * _Nonnull btn) { [weakself changeAlpha]; }; //顶部视图 UIView * topView= [UIView new]; self.topView = topView; [self addSubview:topView]; topView.backgroundColor = [UIColor dhcolor_c51]; [topView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.left.right.mas_equalTo(self); make.height.mas_equalTo(40); }]; //返回按钮 LCButton * portrait = [LCButton lcButtonWithType:LCButtonTypeCustom]; [topView addSubview:portrait]; [portrait setTintColor:[UIColor dhcolor_c43]]; [portrait setImage:LC_IMAGENAMED(@"nav_back") forState:UIControlStateNormal]; [portrait mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(topView.mas_left).offset(15); make.centerY.mas_equalTo(topView.mas_centerY); }]; portrait.touchUpInsideblock = ^(LCButton * _Nonnull btn) { [weakself.delegate naviBackClick:btn]; }; //锁定全屏按钮 LCButton * lockBtn = [LCButton lcButtonWithType:LCButtonTypeCustom]; self.lockBtn = lockBtn; [self addSubview:lockBtn]; [lockBtn setImage:LC_IMAGENAMED(@"live_video_icon_h_lock_off") forState:UIControlStateNormal]; [lockBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(self.mas_right).offset(-kTopBarSafeHeight); make.centerY.mas_equalTo(self.mas_centerY); }]; [lockBtn.KVOController observe:self.presenter.videoManager keyPath:@"isLockFullScreen" options:NSKeyValueObservingOptionNew block:^(id _Nullable observer, id _Nonnull object, NSDictionary * _Nonnull change) { if ([change[@"new"] boolValue]) { [lockBtn setImage:LC_IMAGENAMED(@"live_video_icon_h_lock_on") forState:UIControlStateNormal]; }else{ [lockBtn setImage:LC_IMAGENAMED(@"live_video_icon_h_lock_off") forState:UIControlStateNormal]; } }]; lockBtn.touchUpInsideblock = ^(LCButton * _Nonnull btn) { [weakself.delegate lockFullScreen:btn]; }; //序列号显示 UILabel * titleLab = [UILabel new]; titleLab.text = [self.delegate currentTitle]; titleLab.textColor = [UIColor dhcolor_c43]; [topView addSubview:titleLab]; [titleLab mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.mas_equalTo(topView.mas_centerY); make.centerX.mas_equalTo(topView.mas_centerX); }]; //底部视图 UIView * bottomView= [UIView new]; self.bottomView = bottomView; [self addSubview:bottomView]; bottomView.backgroundColor = [UIColor dhcolor_c51]; [bottomView mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.left.right.mas_equalTo(self); make.height.mas_equalTo(54); }]; self.startLab = [UILabel new]; self.startLab.hidden = !self.isNeedProcess; [bottomView addSubview:self.startLab]; self.startLab.textAlignment = NSTextAlignmentCenter; self.startLab.textColor = [UIColor dhcolor_c43]; self.startLab.adjustsFontSizeToFitWidth = YES; [self.startLab mas_makeConstraints:^(MASConstraintMaker *make) { make.top.bottom.mas_equalTo(bottomView); make.left.mas_equalTo(bottomView).offset(20); make.width.mas_equalTo(80); }]; self.endLab = [UILabel new]; self.endLab.hidden = !self.isNeedProcess; self.endLab.textAlignment = NSTextAlignmentCenter; self.endLab.textColor = [UIColor dhcolor_c43]; [bottomView addSubview:self.endLab]; self.endLab.adjustsFontSizeToFitWidth = YES; [self.endLab mas_makeConstraints:^(MASConstraintMaker *make) { make.top.bottom.mas_equalTo(bottomView); make.right.mas_equalTo(bottomView).offset(-20); make.width.mas_equalTo(80); }]; LCVideotapePlayProcessView * processView = [LCVideotapePlayProcessView new]; self.processView = processView; [processView configFullScreenUI]; processView.hidden = !self.isNeedProcess; [bottomView addSubview:processView]; [processView mas_makeConstraints:^(MASConstraintMaker *make) { make.right.left.mas_equalTo(self); make.centerY.mas_equalTo(bottomView.mas_top); make.height.mas_equalTo(self.isNeedProcess?23:0); }]; processView.valueChangeBlock = ^(float offset, NSDate * _Nonnull currentStartTiem) { weakself.startLab.text = [currentStartTiem stringWithFormat:@"HH:mm:ss"]; }; processView.valueChangeEndBlock = ^(float offset, NSDate * _Nonnull currentStartTiem) { //改进度 [self.delegate changePlayOffset:(NSInteger)offset]; }; int index = 0; while (index