Commit 25c0310d authored by zhaowl123's avatar zhaowl123
Browse files

4.15.3上线

parent 427e365f
No preview for this file type
......@@ -124,7 +124,7 @@
//funcBgView 动画
@property(nonatomic,strong)NSTimer * funcTimer;//页面手势定时器
@property(nonatomic,assign)NSInteger funcSecond;//页面手势定时器 持续时间 默认4
@property(nonatomic,assign)NSInteger funcSecond;//页面手势定时器 持续时间 默认5
@property(nonatomic,assign)BOOL isSlidering;//拖拽手势的定时器, 为了防止频繁拖拽引发的问题
@property(nonatomic,strong)DWPlayerSettingView * settingView;//当前设置页面
......@@ -232,6 +232,10 @@
//**************************** 视频封面图 ****************************
@property(nonatomic,strong)UIImageView * imgImageView;
//滑动预览功能
@property (nonatomic, strong) UIImageView *preViewImage;
@property (nonatomic, strong) UILabel *timeLabel;
@property (nonatomic, strong) UILabel *markLabel;//显示打点描述
//知识点功能
@property (nonatomic, copy)NSDictionary *knowledheDict;
@property (nonatomic, strong) UIButton *knowledgeBtn;//知识点
......@@ -321,6 +325,7 @@ static CGFloat barrageBgHeight = 40;
[self initFuncGesture];
[self initAirPlayView];
[self initPlayerPanGesture];
[self initPreView];//滑动预览UI
//设置弹幕视图
[self initBarrageView];
......@@ -363,12 +368,7 @@ static CGFloat barrageBgHeight = 40;
// self.testTimer = [NSTimer timerWithTimeInterval:1 target:self selector:@selector(testTimeAction) userInfo:nil repeats:YES];
// [[NSRunLoop mainRunLoop] addTimer:self.testTimer forMode:NSRunLoopCommonModes];
//gw test
// _switchBtn = [[UISwitch alloc] initWithFrame:CGRectMake(100, 50, 80, 40)];
// _switchBtn.on = YES;
_isAsAllowShow = YES;//默认打开
// [_switchBtn addTarget:self action:@selector(handleSiwtchBtn:) forControlEvents:UIControlEventValueChanged];
// [self addSubview:_switchBtn];
}
//- (void)handleSiwtchBtn:(UISwitch *)sender{
......@@ -1191,10 +1191,10 @@ static CGFloat barrageBgHeight = 40;
self.playerView.hidden = YES;
}
//清理视频打点数据
if (self.videomarkArray && self.videomarkArray.count) {
[self dealMarkArray:self.videoModel.videomarks];
}
// //清理视频打点数据
// if (self.videomarkArray && self.videomarkArray.count) {
// [self dealMarkArray:self.videoModel.videomarks];
// }
//取消gif录制
if (self.isGIF) {
......@@ -1206,7 +1206,8 @@ static CGFloat barrageBgHeight = 40;
if (self.isVideo) {
//显示清晰度按钮
[_slider mas_updateConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(@(-(40 * 3) - 10 - 5));
// make.right.equalTo(@(-(40 * 3) - 10 - 5));
make.right.equalTo(self.totalLabel.mas_left).offset(-15);
}];
[_speedButton mas_updateConstraints:^(MASConstraintMaker *make) {
......@@ -1434,7 +1435,7 @@ static CGFloat barrageBgHeight = 40;
[[NSString stringWithFormat:@"开始下载:%@",vodVideo.title] showAlert];
}
#pragma mark - 进度条拖动
#pragma mark - 进度条拖动结束
-(void)sliderScrubWithValue:(CGFloat)value
{
//未加载完成,不触发拖拽事件
......@@ -1618,7 +1619,7 @@ static CGFloat barrageBgHeight = 40;
//func timer 相关
-(void)createFuncTimer
{
self.funcSecond = 4;
self.funcSecond = 5;
if (self.funcTimer) {
[self.funcTimer invalidate];
......@@ -1845,11 +1846,11 @@ static CGFloat barrageBgHeight = 40;
}];
}
if (self.isShowMarkView && self.isFull) {
[self showOrHiddenMarkView:NO];
}else{
[self showOrHiddenMarkView:YES];
}
// if (self.isShowMarkView && self.isFull) {
// [self showOrHiddenMarkView:NO];
// }else{
// [self showOrHiddenMarkView:YES];
// }
}else{
if (self.topFuncBgView.frame.origin.y == -self.topFuncBgView.frame.size.height) {
......@@ -2291,16 +2292,44 @@ static CGFloat barrageBgHeight = 40;
}];
}
//进度条拖拽相关
-(void)sliderMovingAction
#pragma mark - 正在拖动
-(void)sliderMovingAction:(DWPlayerSlider *)slider
{
if (!self.readyToPlay) {
return;
}
CGFloat durationInSeconds = CMTimeGetSeconds(self.playerView.player.currentItem.duration);
CGFloat time = durationInSeconds * slider.value;
self.isSlidering = YES;
if(self.isFull){
self.preViewImage.hidden = NO;
self.timeLabel.hidden = NO;
}else{
self.preViewImage.hidden = YES;
self.timeLabel.hidden = YES;
}
[self funcBgViewIsAppear:YES];//拖动的时候要展示slider
UIImage *image = [self.playerView thumbnailImageForVideoAtTime:time];
self.preViewImage.image = image;
self.timeLabel.text = [NSString stringWithFormat:@"%@/%@", [DWTools formatSecondsToString:time], [DWTools formatSecondsToString:durationInSeconds]];
self.timeLabel.attributedText = [DWTools setTextColor:ColorFrom16A(0xff920a, 1) rangeOfString:[DWTools formatSecondsToString:time] string:self.timeLabel.text textFont:17];
NSInteger integer = time;
for (DWVideoMarkModel *markModel in self.videomarkArray) {//遍历打点的时间点去显示打点描述
if (!self.isFull) {
return;
}
//根据打点时间设置取值范围
if (integer >= markModel.marktime - 6 && integer <= markModel.marktime + 6) {
self.markLabel.text = markModel.markdesc;
break;
}else{
self.markLabel.text = nil;
}
}
}
#pragma mark - 拖动开始
-(void)sliderBeganAction
{
if (!self.readyToPlay) {
......@@ -2313,8 +2342,12 @@ static CGFloat barrageBgHeight = 40;
self.isSlidering = YES;
}
#pragma mark - 拖动结束
-(void)sliderEndedAction
{
self.preViewImage.hidden = YES;
self.timeLabel.hidden = YES;
self.markLabel.text = nil;
[self sliderScrubWithValue:self.slider.value];
}
......@@ -2324,6 +2357,12 @@ static CGFloat barrageBgHeight = 40;
{
CGPoint point = [tap locationInView:self.slider];
CGFloat tapValue = point.x / self.sliderWidth;
// gw test
//视频总时长
CGFloat duration = CMTimeGetSeconds([self.playerView.player.currentItem duration]);
NSNumber *number =[NSNumber numberWithFloat:tapValue * duration];
NSInteger integer =[number integerValue];
int cuTime = tapValue;
if(self.endTime.length > 0){
if(cuTime < self.statrTime.intValue){
......@@ -2333,17 +2372,27 @@ static CGFloat barrageBgHeight = 40;
}
}
[self sliderScrubWithValue:tapValue];
if (!self.isFull) {
return;
__weak typeof(self) weakSelf = self;
[self.videomarkArray enumerateObjectsUsingBlock:^(DWVideoMarkModel *markModel, NSUInteger idx, BOOL * _Nonnull stop) {
if (!self.isFull) {
return;
}
//根据打点时间设置取值范围
if (integer >= markModel.marktime - 6 && integer <= markModel.marktime + 6) {
self.isShowMarkView = YES;
[weakSelf showVideoMarkCurrentValue:tapValue videoDuration:duration];
}
}];
if(!self.isShowMarkView){//如果点击的是视频打点则不跳转
[self sliderScrubWithValue:tapValue];
}
self.isShowMarkView = YES;
//视频总时长
CGFloat duration = CMTimeGetSeconds([self.playerView.player.currentItem duration]);
[self showVideoMarkCurrentValue:tapValue videoDuration:duration];
// CGFloat duration = CMTimeGetSeconds([self.playerView.player.currentItem duration]);
// [self showVideoMarkCurrentValue:tapValue videoDuration:duration];
}
......@@ -2600,25 +2649,41 @@ static CGFloat barrageBgHeight = 40;
if (integer >= markModel.marktime - 6 && integer <= markModel.marktime + 6) {
*stop =YES;
weakSelf.markView.markModel =markModel;
CGFloat width = weakSelf.markView.width;
UIButton *button = weakSelf.markButtonArray[idx];
CGRect frame = [button convertRect:button.bounds toView:self];
// weakSelf.markView.markModel =markModel;
//防止 markView 超出屏幕外
CGFloat markViewLeft = frame.origin.x+2.5 - width/2;
if (markViewLeft < 0) {
markViewLeft = 0;
}
if (markViewLeft + width > weakSelf.frame.size.width) {
markViewLeft = weakSelf.frame.size.width - width;
}
weakSelf.markView.frame = CGRectMake(markViewLeft, ScreenHeight-77/2-50,width,30);
weakSelf.arrowImageView.frame = CGRectMake(frame.origin.x+2.5 -17/2, CGRectGetMaxY(self.markView.frame), 34/2, 15/2);
// CGFloat width = weakSelf.markView.width;
// UIButton *button = weakSelf.markButtonArray[idx];
// CGRect frame = [button convertRect:button.bounds toView:self];
//防止 markView 超出屏幕外
// CGFloat markViewLeft = frame.origin.x+2.5 - width/2;
// if (markViewLeft < 0) {
// markViewLeft = 0;
// }
// if (markViewLeft + width > weakSelf.frame.size.width) {
// markViewLeft = weakSelf.frame.size.width - width;
// }
// weakSelf.markView.frame = CGRectMake(markViewLeft, ScreenHeight-77/2-50,width,30);
// weakSelf.arrowImageView.frame = CGRectMake(frame.origin.x+2.5 -17/2, CGRectGetMaxY(self.markView.frame), 34/2, 15/2);
weakSelf.markView.frame = CGRectMake(0, 0, ScreenWidth, ScreenHeight);
weakSelf.markView.scrollView.frame = CGRectMake(ScreenWidth/2 - 120, ScreenHeight/2-100, 240, 200);
[weakSelf.markView.scrollView setContentOffset:CGPointMake(idx*240, 0)];
[weakSelf showOrHiddenMarkView:NO];
weakSelf.markView.index = idx;
weakSelf.markScrubtime =markModel.marktime;
//获取打点的图像
if(self.videomarkArray.count > 0){
NSMutableArray *tempArr = [NSMutableArray array];
for (DWVideoMarkModel *model in self.videomarkArray) {
UIImage *image = [self.playerView thumbnailImageForVideoAtTime:model.marktime];
model.videoImg = image;
[tempArr addObject:model];
}
if(weakSelf.markView.datasource == 0){
weakSelf.markView.datasource = tempArr;
}
}
}
}];
......@@ -3790,7 +3855,10 @@ static CGFloat barrageBgHeight = 40;
self.readyToPlay = YES;
[self hideHudWithMessage:nil];
//视频打点数据
if (self.videomarkArray && self.videomarkArray.count) {
[self dealMarkArray:self.videoModel.videomarks];
}
if (self.autoPlay) {
[self removeImg];
}
......@@ -4026,6 +4094,28 @@ static CGFloat barrageBgHeight = 40;
make.edges.equalTo(self);
}];
}
- (void)initPreView{
[self addSubview:self.preViewImage];
[self.preViewImage mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.mas_centerX);
make.centerY.equalTo(self.mas_centerY);
make.width.equalTo(@240);
make.height.equalTo(@135);
}];
[self addSubview:self.timeLabel];
[self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.mas_centerX);
make.bottom.equalTo(self.preViewImage.mas_top).offset(-4);
make.width.equalTo(@180);
make.height.equalTo(@23);
}];
[self addSubview:self.markLabel];
[self.markLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.mas_centerX);
make.top.equalTo(self.preViewImage.mas_bottom).offset(10);
make.width.equalTo(@240);
}];
}
//顶部控件
-(void)initTopFuncView
......@@ -4667,7 +4757,7 @@ static CGFloat barrageBgHeight = 40;
{
if (!_slider) {
_slider = [[DWPlayerSlider alloc]init];
[_slider addTarget:self action:@selector(sliderMovingAction) forControlEvents:UIControlEventValueChanged];
[_slider addTarget:self action:@selector(sliderMovingAction:) forControlEvents:UIControlEventValueChanged];
[_slider addTarget:self action:@selector(sliderEndedAction) forControlEvents:UIControlEventTouchUpInside | UIControlEventTouchUpOutside];
[_slider addTarget:self action:@selector(sliderBeganAction) forControlEvents:UIControlEventTouchDown];
//添加tap手势,用于视频打点功能以及点击拖拽
......@@ -4822,21 +4912,27 @@ static CGFloat barrageBgHeight = 40;
}
return _markButtonArray;
}
#pragma mark - 视频打点UI
- (DWMarkView *)markView{
if (!_markView) {
_markView = [[DWMarkView alloc]init];
_markView.backgroundColor = [DWTools colorWithHexString:@"#1e1f21"];
_markView.alpha = 0.69;
_markView.layer.cornerRadius = 15;
_markView.layer.masksToBounds = YES;
_markView = [[DWMarkView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
_markView.backgroundColor = ColorFrom16A(0x000000, 0.5);
WeakSelf(self);
_markView.block = ^(NSInteger index) {
StrongSelf(self);
DWVideoMarkModel *markModel = self.videomarkArray[index];
[self showOrHiddenMarkView:YES];
self.isShowMarkView = NO;
[self.playerView scrub:markModel.marktime];
[self play];
//为了防止打点播放后 视频进度条不走
self.isSlidering =NO;
};
[self addSubview:_markView];
UITapGestureRecognizer *tap =[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(markViewTapAction:)];
[_markView addGestureRecognizer:tap];
// UITapGestureRecognizer *tap =[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(markViewTapAction:)];
// [_markView addGestureRecognizer:tap];
}
return _markView;
}
......@@ -5115,6 +5211,36 @@ static CGFloat barrageBgHeight = 40;
return _answerArr;
}
- (UIImageView *)preViewImage{
if(!_preViewImage){
_preViewImage = [UIImageView new];
_preViewImage.hidden = YES;
}
return _preViewImage;
}
- (UILabel *)timeLabel{
if(!_timeLabel){
_timeLabel = [UILabel new];
_timeLabel.textColor = ColorFrom16A(0xffffff, 0.7);
_timeLabel.font = TitleFont(13);
_timeLabel.textAlignment = 1;
}
return _timeLabel;
}
-(UILabel *)markLabel{
if(!_markLabel){
_markLabel = [UILabel new];
_markLabel.textColor = UIColor.whiteColor;
_markLabel.textAlignment = 1;
_markLabel.numberOfLines = 2;
_markLabel.font = TitleFont(13);
}
return _markLabel;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
......
......@@ -8,11 +8,14 @@
#import <UIKit/UIKit.h>
typedef void(^DWMarkSelectBlock)(NSInteger index);
@interface DWMarkView : UIView
@property (nonatomic,strong)DWVideoMarkModel *markModel;
@property (nonatomic,assign,readonly)CGFloat width;
@property (nonatomic, strong) UIScrollView *scrollView;
@property (nonatomic, copy) NSArray *datasource;//打点数组
@property (nonatomic, assign) NSInteger index;//当前位置
@property (nonatomic, copy) DWMarkSelectBlock block;
@end
......@@ -8,93 +8,252 @@
#import "DWMarkView.h"
@interface DWMarkView()
@property (nonatomic,assign)CGFloat width;
@property (nonatomic,strong)UILabel *descLabel;
@property (nonatomic,strong)UILabel *timeLabel;
@property (nonatomic,strong)UIImageView *imageView;
@interface DWMarkView ()<UIScrollViewDelegate>
@property (nonatomic, strong) UIImageView *iv;
@property (nonatomic, strong) UIButton *leftBtn;
@property (nonatomic, strong) UIButton *rightBtn;
@end
@implementation DWMarkView
- (instancetype)initWithFrame:(CGRect)frame{
if(self = [super initWithFrame:frame]){
[self createView];
}
return self;
}
- (instancetype)init{
self =[super init];
if (self) {
- (void)setDatasource:(NSArray *)datasource{
_datasource = datasource;
self.scrollView.contentSize = CGSizeMake(datasource.count*400, 0);
for(int i = 0; i< datasource.count; i++){
DWVideoMarkModel *markModel = _datasource[i];
UIImageView *iv = [[UIImageView alloc] initWithFrame:CGRectMake(i*240, 0, 240, 135)];
iv.image = markModel.videoImg;
[self.scrollView addSubview:iv];
UIView *bottomView = [[UIView alloc] initWithFrame:CGRectMake(i*240, 140, 240, 30)];
bottomView.layer.backgroundColor = ColorFrom16A(0x000000, 0.7).CGColor;
bottomView.layer.cornerRadius = 2;
[self.scrollView addSubview:bottomView];
UILabel *leftLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, 5, 47, 20)];
leftLabel.backgroundColor = ColorFrom16A(0xff920a, 1);
leftLabel.layer.cornerRadius = 2;
leftLabel.layer.masksToBounds = YES;
leftLabel.textColor = UIColor.whiteColor;
leftLabel.font = TitleFont(13);
leftLabel.textAlignment = 1;
leftLabel.text = [NSString stringWithFormat:@"看点%d",i+1];
[bottomView addSubview:leftLabel];
[self loadSubviews];
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(5 , 5, _scrollView.frame.size.width - 10, 20)];
titleLabel.textColor = UIColor.whiteColor;
titleLabel.font = TitleFont(13);
titleLabel.numberOfLines = 2;
NSString *time = [NSString stringWithFormat:@"%ld", markModel.marktime];
time = [self getMMSSFromSS:time];
titleLabel.text = [NSString stringWithFormat:@" %@ %@", time, markModel.markdesc];
CGFloat height = [DWTools widthWithHeight:240 - 57 andFont:TitleFont(13) andLabelText:titleLabel.text].height;
if(height > 20){
bottomView.frame = CGRectMake(i*240, 140, 240, 50);
titleLabel.frame = CGRectMake(5 , 5, _scrollView.frame.size.width - 10, 40);
}
[bottomView addSubview:titleLabel];
}
return self;
if(self.index == 0){
self.leftBtn.alpha = 0.4;
}else{
self.leftBtn.alpha = 1;
}
if(self.index == self.datasource.count - 1){
self.rightBtn.alpha = 0.4;
}else{
self.rightBtn.alpha = 1;
}
}
- (void)setMarkModel:(DWVideoMarkModel *)markModel{
_markModel =markModel;
[self updateFrame];
//传入 秒 得到 xx分钟xx秒
-(NSString *)getMMSSFromSS:(NSString *)totalTime{
NSInteger seconds = [totalTime integerValue];
//format of minute
NSString *str_minute = [NSString stringWithFormat:@"%ld",seconds/60];
//format of second
NSString *str_second = [NSString stringWithFormat:@"%ld",seconds%60];
//format of time
if(str_minute.length <= 1){
str_minute = [NSString stringWithFormat:@"0%@", str_minute];
}
if(str_second.length <= 1){
str_second = [NSString stringWithFormat:@"0%@", str_second];
}
NSString *format_time = [NSString stringWithFormat:@"%@:%@",str_minute,str_second];
NSLog(@"format_time : %@",format_time);
return format_time;
}
- (void)updateFrame{
NSString *timeStr =[DWTools formatSecondsToString:_markModel.marktime];
CGSize timeSize =[self widthWithHeight:12 andFont:12 andLabelText:timeStr];
_timeLabel.text =timeStr;
_timeLabel.frame =CGRectMake(30/4,8,timeSize.width,timeSize.height);
CGSize size =[self widthWithHeight:12 andFont:12 andLabelText:_markModel.markdesc];
_descLabel.frame =CGRectMake(CGRectGetMaxX(_timeLabel.frame)+16/4,8, size.width, size.height);
_descLabel.text =_markModel.markdesc;
_imageView.frame =CGRectMake(CGRectGetMaxX(_descLabel.frame)+5,(30-16)/2,16,16);
self.width =30/4+timeSize.width+16/4+size.width+5+16+25/4;
- (void)createView{
_leftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[_leftBtn addTarget:self action:@selector(handleLeftBtn) forControlEvents:UIControlEventTouchUpInside];
[_leftBtn setImage:[UIImage imageNamed:@"left_btn_icon"] forState:0];
[self addSubview:_leftBtn];
[_leftBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self.scrollView.mas_centerY).offset(-30);
make.right.equalTo(self.scrollView.mas_left).offset(-5);
make.width.and.height.equalTo(@30);
}];
_rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[_rightBtn setImage:[UIImage imageNamed:@"right_btn_icon"] forState:0];
[_rightBtn addTarget:self action:@selector(handleRightBtn) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:_rightBtn];
[_rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self.scrollView.mas_centerY).offset(-30);
make.left.equalTo(self.scrollView.mas_right).offset(5);
make.width.and.height.equalTo(@30);
}];
}
- (void)loadSubviews{
_descLabel =[[UILabel alloc]init];
_descLabel.font =[UIFont systemFontOfSize:12];
_descLabel.textColor =[DWTools colorWithHexString:@"#ffffff"];
[self addSubview:_descLabel];
_timeLabel =[[UILabel alloc]init];
_timeLabel.font =[UIFont systemFontOfSize:12];
_timeLabel.textColor =[DWTools colorWithHexString:@"#ffffff"];
[self addSubview:_timeLabel];
_imageView =[[UIImageView alloc]init];
_imageView.image =[UIImage imageNamed:@"icon_markplay.png"];
_imageView.layer.cornerRadius =16/2;
_imageView.layer.masksToBounds =YES;
[self addSubview:_imageView];
- (void)handleLeftBtn{
if(self.index != 0){
self.index--;