DWVodPlayerView.m 145 KB
Newer Older
Han Ruisong's avatar
Han Ruisong committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//
//  DWVodPlayerView.m
//  Demo
//
//  Created by zwl on 2019/4/15.
//  Copyright © 2019 com.bokecc.www. All rights reserved.
//

#import "DWVodPlayerView.h"
#import "DWPlayerFuncBgView.h"
#import "DWPlayerSlider.h"
#import "DWPlayerSettingView.h"
#import "DWTableChooseModel.h"
#import "DWMarkView.h"
#import "DWQuestionView.h"
#import "DWFeedBackView.h"
#import "DWSubtitleView.h"
#import "DWMessageView.h"
#import <MediaPlayer/MediaPlayer.h>
#import "DWGIFManager.h"
#import "DWToastView.h"
#import "CustomDirectorFactory.h"
#import "DWGifRecordFinishView.h"
#import "DWVisitorCollectView.h"
Han Ruisong's avatar
Han Ruisong committed
25
26
#import "DWExercisesAlertView.h"
#import "DWExercisesView.h"
Han Ruisong's avatar
Han Ruisong committed
27
#import <AVKit/AVKit.h>
Han Ruisong's avatar
Han Ruisong committed
28
#import "DWVodPlayerPanGesture.h"
Han Ruisong's avatar
Han Ruisong committed
29
#import <AssetsLibrary/AssetsLibrary.h>
Han Ruisong's avatar
Han Ruisong committed
30
31
32
33
34
//弹幕
#import "OCBarrage.h"
#import "DWBarrageBgView.h"
#import "DWBarrageTextDescriptor.h"
#import "DWBarrageTextCell.h"
Han Ruisong's avatar
Han Ruisong committed
35

Han Ruisong's avatar
Han Ruisong committed
36
@interface DWVodPlayerView ()<DWVideoPlayerDelegate,DWPlayerSettingViewDelegate,DWGifRecordFinishViewDelegate,DWVisitorCollectViewDelegate,DWExercisesAlertViewDelegate,DWExercisesViewDelegate,AVPictureInPictureControllerDelegate,DWVodPlayerPanGestureDelegate,DWBarrageManagerDelegate,DWBarrageBgViewDelegate>
Han Ruisong's avatar
Han Ruisong committed
37
38
39
40
41
42
43
44
45
46
47
48

@property(nonatomic,strong)UIView * maskView;//遮罩层

@property(nonatomic,strong)DWVodVideoModel * videoModel;
@property(nonatomic,strong)DWDownloadModel * downloadModel;

//DWPlayerView
@property(nonatomic,strong)DWPlayerView * playerView;
//音频
@property(nonatomic,strong)UIView * radioBgView;
@property(nonatomic,strong)UIImageView * radioImageView;

Han Ruisong's avatar
Han Ruisong committed
49
//@property(nonatomic,assign)BOOL openWindowsPlay;//是否开启窗口播放功能
Han Ruisong's avatar
Han Ruisong committed
50
51
52
53
54
55
56
@property(nonatomic,assign)BOOL isWindowsPlay;//当前是否在小窗模式

@property(nonatomic,strong)UIPanGestureRecognizer * windowsPan;//窗口拖拽手势
@property(nonatomic,strong)UIButton * windowsCloseButton;
@property(nonatomic,strong)UIButton * windowsPlayOrPauseButton;
@property(nonatomic,strong)UIButton * windowsResumeButton;

Han Ruisong's avatar
Han Ruisong committed
57
58
59
//是否加载完毕
@property(nonatomic,assign)BOOL readyToPlay;

Han Ruisong's avatar
Han Ruisong committed
60
61
62
63
64
//是否开启后台播放
@property(nonatomic,assign)BOOL allowBackgroundPlay;
//是否开启画中画,仅对pad有效
@property(nonatomic,assign)BOOL allowPictureInPicture;

Han Ruisong's avatar
Han Ruisong committed
65
66
67
68
69
70
71
@property(nonatomic,assign)UIEdgeInsets areaInsets;
@property(nonatomic,assign)BOOL isFull;
@property(nonatomic,assign)BOOL isVideo;//当前播放模式 视频 / 音频
@property(nonatomic,assign)NSTimeInterval switchTime;
@property(nonatomic,assign)BOOL isSwitchquality;//是否切换清晰度
@property(nonatomic,assign)BOOL isLock;//锁屏

Han Ruisong's avatar
Han Ruisong committed
72
73
@property(nonatomic,strong)UITapGestureRecognizer * tap;//状态栏控制

Han Ruisong's avatar
Han Ruisong committed
74
75
@property(nonatomic,assign)CGSize titleLabelSize;

Han Ruisong's avatar
Han Ruisong committed
76
77
@property(nonatomic,assign)BOOL playRepeat;//是否进行过重试

Han Ruisong's avatar
Han Ruisong committed
78
79
80
81
82
83
84
85
//top
@property(nonatomic,strong)DWPlayerFuncBgView * topFuncBgView;
@property(nonatomic,strong)UIButton * backButton;//返回按钮
@property(nonatomic,strong)UILabel * titleLabel;//视频标题
@property(nonatomic,strong)UIButton * mediaKindButton;//媒体类型按钮
@property(nonatomic,strong)UIButton * otherFuncButton;//其他功能,字幕切换,画面尺寸之类的
@property(nonatomic,strong)UIButton * vrInteractiveButton;//vrButton
@property(nonatomic,strong)UIButton * vrDisplayButton;//vrButton
Han Ruisong's avatar
Han Ruisong committed
86
@property(nonatomic,strong)UIButton * screeningButton;//投屏按钮
Han Ruisong's avatar
Han Ruisong committed
87
@property(nonatomic,strong)UIButton * pipButton;//画中画按钮
Han Ruisong's avatar
Han Ruisong committed
88
@property(nonatomic,strong)UIButton * windowsButton;//窗口播放按钮
Han Ruisong's avatar
Han Ruisong committed
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105

//bottom
@property(nonatomic,strong)DWPlayerFuncBgView * bottomFuncBgView;
@property(nonatomic,strong)UIButton * playOrPauseButton;//开始/暂停
@property(nonatomic,strong)UIButton * nextButton;//播放下一个视频
@property(nonatomic,strong)UILabel * currentLabel;//当前时间
@property(nonatomic,strong)UILabel * lineLabel;// /!!
@property(nonatomic,strong)UILabel * totalLabel;//总时间
@property(nonatomic,strong)DWPlayerSlider * slider;//进度条,
@property(nonatomic,strong)UIButton * speedButton;//倍速
@property(nonatomic,strong)UIButton * qualityButton;//画质,清晰度
@property(nonatomic,strong)UIButton * chooseButton;//选集
@property(nonatomic,strong)UIButton * rotateScreenButton;//横竖屏切换

@property(nonatomic,strong)UIButton * gifButton;//GIF录制
@property(nonatomic,strong)UIButton * disableGesButton;//禁用页面手势

Han Ruisong's avatar
Han Ruisong committed
106
107
@property(nonatomic,strong)UIButton * screenShotButton;//截屏按钮

Han Ruisong's avatar
Han Ruisong committed
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
@property(nonatomic,strong)MBProgressHUD * hud;

//funcBgView 动画
@property(nonatomic,strong)NSTimer * funcTimer;//页面手势定时器
@property(nonatomic,assign)NSInteger funcSecond;//页面手势定时器 持续时间  默认4秒
@property(nonatomic,assign)BOOL isSlidering;//拖拽手势的定时器, 为了防止频繁拖拽引发的问题

@property(nonatomic,strong)DWPlayerSettingView * settingView;//当前设置页面

@property(nonatomic,strong)NSMutableArray <DWTableChooseModel *> * speedArray;//速率选择数据
@property(nonatomic,strong)NSMutableArray <DWTableChooseModel *> * qualityArray;//清晰度选择数据
@property(nonatomic,strong)NSMutableArray <DWTableChooseModel *> * sizeArray;//画面尺寸
@property(nonatomic,strong)NSMutableArray <DWTableChooseModel *> * selectionArray;//画面尺寸
@property(nonatomic,assign)CGFloat screenLight;//屏幕亮度
@property(nonatomic,assign)CGFloat systemSound;//系统音量
@property(nonatomic,strong)UISlider * volumeViewSlider;

Han Ruisong's avatar
Han Ruisong committed
125
@property(nonatomic,strong)HDReachability * reachability; //网络状态监听
Han Ruisong's avatar
Han Ruisong committed
126

Han Ruisong's avatar
Han Ruisong committed
127
@property(nonatomic,strong)DWVodPlayerPanGesture * pan;//亮度,音量,快进快退调节
Han Ruisong's avatar
Han Ruisong committed
128

Han Ruisong's avatar
Han Ruisong committed
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
//**************************** 视频打点 ****************************
@property(nonatomic,strong)NSArray * videomarkArray;//打点数组
@property(nonatomic,strong)NSMutableArray * markButtonArray;//按钮的数组 取坐标
@property(nonatomic,assign)CGFloat markScrubtime;
@property(nonatomic,strong)DWMarkView * markView;//打点视图
@property(nonatomic,strong)UIImageView * arrowImageView;//箭头
@property(nonatomic,assign)CGFloat sliderWidth;
@property(nonatomic,assign)BOOL isShowMarkView;

//**************************** 视频问答 ****************************
@property(nonatomic,strong)NSArray * questionArray;//问答数组
@property(nonatomic,strong)DWQuestionView * questionView;//问题显示
@property(nonatomic,strong)DWFeedBackView * feedBackView;//回答正确或错误
@property(nonatomic,strong)NSMutableArray * questionIdsArray;//问题ID,做统计使用

//**************************** 视频字幕 ****************************
@property(nonatomic,strong)NSMutableArray <DWTableChooseModel *> * subTitleArray;//字幕数组
@property(nonatomic,strong)DWSubtitleView * subtitleView;

//**************************** 授权验证 ****************************
@property (nonatomic,assign)BOOL enable;//能否完整播放;
@property (nonatomic,strong)UILabel * messageLabel;//授权验证提示
@property (nonatomic,strong)DWMessageView * messageView;//试看结束提示

//**************************** gif录制 ****************************
@property (nonatomic,strong)UIView * gifView;
@property (nonatomic,strong)UIButton * gifCancelBtn;//GIF取消按钮
@property (nonatomic,strong)NSTimer * gifTimer;//GIF定时器
@property (nonatomic,assign)CGFloat clipTime;//截取的视频时间
@property (nonatomic,assign)NSInteger gifStartTime;//制作GIF的起始时间
@property (nonatomic,assign)NSInteger gifTotalTime;//制作GIF的总时间
@property (nonatomic,strong)DWGIFManager * gifManager;
@property (nonatomic,strong)MBProgressHUD * gifHud;
@property (nonatomic,assign)BOOL isGIF;
@property (nonatomic,assign)BOOL isFirstClick;
@property (nonatomic,strong)DWToastView * toastView;

//**************************** VR ****************************
@property (nonatomic,strong)UIView * vrView;
@property (nonatomic,strong)DWVRLibrary * vrLibrary;
@property (nonatomic,strong)DWVRConfiguration * config;
@property (nonatomic,assign)DWModeInteractive interative;//交互模式
@property (nonatomic,assign)DWModeDisplay display;//单双屏

//**************************** 访客信息收集器 ****************************
@property (nonatomic,strong)DWVisitorCollectView * visitorCollectView;

Han Ruisong's avatar
Han Ruisong committed
176
//**************************** 课堂练习 ****************************
Han Ruisong's avatar
Han Ruisong committed
177
178
179
180
@property (nonatomic,assign)CGFloat exercisesFrontScrubTime;//记录回退时间
@property (nonatomic,assign)CGFloat exercisesLastScrubTime;//记录当前时间
@property (nonatomic,strong)DWExercisesAlertView * exercisesAlertView;//课堂练习提示View
@property (nonatomic,strong)DWExercisesView * exercisesView;//课堂练习view
Han Ruisong's avatar
Han Ruisong committed
181

Han Ruisong's avatar
Han Ruisong committed
182
183
184
//**************************** airPlay ****************************
@property(nonatomic,strong)UILabel * airPlayStatusLabel;

Han Ruisong's avatar
Han Ruisong committed
185
186
187
//**************************** ipad PictureInPicture ****************************
@property(nonatomic,strong)AVPictureInPictureController * pipVC;

Han Ruisong's avatar
Han Ruisong committed
188
189
190
//@property(nonatomic,strong)UILabel * testLabel;
//@property(nonatomic,strong)NSTimer * testTimer;

Han Ruisong's avatar
Han Ruisong committed
191
192
193
//**************************** marquee ****************************
@property(nonatomic,strong)HDMarqueeView * marqueeView;

Han Ruisong's avatar
Han Ruisong committed
194
195
196
197
198
199
200
201
202
203
//**************************** 弹幕 ****************************
//弹幕数据
@property(nonatomic,strong)NSArray<DWBarrageModel *> * barragesArray;
//弹幕控制视图
@property(nonatomic,strong)DWBarrageBgView * barrageBgView;
//用于获取弹幕数据以及发送弹幕
@property(nonatomic,strong)DWBarrageManager * barrageManager;
//承载弹幕
@property(nonatomic,strong)OCBarrageManager * barrage;

Han Ruisong's avatar
Han Ruisong committed
204
205
206
207
208
209
210
@end

@implementation DWVodPlayerView

static CGFloat topFuncBgHeight = 39;
static CGFloat bottomFuncBgHeight = 39;
static const CGFloat gifSeconds = 0.25;
Han Ruisong's avatar
Han Ruisong committed
211
212
static CGFloat barrageBgHeight = 40;

Han Ruisong's avatar
Han Ruisong committed
213
214
215
216
217

-(instancetype)init
{
    if (self == [super init]) {
        
Han Ruisong's avatar
Han Ruisong committed
218
        [UIApplication sharedApplication].idleTimerDisabled = YES;
Han Ruisong's avatar
Han Ruisong committed
219
        
Han Ruisong's avatar
Han Ruisong committed
220
221
222
        self.isFull = NO;
        self.isShowMarkView = NO;
        self.isLock = NO;
Han Ruisong's avatar
Han Ruisong committed
223
        self.isScreening = NO;
Han Ruisong's avatar
Han Ruisong committed
224
        //是否允许后台播放
Han Ruisong's avatar
Han Ruisong committed
225
//        self.allowBackgroundPlay = YES;
Han Ruisong's avatar
Han Ruisong committed
226
        self.allowBackgroundPlay = NO;
Han Ruisong's avatar
Han Ruisong committed
227
        self.titleLabelSize = CGSizeZero;
Han Ruisong's avatar
Han Ruisong committed
228
        
Han Ruisong's avatar
Han Ruisong committed
229
230
        self.playRepeat = NO;
        
Han Ruisong's avatar
Han Ruisong committed
231
        //是否开启小窗播放
Han Ruisong's avatar
Han Ruisong committed
232
233
        //        self.openWindowsPlay = YES;
        
Han Ruisong's avatar
Han Ruisong committed
234
        self.isWindowsPlay = NO;
Han Ruisong's avatar
Han Ruisong committed
235
        
Han Ruisong's avatar
Han Ruisong committed
236
237
238
        //是否开启画中画
        self.allowPictureInPicture = NO;
        
Han Ruisong's avatar
Han Ruisong committed
239
240
241
242
243
244
245
246
247
        self.backgroundColor = [UIColor blackColor];
        
        [self initMaskView];
        [self initTopFuncView];
        [self initDownFuncView];
        [self initLeftFuncView];
        [self initPlayerView];
        [self initRadioView];
        [self initFuncGesture];
Han Ruisong's avatar
Han Ruisong committed
248
        [self initAirPlayView];
Han Ruisong's avatar
Han Ruisong committed
249
        [self initPlayerPanGesture];
Han Ruisong's avatar
Han Ruisong committed
250
251
        //设置弹幕视图
        [self initBarrageView];
Han Ruisong's avatar
Han Ruisong committed
252
253
254
255
256
257
        
        //初始化时,默认竖屏设置
        [self hideAndClearNotNecessaryView];
        [self reLayoutWithScreenState:self.isFull];
        
        //增加网络状态监听
Han Ruisong's avatar
Han Ruisong committed
258
        self.reachability = [HDReachability reachabilityForInternetConnection];
Han Ruisong's avatar
Han Ruisong committed
259
        [self.reachability startNotifier];
Han Ruisong's avatar
Han Ruisong committed
260
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkStateChange) name:kHDReachabilityChangedNotification object:nil];
Han Ruisong's avatar
Han Ruisong committed
261
        
Han Ruisong's avatar
Han Ruisong committed
262
263
264
265
266
267
268
269
        //开启远程控制
        [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
        [self remoteControlEvent];
        
        //增加前后台切换通知
        //回到前台
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(enterForegroundNotification) name:UIApplicationWillEnterForegroundNotification object:nil];
        // app退到后台
Han Ruisong's avatar
Han Ruisong committed
270
        //        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(resignActiveNotification) name:UIApplicationWillResignActiveNotification object:nil];
Han Ruisong's avatar
Han Ruisong committed
271
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didEnterBackgroundNotification) name:UIApplicationDidEnterBackgroundNotification object:nil];
Han Ruisong's avatar
Han Ruisong committed
272
273
274
        
        //airplay监听
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(wirelessRouteActiveNotification:) name:MPVolumeViewWirelessRouteActiveDidChangeNotification object:nil];
Han Ruisong's avatar
Han Ruisong committed
275
        
Han Ruisong's avatar
Han Ruisong committed
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
        //        self.testLabel = [[UILabel alloc]init];
        //        self.testLabel.font = [UIFont systemFontOfSize:14];
        //        self.testLabel.textColor = [UIColor purpleColor];
        //        self.testLabel.textAlignment = NSTextAlignmentLeft;
        //        self.testLabel.numberOfLines = 0;
        //        [self addSubview:self.testLabel];
        //        [self.testLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        //            make.left.equalTo(@30);
        //            make.right.equalTo(@(-30));
        //            make.height.equalTo(@50);
        //            make.bottom.equalTo(self.bottomFuncBgView.mas_top).offset(-10);
        //        }];
        //
        //        self.testTimer = [NSTimer timerWithTimeInterval:1 target:self selector:@selector(testTimeAction) userInfo:nil repeats:YES];
        //        [[NSRunLoop mainRunLoop] addTimer:self.testTimer forMode:NSRunLoopCommonModes];
Han Ruisong's avatar
Han Ruisong committed
291
292
293
294
    }
    return self;
}

Han Ruisong's avatar
Han Ruisong committed
295
296
297
298
299
//-(void)testTimeAction
//{
//    self.testLabel.text = [NSString stringWithFormat:@"播放时长:%.2fs \n暂停时长:%.2fs",self.playerView.playedTimes,self.playerView.pausedTimes];
//}

Han Ruisong's avatar
Han Ruisong committed
300
301
-(void)dealloc
{
Han Ruisong's avatar
Han Ruisong committed
302
    [UIApplication sharedApplication].idleTimerDisabled = NO;
Han Ruisong's avatar
Han Ruisong committed
303
    
Han Ruisong's avatar
Han Ruisong committed
304
305
306
    //移除网络监听
    [self.reachability stopNotifier];
    self.reachability = nil;
Han Ruisong's avatar
Han Ruisong committed
307
    [[NSNotificationCenter defaultCenter] removeObserver:self name:kHDReachabilityChangedNotification object:nil];
Han Ruisong's avatar
Han Ruisong committed
308
    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillEnterForegroundNotification object:nil];
Han Ruisong's avatar
Han Ruisong committed
309
    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidEnterBackgroundNotification object:nil];
Han Ruisong's avatar
Han Ruisong committed
310
    [[NSNotificationCenter defaultCenter] removeObserver:self name:MPVolumeViewWirelessRouteActiveDidChangeNotification object:nil];
Han Ruisong's avatar
Han Ruisong committed
311
        
Han Ruisong's avatar
Han Ruisong committed
312
313
314
315
316
317
    NSLog(@"DWVodPlayerView dealloc");
}

#pragma mark - public
-(void)setVodVideo:(DWVodVideoModel *)videoModel
{
Han Ruisong's avatar
Han Ruisong committed
318
319
    //    _hud = [MBProgressHUD showHUDAddedTo:self.maskView animated:YES];
    //    _hud.label.text = @"努力加载中,请稍后";
Han Ruisong's avatar
Han Ruisong committed
320
321
    self.downloadModel = nil;
    
Han Ruisong's avatar
Han Ruisong committed
322
323
324
325
326
327
328
    [self showHudWithMessage:@"努力加载中,请稍后"];
    
    self.readyToPlay = NO;
    self.enable = YES;
    self.isSwitchquality = NO;
    
    self.videoModel = videoModel;
Han Ruisong's avatar
Han Ruisong committed
329
    
Han Ruisong's avatar
Han Ruisong committed
330
331
    self.playRepeat = NO;
    
Han Ruisong's avatar
Han Ruisong committed
332
    [self.playerView playVodViedo:videoModel withCustomId:nil];
Han Ruisong's avatar
Han Ruisong committed
333
    
Han Ruisong's avatar
Han Ruisong committed
334
    [self play];
Han Ruisong's avatar
Han Ruisong committed
335
    
Han Ruisong's avatar
Han Ruisong committed
336
337
    //处理视频清晰度数据
    [self dealQualityArray];
Han Ruisong's avatar
Han Ruisong committed
338
    
Han Ruisong's avatar
Han Ruisong committed
339
340
341
    //设置videoId,关联弹幕
    self.barrageManager.videoId = self.videoModel.videoId;
    
Han Ruisong's avatar
Han Ruisong committed
342
343
    //开启跑马灯功能
    [self initMarqueeView];
Han Ruisong's avatar
Han Ruisong committed
344
345
346
347
}

-(void)playLocalVideo:(DWDownloadModel *)downloadModel
{
Han Ruisong's avatar
Han Ruisong committed
348
349
    self.videoModel = nil;
    
Han Ruisong's avatar
Han Ruisong committed
350
351
352
353
354
    self.downloadModel  = downloadModel;
    self.enable = YES;
    
    self.readyToPlay = NO;
    
Han Ruisong's avatar
Han Ruisong committed
355
356
357
    //设置videoId,关联弹幕
    self.barrageManager.videoId = self.downloadModel.videoId;
    
Han Ruisong's avatar
Han Ruisong committed
358
359
360
361
362
363
364
365
366
367
    self.titleLabel.text = [downloadModel.othersInfo objectForKey:@"title"];
    [self.qualityButton setTitle:downloadModel.desp forState:UIControlStateNormal];
    
    [self initVRView];
    
    if ([downloadModel.mediaType isEqualToString:@"1"]) {
        [self changePlayerMediaType:YES];
    }else{
        [self changePlayerMediaType:NO];
    }
Han Ruisong's avatar
Han Ruisong committed
368
    
Han Ruisong's avatar
Han Ruisong committed
369
370
    [self.playerView playLocalVideo:downloadModel];
    [self play];
Han Ruisong's avatar
Han Ruisong committed
371
372
373
    
    //开启跑马灯功能
    [self initMarqueeView];
Han Ruisong's avatar
Han Ruisong committed
374
375
376
377
378
379
380
381
382
}

-(void)reLayoutWithScreenState:(BOOL)isFull
{
    self.isFull = isFull;
    
    [self hideAndClearNotNecessaryView];
    
    [self updateConstraintsAndHidden];
Han Ruisong's avatar
Han Ruisong committed
383
384
385
386
    
    if (self.marqueeView) {
        [self.marqueeView startMarquee];
    }
Han Ruisong's avatar
Han Ruisong committed
387
388
    
    [self.barrageBgView screenRotate:self.isFull];
Han Ruisong's avatar
Han Ruisong committed
389
390
391
392
393
}

-(void)play
{
    self.playOrPauseButton.selected = YES;
Han Ruisong's avatar
Han Ruisong committed
394
    self.windowsPlayOrPauseButton.selected = self.playOrPauseButton.selected;
Han Ruisong's avatar
Han Ruisong committed
395
396
397
398
399
400
    [self.playerView play];
}

-(void)pause
{
    self.playOrPauseButton.selected = NO;
Han Ruisong's avatar
Han Ruisong committed
401
    self.windowsPlayOrPauseButton.selected = self.playOrPauseButton.selected;
Han Ruisong's avatar
Han Ruisong committed
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
    [self.playerView pause];
}

//处理选集数据
-(void)setSelectionList:(NSArray *)selectionList
{
    _selectionList = selectionList;
    
    if (!selectionList) {
        return;
    }
    
    [self.selectionArray removeAllObjects];
    
    for (int i = 0; i < selectionList.count; i++) {
        DWVodModel * vodModel = [selectionList objectAtIndex:i];
        
        DWTableChooseModel * chooseModel = [[DWTableChooseModel alloc]init];
        chooseModel.title = vodModel.title;
        [self.selectionArray addObject:chooseModel];
    }
Han Ruisong's avatar
Han Ruisong committed
423
    
Han Ruisong's avatar
Han Ruisong committed
424
425
426
427
428
}

//关闭播放器
-(void)closePlayer
{
Han Ruisong's avatar
Han Ruisong committed
429
430
    //    [self.testTimer invalidate];
    //    self.testTimer = nil;
Han Ruisong's avatar
Han Ruisong committed
431
    
Han Ruisong's avatar
Han Ruisong committed
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
    [self destroyFuncTimer];
    
    //清理player
    [self.playerView removeTimer];
    [self.playerView resetPlayer];
    
    //关闭远程控制
    [[UIApplication sharedApplication] endReceivingRemoteControlEvents];
    
    if (self.config) {
        self.config = nil;
    }
    if (self.vrLibrary) {
        self.vrLibrary = nil;
    }
}

//播放在线视频时,设置文件名
-(void)setVodModel:(DWVodModel *)vodModel
{
    _vodModel = vodModel;
    
    self.titleLabel.text = vodModel.title;
}

Han Ruisong's avatar
Han Ruisong committed
457
458
459
460
461
-(NSString *)videoTitle
{
    return self.titleLabel.text;
}

Han Ruisong's avatar
Han Ruisong committed
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
-(void)playFailureRepeat
{
    if (self.videoModel && !self.playRepeat) {
        //在线媒体,且未进行过重试
        if (self.playerView.qualityModel) {
            [self showHudWithMessage:@"努力加载中,请稍后"];
            [self.playerView switchQuality:self.playerView.qualityModel withCustomId:nil];
            [self play];
        }
            
        self.playRepeat = YES;
    }else{
        [@"播放失败,请重试" showAlert];
        
        [self hideHudWithMessage:nil];
    }
}

Han Ruisong's avatar
Han Ruisong committed
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
#pragma mark - function
//保存videoModel ,并对打点,问答,字幕等功能数据进行处理
-(void)setVideoModel:(DWVodVideoModel *)videoModel
{
    _videoModel = videoModel;
    
    self.titleLabel.text = videoModel.title;
    
    //处理VR
    [self initVRView];
    
    //处理选集数据
    [self dealChooseArray];
    
    //处理视频打点数据
    self.isShowMarkView = NO;
    if (videoModel.videomarks.count) {
        self.videomarkArray = videoModel.videomarks;
    }
    
    //处理问答数据
    self.questionArray = videoModel.questions;
    
    //处理字幕数据
    [self dealSubtitleArray];
    
    //处理授权验证数据
    if (videoModel.authorize) {
        [self dealAuthorizeData];
    }
Han Ruisong's avatar
Han Ruisong committed
510
    
Han Ruisong's avatar
Han Ruisong committed
511
512
513
514
515
}

//更新约束和控件状态
-(void)updateConstraintsAndHidden
{
Han Ruisong's avatar
Han Ruisong committed
516
517
518
519
520
    NSInteger buttonCount = 1;
    if (IS_PAD) {
        buttonCount++;
    }
    
Han Ruisong's avatar
Han Ruisong committed
521
    if (self.isFull) {
Han Ruisong's avatar
Han Ruisong committed
522
        
Han Ruisong's avatar
Han Ruisong committed
523
524
525
526
527
528
529
530
531
532
533
534
        [_playerView mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self);
        }];
        
        [_radioBgView mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self);
        }];
        
        [_maskView mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self);
        }];
        
Han Ruisong's avatar
Han Ruisong committed
535
536
537
        self.otherFuncButton.hidden = NO;
        self.speedButton.hidden = NO;
        self.qualityButton.hidden = !self.isVideo;
Han Ruisong's avatar
Han Ruisong committed
538
        
Han Ruisong's avatar
Han Ruisong committed
539
540
541
542
543
544
545
546
547
        if (self.downloadModel) {
            self.chooseButton.hidden = YES;
            self.nextButton.hidden = YES;
        }else{
            self.chooseButton.hidden = NO;
            self.nextButton.hidden = NO;
        }
        self.gifButton.hidden = NO;
        self.disableGesButton.hidden = NO;
Han Ruisong's avatar
Han Ruisong committed
548
        self.screenShotButton.hidden = NO;
Han Ruisong's avatar
Han Ruisong committed
549
550
551
552
553
554
555
556
557
558
559
560
        
        //根据状态 切换字幕
        [self switchSubtitleStyle];
        
        if (self.funcTimer) {
            [_topFuncBgView mas_updateConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(@0);
                make.height.equalTo(@(20 + topFuncBgHeight));
            }];
            
            [_bottomFuncBgView mas_updateConstraints:^(MASConstraintMaker *make) {
                make.bottom.equalTo(@0);
Han Ruisong's avatar
Han Ruisong committed
561
                make.height.equalTo(@(self.areaInsets.bottom + bottomFuncBgHeight + barrageBgHeight));
Han Ruisong's avatar
Han Ruisong committed
562
            }];
Han Ruisong's avatar
Han Ruisong committed
563

Han Ruisong's avatar
Han Ruisong committed
564
565
566
567
568
569
570
        }else{
            [_topFuncBgView mas_updateConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(@(-(20 + topFuncBgHeight)));
                make.height.equalTo(@(20 + topFuncBgHeight));
            }];
            
            [_bottomFuncBgView mas_updateConstraints:^(MASConstraintMaker *make) {
Han Ruisong's avatar
Han Ruisong committed
571
572
                make.bottom.equalTo(@(self.areaInsets.bottom + bottomFuncBgHeight + barrageBgHeight));
                make.height.equalTo(@(self.areaInsets.bottom + bottomFuncBgHeight + barrageBgHeight));
Han Ruisong's avatar
Han Ruisong committed
573
574
            }];

Han Ruisong's avatar
Han Ruisong committed
575
576
        }
        
Han Ruisong's avatar
Han Ruisong committed
577
578
579
580
        UIDeviceOrientation orientation = [UIDevice currentDevice].orientation;
        UIInterfaceOrientation interfaceOrientation = (UIInterfaceOrientation)orientation;
        
        if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
Han Ruisong's avatar
Han Ruisong committed
581
            
Han Ruisong's avatar
Han Ruisong committed
582
583
584
585
            [_gifButton mas_updateConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(@(-self.areaInsets.right));
            }];
            
Han Ruisong's avatar
Han Ruisong committed
586
587
588
589
590
591
            [_screenShotButton mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(@(-self.areaInsets.right));
                make.centerY.equalTo(self.mas_centerY).offset(-24);
                make.width.and.height.equalTo(@30);
            }];
            
Han Ruisong's avatar
Han Ruisong committed
592
593
594
            [_disableGesButton mas_updateConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(@10);
            }];
Han Ruisong's avatar
Han Ruisong committed
595
            
Han Ruisong's avatar
Han Ruisong committed
596
597
        }
        if (interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
Han Ruisong's avatar
Han Ruisong committed
598
            
Han Ruisong's avatar
Han Ruisong committed
599
600
601
602
            [_gifButton mas_updateConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(@(-10));
            }];
            
Han Ruisong's avatar
Han Ruisong committed
603
604
605
606
607
608
            [_screenShotButton mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(@(-10));
                make.centerY.equalTo(self.mas_centerY).offset(-24);
                make.width.and.height.equalTo(@30);
            }];
            
Han Ruisong's avatar
Han Ruisong committed
609
610
611
            [_disableGesButton mas_updateConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(@(self.areaInsets.left));
            }];
Han Ruisong's avatar
Han Ruisong committed
612
            
Han Ruisong's avatar
Han Ruisong committed
613
        }
Han Ruisong's avatar
Han Ruisong committed
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640

        [self.currentLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@20);
            make.top.equalTo(@((barrageBgHeight - self.titleLabelSize.height) / 2.0));
            make.height.equalTo(@(self.titleLabelSize.height));
            make.width.equalTo(@(self.titleLabelSize.width));
        }];
        
        [self.totalLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(@(-20));
            make.centerY.equalTo(self.currentLabel);
            make.height.equalTo(@(self.titleLabelSize.height));
            make.width.equalTo(@(self.titleLabelSize.width));
        }];
        
        [self.slider mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.currentLabel.mas_right).offset(15);
            make.right.equalTo(self.totalLabel.mas_left).offset(-15);
            make.height.equalTo(@30);
            make.centerY.equalTo(self.currentLabel);
        }];
        
        [self.playOrPauseButton mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(@(barrageBgHeight + 4.5));
            make.width.and.height.equalTo(@30);
            make.left.equalTo(@10);
        }];
Han Ruisong's avatar
Han Ruisong committed
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
        
        //本地模式 不显示选集按钮。页面控件做调整
        if (self.isVideo) {
            
            if (self.chooseButton.hidden) {
                [_speedButton mas_updateConstraints:^(MASConstraintMaker *make) {
                    make.right.equalTo(@(-(40 * 1) - 10));
                }];
                
                [_qualityButton mas_updateConstraints:^(MASConstraintMaker *make) {
                    make.right.equalTo(@(-(40 * 0) - 10));
                }];
            }else{
                [_speedButton mas_updateConstraints:^(MASConstraintMaker *make) {
                    make.right.equalTo(@(-(40 * 2) - 10));
                }];
                
                [_qualityButton mas_updateConstraints:^(MASConstraintMaker *make) {
                    make.right.equalTo(@(-(40 * 1) - 10));
                }];
                
                [_chooseButton mas_updateConstraints:^(MASConstraintMaker *make) {
                    make.right.equalTo(@(-(40 * 0) - 10));
                }];
            }
            
        }else{
            
            if (self.chooseButton.hidden) {
                [_speedButton mas_updateConstraints:^(MASConstraintMaker *make) {
                    make.right.equalTo(@(-(40 * 0) - 10));
                }];
            }else{
                [_speedButton mas_updateConstraints:^(MASConstraintMaker *make) {
                    make.right.equalTo(@(-(40 * 1) - 10));
                }];
                
                [_chooseButton mas_updateConstraints:^(MASConstraintMaker *make) {
                    make.right.equalTo(@(-(40 * 0) - 10));
                }];
            }
        }
        
        //本地模式 ,不显示下一集按钮
        if (self.nextButton.hidden) {
            [_nextButton mas_updateConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(self.playOrPauseButton.mas_right);
                make.width.equalTo(@0);
            }];
        }else{
            [_nextButton mas_updateConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(self.playOrPauseButton.mas_right).offset(5);
                make.width.equalTo(@30);
            }];
        }
        
Han Ruisong's avatar
Han Ruisong committed
697
698
699
700
701
702
703
704
705
        [self.barrageBgView removeFromSuperview];
        [self.bottomFuncBgView addSubview:self.barrageBgView];
        [self.barrageBgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.nextButton.mas_right).offset(15);
            make.centerY.equalTo(self.playOrPauseButton);
            make.height.equalTo(@(barrageBgHeight));
            make.right.equalTo(self.speedButton.mas_left).offset(-15);
        }];
        
Han Ruisong's avatar
Han Ruisong committed
706
707
708
709
710
711
712
713
714
715
716
717
        //VR
        //此种方法组合可以实现Motion下的正确方向
        if (self.videoModel.vrmode == 1 || self.downloadModel.vrMode) {
            BOOL haveMotion = NO;
            if (_interative ==DWModeInteractiveMotion || _interative ==DWModeInteractiveMotionWithTouch) {
                haveMotion = YES;
            }
            if (haveMotion) {
                [self.vrLibrary switchInteractiveMode:DWModeInteractiveTouch];
                [self.vrLibrary switchInteractiveMode:DWModeInteractiveMotion];
            }
            [self.vrLibrary switchInteractiveMode:_interative];
Han Ruisong's avatar
Han Ruisong committed
718
            
Han Ruisong's avatar
Han Ruisong committed
719
            [_vrInteractiveButton mas_updateConstraints:^(MASConstraintMaker *make) {
Han Ruisong's avatar
Han Ruisong committed
720
                make.right.equalTo(@(-(40 * buttonCount) - 10));
Han Ruisong's avatar
Han Ruisong committed
721
            }];
Han Ruisong's avatar
Han Ruisong committed
722
            
Han Ruisong's avatar
Han Ruisong committed
723
            [_vrDisplayButton mas_updateConstraints:^(MASConstraintMaker *make) {
Han Ruisong's avatar
Han Ruisong committed
724
                make.right.equalTo(@(-(40 * (buttonCount + 1)) - 10));
Han Ruisong's avatar
Han Ruisong committed
725
            }];
Han Ruisong's avatar
Han Ruisong committed
726
        }
Han Ruisong's avatar
Han Ruisong committed
727
        
Han Ruisong's avatar
Han Ruisong committed
728
    }else{
Han Ruisong's avatar
Han Ruisong committed
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
        
        [_playerView mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.and.top.equalTo(@0);
            make.width.equalTo(self);
            make.bottom.equalTo(@(-barrageBgHeight));
        }];
        
        [_radioBgView mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.and.top.equalTo(@0);
            make.width.equalTo(self);
            make.bottom.equalTo(@(-barrageBgHeight));
        }];
        
        [_maskView mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.and.top.equalTo(@0);
            make.width.equalTo(self);
            make.bottom.equalTo(@(-barrageBgHeight));
        }];
        
Han Ruisong's avatar
Han Ruisong committed
748
        self.mediaKindButton.hidden = NO;
Han Ruisong's avatar
Han Ruisong committed
749
        self.screeningButton.hidden = NO;
Han Ruisong's avatar
Han Ruisong committed
750
        self.windowsButton.hidden = NO;
Han Ruisong's avatar
Han Ruisong committed
751
        self.lineLabel.hidden = NO;
Han Ruisong's avatar
Han Ruisong committed
752
        
Han Ruisong's avatar
Han Ruisong committed
753
754
755
        self.rotateScreenButton.hidden = NO;
        //回复锁屏状态
        self.disableGesButton.selected = NO;
Han Ruisong's avatar
Han Ruisong committed
756
        self.screenShotButton.hidden = NO;
Han Ruisong's avatar
Han Ruisong committed
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
        self.isLock = NO;
        //如果正在录制gif ,取消
        if (self.isGIF) {
            [self gifCancelAction];
        }
        
        //隐藏字幕
        if (self.subtitleView) {
            [self.subtitleView switchSubtitleStyle:3];
        }
        
        if (self.funcTimer) {
            [_topFuncBgView mas_updateConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(@0);
                make.height.equalTo(@(self.areaInsets.top + topFuncBgHeight));
            }];
Han Ruisong's avatar
Han Ruisong committed
773

Han Ruisong's avatar
Han Ruisong committed
774
            [_bottomFuncBgView mas_updateConstraints:^(MASConstraintMaker *make) {
Han Ruisong's avatar
Han Ruisong committed
775
                make.bottom.equalTo(@(-barrageBgHeight));
Han Ruisong's avatar
Han Ruisong committed
776
777
                make.height.equalTo(@(bottomFuncBgHeight));
            }];
Han Ruisong's avatar
Han Ruisong committed
778

Han Ruisong's avatar
Han Ruisong committed
779
780
781
782
783
784
785
786
787
788
789
        }else{
            [_topFuncBgView mas_updateConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(@(-(self.areaInsets.top + topFuncBgHeight)));
                make.height.equalTo(@(self.areaInsets.top + topFuncBgHeight));
            }];
            
            [_bottomFuncBgView mas_updateConstraints:^(MASConstraintMaker *make) {
                make.bottom.equalTo(@(bottomFuncBgHeight));
                make.height.equalTo(@(bottomFuncBgHeight));
            }];
        }
Han Ruisong's avatar
Han Ruisong committed
790
        
Han Ruisong's avatar
Han Ruisong committed
791
792
793
794
795
        [_nextButton mas_updateConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.playOrPauseButton.mas_right);
            make.width.equalTo(@0);
        }];
        
Han Ruisong's avatar
Han Ruisong committed
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
        [self.playOrPauseButton mas_remakeConstraints:^(MASConstraintMaker *make) {
             make.top.equalTo(@(4.5));
             make.width.and.height.equalTo(@30);
             make.left.equalTo(@10);
         }];
        
        [_currentLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.nextButton.mas_right).offset(5);
            make.centerY.equalTo(self.playOrPauseButton);
            make.height.equalTo(@(self.titleLabelSize.height));
            make.width.equalTo(@(self.titleLabelSize.width));
        }];
        [_lineLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.currentLabel.mas_right).offset(2.5);
            make.centerY.equalTo(self.playOrPauseButton);
            make.height.equalTo(@(self.lineLabel.frame.size.height));
            make.width.equalTo(@(self.lineLabel.frame.size.width));
        }];
        [_totalLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.lineLabel.mas_right).offset(2.5);
            make.centerY.equalTo(self.playOrPauseButton);
            make.height.equalTo(@(self.titleLabelSize.height));
            make.width.equalTo(@(self.titleLabelSize.width));
        }];
  
        [_slider mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.totalLabel.mas_right).offset(5);
            make.centerY.equalTo(self.playOrPauseButton);
            make.height.equalTo(@30);
Han Ruisong's avatar
Han Ruisong committed
825
826
            make.right.equalTo(@(-45));
        }];
Han Ruisong's avatar
Han Ruisong committed
827
828
829
830
831
832
833
834
835
836
837
838
839
840
        [_rotateScreenButton mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(@(-5));
            make.centerY.equalTo(self.playOrPauseButton);
            make.width.equalTo(@30);
            make.height.equalTo(@30);
        }];

        [self.barrageBgView removeFromSuperview];
        [self insertSubview:self.barrageBgView aboveSubview:self.bottomFuncBgView];
        [self.barrageBgView mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(@0);
            make.left.and.right.equalTo(@0);
            make.height.equalTo(@(barrageBgHeight));
        }];
Han Ruisong's avatar
Han Ruisong committed
841
842
843
844
845
846
847
848
849
850
851
        
        if (self.videoModel.vrmode == 1 || self.downloadModel.vrMode) {
            BOOL haveMotion = NO;
            if (_interative == DWModeInteractiveMotion || _interative == DWModeInteractiveMotionWithTouch) {
                haveMotion =YES;
            }
            if (haveMotion) {
                [self.vrLibrary switchInteractiveMode:DWModeInteractiveTouch];
                [self.vrLibrary switchInteractiveMode:DWModeInteractiveMotion];
            }
            [self.vrLibrary switchInteractiveMode:_interative];
Han Ruisong's avatar
Han Ruisong committed
852
853
            
            [_vrInteractiveButton mas_updateConstraints:^(MASConstraintMaker *make) {
Han Ruisong's avatar
Han Ruisong committed
854
                //                make.right.equalTo(@(-(40 * (buttonCount + 1)) - 10));
Han Ruisong's avatar
Han Ruisong committed
855
                make.right.equalTo(@(-(40 * (buttonCount + 2)) - 10));
Han Ruisong's avatar
Han Ruisong committed
856
857
858
            }];
            
            [_vrDisplayButton mas_updateConstraints:^(MASConstraintMaker *make) {
Han Ruisong's avatar
Han Ruisong committed
859
                //                make.right.equalTo(@(-(40 * (buttonCount + 2)) - 10));
Han Ruisong's avatar
Han Ruisong committed
860
                make.right.equalTo(@(-(40 * (buttonCount + 3)) - 10));
Han Ruisong's avatar
Han Ruisong committed
861
            }];
Han Ruisong's avatar
Han Ruisong committed
862
        }
Han Ruisong's avatar
Han Ruisong committed
863
        
Han Ruisong's avatar
Han Ruisong committed
864
865
866
867
868
        [_screenShotButton mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@10);
            make.centerY.equalTo(self);
            make.width.and.height.equalTo(@30);
        }];
Han Ruisong's avatar
Han Ruisong committed
869
870
871
872
873
874
    }
    
    //访客信息收集器
    if (self.visitorCollectView) {
        [self.visitorCollectView screenRotate:self.isFull];
    }
Han Ruisong's avatar
Han Ruisong committed
875
    
Han Ruisong's avatar
Han Ruisong committed
876
877
    [self setNeedsLayout];
    [self layoutIfNeeded];
Han Ruisong's avatar
Han Ruisong committed
878
    
Han Ruisong's avatar
Han Ruisong committed
879
880
881
    //修改弹幕视图frame
    self.barrage.renderView.frame = self.playerView.bounds;
    
Han Ruisong's avatar
Han Ruisong committed
882
883
    //获取到真实位置后,重置进度条位置
    [self.slider resetSubViewFrame];
Han Ruisong's avatar
Han Ruisong committed
884
885
886
887
888
889
890
891
}

//清理和隐藏页面控件
-(void)hideAndClearNotNecessaryView
{
    //top
    self.mediaKindButton.hidden = YES;
    self.otherFuncButton.hidden = YES;
Han Ruisong's avatar
Han Ruisong committed
892
    self.screeningButton.hidden = YES;
Han Ruisong's avatar
Han Ruisong committed
893
    self.windowsButton.hidden = YES;
Han Ruisong's avatar
Han Ruisong committed
894
895
896
897
898
899
900
    
    //bottom
    self.nextButton.hidden = YES;
    self.speedButton.hidden = YES;
    self.qualityButton.hidden = YES;
    self.chooseButton.hidden = YES;
    self.rotateScreenButton.hidden = YES;
Han Ruisong's avatar
Han Ruisong committed
901
902
    self.lineLabel.hidden = YES;
    
Han Ruisong's avatar
Han Ruisong committed
903
904
905
    //left
    self.gifButton.hidden = YES;
    self.disableGesButton.hidden = YES;
Han Ruisong's avatar
Han Ruisong committed
906
    self.screenShotButton.hidden = YES;
Han Ruisong's avatar
Han Ruisong committed
907
    
Han Ruisong's avatar
Han Ruisong committed
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
    //打点视图隐藏
    self.isShowMarkView = NO;
    [self showOrHiddenMarkView:YES];
    if (self.videomarkArray && self.videomarkArray.count) {
        //有打点数据
        [self dealMarkArray:self.videomarkArray];
    }
}

//处理清晰度数据
-(void)dealQualityArray
{
    [self.qualityArray removeAllObjects];
    
    if (!self.videoModel.videoQualities || self.videoModel.videoQualities.count == 0) {
        //无视频清晰度
        [self changePlayerMediaType:NO];
    }else if (!self.videoModel.radioQualities || self.videoModel.radioQualities.count == 0){
        //无音频清晰度
        [self changePlayerMediaType:YES];
    }else{
        [self changePlayerMediaType:YES];
    }
    
    for (DWVideoQualityModel * quality in self.videoModel.videoQualities) {
        DWTableChooseModel * chooseModel = [[DWTableChooseModel alloc]init];
        chooseModel.title = quality.desp;
        if ([quality.quality isEqualToString:self.playerView.qualityModel.quality]) {
            chooseModel.isSelect = YES;
        }else{
            chooseModel.isSelect = NO;
        }
        [self.qualityArray addObject:chooseModel];
    }
    
    [self.qualityButton setTitle:self.playerView.qualityModel.desp forState:UIControlStateNormal];
}

//处理选集默认数据
-(void)dealChooseArray
{
    if (self.selectionArray.count == 0) {
        return;
    }
    
    for (int i = 0; i < self.selectionList.count; i++) {
        DWTableChooseModel * chooseModel = [self.selectionArray objectAtIndex:i];
        //这里应该是拿videoId做判断
        DWVodModel * vodModel = [self.selectionList objectAtIndex:i];
        if ([vodModel.videoId isEqualToString:self.videoModel.videoId]) {
            chooseModel.isSelect = YES;
        }else{
            chooseModel.isSelect = NO;
        }
    }
}

//切换页面播放模式
-(void)changePlayerMediaType:(BOOL)isVideo
{
    self.mediaKindButton.selected = !isVideo;
    self.isVideo = isVideo;
    if (self.isVideo) {
        self.radioBgView.hidden = YES;
        if (self.videoModel.vrmode == 1 || self.downloadModel.vrMode) {
            self.vrView.hidden = NO;
        }else{
            self.playerView.hidden = NO;
        }
    }else{
        self.radioBgView.hidden = NO;
        self.playerView.hidden = YES;
    }
    
    //清理视频打点数据
    if (self.videomarkArray && self.videomarkArray.count) {
        [self dealMarkArray:self.videoModel.videomarks];
    }
    
    //取消gif录制
    if (self.isGIF) {
        [self gifCancelAction];
    }
    
    if (self.isFull) {
        self.qualityButton.hidden = !self.isVideo;
        if (self.isVideo) {
            //显示清晰度按钮
            [_slider mas_updateConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(@(-(40 * 3) - 10 - 5));
            }];
            
            [_speedButton mas_updateConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(@(-(40 * 2) - 10));
            }];
        }else{
            //隐藏清晰度按钮
            [_slider mas_updateConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(@(-(40 * 2) - 10 - 5));
            }];
            
            [_speedButton mas_updateConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(@(-(40 * 1) - 10));
            }];
        }
    }
Han Ruisong's avatar
Han Ruisong committed
1014
    
Han Ruisong's avatar
Han Ruisong committed
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
}

//切换清晰度
-(void)switchQuality:(DWVideoQualityModel *)qualityModel
{
    if (!qualityModel) {
        [_hud hideAnimated:NO];
        [@"暂未找到当前清晰度,请检查数据" showAlert];
        return;
    }
    
    self.readyToPlay = NO;
    
Han Ruisong's avatar
Han Ruisong committed
1028
1029
    self.playRepeat = NO;
    
Han Ruisong's avatar
Han Ruisong committed
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
    //如果VR视图存在,需要重新创建
    if (self.vrView) {
        [self.vrView removeFromSuperview];
        self.vrView = nil;
    }
    [self initVRView];
    
    if ([qualityModel.mediaType isEqualToString:@"1"] && !self.isVideo) {
        [self changePlayerMediaType:YES];
    }else if ([qualityModel.mediaType isEqualToString:@"2"] && self.isVideo) {
        [self changePlayerMediaType:NO];
    }
    
    //修改当前清晰度
    if (self.isVideo) {
        NSInteger selectIndex = [self.videoModel.videoQualities indexOfObject:qualityModel];
        DWTableChooseModel * chooseModel = [self.qualityArray objectAtIndex:selectIndex];
        if (!chooseModel.isSelect) {
            for (DWTableChooseModel * chooseModel in self.qualityArray) {
                if (chooseModel.isSelect) {
                    chooseModel.isSelect = NO;
                    break;
                }
            }
        }
        chooseModel.isSelect = YES;
    }
    
    //清理默认值
    self.currentLabel.text = @"00:00";
    self.totalLabel.text = @"00:00";
    self.slider.value = 0;
    self.slider.bufferValue = 0;
    self.isSwitchquality = YES;
    self.switchTime = CMTimeGetSeconds([self.playerView.player currentTime]);
    
    [self pause];
Han Ruisong's avatar
Han Ruisong committed
1067
1068
1069
    
    //    _hud = [MBProgressHUD showHUDAddedTo:self.maskView animated:YES];
    //    _hud.label.text = @"切换清晰度,请稍后";
Han Ruisong's avatar
Han Ruisong committed
1070
    [self showHudWithMessage:@"切换中..."];
Han Ruisong's avatar
Han Ruisong committed
1071
    
Han Ruisong's avatar
Han Ruisong committed
1072
    //    self.currentQualityModel = qualityModel;
Han Ruisong's avatar
Han Ruisong committed
1073
1074
1075
    
    [self.qualityButton setTitle:qualityModel.desp forState:UIControlStateNormal];
    [self.playerView switchQuality:qualityModel withCustomId:nil];
Han Ruisong's avatar
Han Ruisong committed
1076
1077
1078
1079
1080
    
    //如果播放加密视频时,SDK解密服务需要一定的时间启动,这里延迟执行play。
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self play];
    });
Han Ruisong's avatar
Han Ruisong committed
1081
    //    [self play];
Han Ruisong's avatar
Han Ruisong committed
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
}

-(void)showHudWithMessage:(NSString *)message
{
    if (_hud) {
        [_hud hideAnimated:NO];
        self.hud = nil;
    }
    _hud = [MBProgressHUD showHUDAddedTo:self.maskView animated:YES];
    _hud.label.text = message;
}

-(void)hideHudWithMessage:(NSString *)message
{
    if (_hud) {
        if (message) {
            _hud.label.text = message;
            [_hud hideAnimated:YES afterDelay:2];
        }else{
            [_hud hideAnimated:YES];
        }
    }
    self.hud = nil;
}

//记忆播放
-(void)saveNsUserDefaults
{
    if (!self.videoModel && !self.downloadModel) {
        return;
    }
    
    NSUserDefaults * userDefaults = [NSUserDefaults standardUserDefaults];
    NSNumber * playTime = [NSNumber numberWithFloat:CMTimeGetSeconds([self.playerView.player currentTime])];
    if (self.videoModel) {
        [userDefaults setValue:playTime forKey:self.videoModel.videoId];
    }else{
        [userDefaults setValue:playTime forKey:self.downloadModel.filePath];
    }
    [userDefaults synchronize];
}

-(void)readNSUserDefaults
{
    if (!self.videoModel && !self.downloadModel) {
        return;
    }
    
    CGFloat playTime = 0;
    NSUserDefaults * userDefaults = [NSUserDefaults standardUserDefaults];
    
    id saveTime = nil;
    if (self.videoModel) {
        saveTime = [userDefaults objectForKey:self.videoModel.videoId];
    }else{
        saveTime = [userDefaults objectForKey:self.downloadModel.filePath];
    }
    if ([saveTime isKindOfClass:[NSDictionary class]]) {
        //旧版本存储的播放数据
        playTime = [[saveTime objectForKey:@"playbackTime"] floatValue];
    }else{
        playTime = [saveTime floatValue];
    }
    
    //若不考虑旧版本的兼容性问题,这里直接获取即可
Han Ruisong's avatar
Han Ruisong committed
1147
1148
1149
1150
1151
    //    if (self.videoModel) {
    //        playTime = [[userDefaults objectForKey:self.videoModel.videoId] floatValue];
    //    }else{
    //        playTime = [[userDefaults objectForKey:self.downloadModel.filePath] floatValue];
    //    }
Han Ruisong's avatar
Han Ruisong committed
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
    
    self.switchTime = playTime;
}

//切换备用线路
-(void)switchSparLine
{
    if (self.playerView.isSpar) {
        [@"当前已经是备用线路了" showAlert];
        return;
    }
    
    [self showHudWithMessage:@"切换线路中,请稍后"];
    
    //记录当前播放到的时间
    if (!CMTimeCompare(self.playerView.player.currentTime, kCMTimeZero)) {
        self.switchTime = CMTimeGetSeconds([self.playerView.player currentTime]);
    }
    
    [self.playerView switchSparPlayLine];
    
}

Han Ruisong's avatar
Han Ruisong committed
1175
-(void)startDownloadTask:(DWVodVideoModel *)vodVideo
Han Ruisong's avatar
Han Ruisong committed
1176
{
Han Ruisong's avatar
Han Ruisong committed
1177
    DWVideoQualityModel * qualitiyModel = self.playerView.qualityModel;
Han Ruisong's avatar
Han Ruisong committed
1178
    
Han Ruisong's avatar
Han Ruisong committed
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
    DWDownloadSessionManager * manager = [DWDownloadSessionManager manager];
    //验证当前任务是否已经在下载队列中
    if ([manager checkLocalResourceWithVideoId:self.videoModel.videoId WithQuality:qualitiyModel.quality]) {
        [@"当前任务已经在下载队列中" showAlert];
        return;
    }
    
    NSString * imageUrl = nil;
    NSString * title = @"";
    if (self.vodModel) {
        imageUrl = self.vodModel.imageUrl;
        title = self.vodModel.title;
Han Ruisong's avatar
Han Ruisong committed
1191
    }else{
Han Ruisong's avatar
Han Ruisong committed
1192
        imageUrl = @"icon_placeholder.png";
Han Ruisong's avatar
Han Ruisong committed
1193
    }
Han Ruisong's avatar
Han Ruisong committed
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
    
    DWDownloadModel * model = [DWDownloadSessionManager createDownloadModel:vodVideo Quality:qualitiyModel.quality AndOthersInfo:@{@"imageUrl":imageUrl,@"title":title}];
    
    if (!model) {
        [@"DownloadModel创建失败,请检查参数" showAlert];
        return;
    }
    
    [manager startWithDownloadModel:model];
    
    [[NSString stringWithFormat:@"开始下载:%@",vodVideo.title] showAlert];
Han Ruisong's avatar
Han Ruisong committed
1205
1206
}

Han Ruisong's avatar
Han Ruisong committed
1207
1208
1209
#pragma mark - func Timer
-(void)initFuncGesture
{
Han Ruisong's avatar
Han Ruisong committed
1210
1211
    self.tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(funcIsAppearTap)];
    [self addGestureRecognizer:self.tap];
Han Ruisong's avatar
Han Ruisong committed
1212
    
Han Ruisong's avatar
Han Ruisong committed
1213
1214
1215
1216
1217
    [self createFuncTimer];
}

-(void)funcIsAppearTap
{
Han Ruisong's avatar
Han Ruisong committed
1218
1219
1220
1221
1222
    //新增判断,画中画启动时,不显示状态栏
    if (self.pipVC && self.pipVC.isPictureInPictureActive) {
        return;
    }
    
Han Ruisong's avatar
Han Ruisong committed
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
    if (self.funcTimer) {
        self.isShowMarkView = NO;
        [self destroyFuncTimer];
    }else{
        [self createFuncTimer];
    }
}

//func timer 相关
-(void)createFuncTimer
{
    self.funcSecond = 4;
    
    if (self.funcTimer) {
        [self.funcTimer invalidate];
        self.funcTimer = nil;
    }
    
    self.funcTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(funcTimerAction) userInfo:nil repeats:YES];
    
    [self funcBgViewIsAppear:YES];
}

-(void)destroyFuncTimer
{
    if (self.funcTimer) {
        [self.funcTimer invalidate];
        self.funcTimer = nil;
    }
    
    [self funcBgViewIsAppear:NO];
}

-(void)funcTimerAction
{
    if (self.funcSecond == 0) {
        [self destroyFuncTimer];
        return;
    }
    
    self.funcSecond--;
}

-(void)funcBgViewIsAppear:(BOOL)appear
{
    CGFloat topHeight = self.isFull ? 20 + topFuncBgHeight : self.areaInsets.top + topFuncBgHeight;
Han Ruisong's avatar
Han Ruisong committed
1269
1270
1271

    CGFloat bottomHeight = self.isFull ? self.areaInsets.bottom + bottomFuncBgHeight + barrageBgHeight : bottomFuncBgHeight;

Han Ruisong's avatar
Han Ruisong committed
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
    UIDeviceOrientation orientation = [UIDevice currentDevice].orientation;
    UIInterfaceOrientation interfaceOrientation = (UIInterfaceOrientation)orientation;
    
    if (self.isLock) {
        [_topFuncBgView mas_updateConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(@(-topHeight));
            make.height.equalTo(@(topHeight));
        }];
        
        [_bottomFuncBgView mas_updateConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(@(bottomHeight));
            make.height.equalTo(@(bottomHeight));
        }];
        
        if (appear) {
            if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
                
                [_gifButton mas_updateConstraints:^(MASConstraintMaker *make) {
                    make.right.equalTo(@(ScreenWidth + self.areaInsets.right + 30));
                }];
                
Han Ruisong's avatar
Han Ruisong committed
1293
1294
1295
1296
                [_screenShotButton mas_updateConstraints:^(MASConstraintMaker *make) {
                    make.right.equalTo(@(ScreenWidth + self.areaInsets.right + 30));
                }];
                
Han Ruisong's avatar
Han Ruisong committed
1297
1298
1299
                [_disableGesButton mas_updateConstraints:^(MASConstraintMaker *make) {
                    make.left.equalTo(@10);
                }];
Han Ruisong's avatar
Han Ruisong committed
1300
                
Han Ruisong's avatar
Han Ruisong committed
1301
1302
1303
1304
1305
1306
            }
            if (interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
                [_gifButton mas_updateConstraints:^(MASConstraintMaker *make) {
                    make.right.equalTo(@(10 + 30));
                }];
                
Han Ruisong's avatar
Han Ruisong committed
1307
1308
1309
                [_screenShotButton mas_updateConstraints:^(MASConstraintMaker *make) {
                    make.right.equalTo(@(10 + 30));
                }];
Han Ruisong's avatar
Han Ruisong committed
1310
                
Han Ruisong's avatar
Han Ruisong committed
1311
1312
1313
                [_disableGesButton mas_updateConstraints:^(MASConstraintMaker *make) {
                    make.left.equalTo(@(self.areaInsets.left));
                }];
Han Ruisong's avatar
Han Ruisong committed
1314
                
Han Ruisong's avatar
Han Ruisong committed
1315
1316
1317
1318
1319
1320
1321
1322
            }
        }else{
            if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
                
                [_gifButton mas_updateConstraints:^(MASConstraintMaker *make) {
                    make.right.equalTo(@(ScreenWidth + self.areaInsets.right + 30));
                }];
                
Han Ruisong's avatar
Han Ruisong committed
1323
1324
1325
1326
                [_screenShotButton mas_updateConstraints:^(MASConstraintMaker *make) {
                    make.right.equalTo(@(ScreenWidth + self.areaInsets.right + 30));
                }];
                
Han Ruisong's avatar
Han Ruisong committed
1327
1328
1329
                [_disableGesButton mas_updateConstraints:^(MASConstraintMaker *make) {
                    make.left.equalTo(@(-10 - 30));
                }];
Han Ruisong's avatar
Han Ruisong committed
1330
                
Han Ruisong's avatar
Han Ruisong committed
1331
1332
1333
1334
1335
1336
1337
            }
            if (interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
                
                [_gifButton mas_updateConstraints:^(MASConstraintMaker *make) {
                    make.right.equalTo(@(10 + 30));
                }];
                
Han Ruisong's avatar
Han Ruisong committed
1338
1339
1340
1341
                [_screenShotButton mas_updateConstraints:^(MASConstraintMaker *make) {
                    make.right.equalTo(@(10 + 30));
                }];
                
Han Ruisong's avatar
Han Ruisong committed
1342
1343
1344
                [_disableGesButton mas_updateConstraints:^(MASConstraintMaker *make) {
                    make.left.equalTo(@(-self.areaInsets.left - 30));
                }];
Han Ruisong's avatar
Han Ruisong committed
1345
                
Han Ruisong's avatar
Han Ruisong committed
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
            }
        }
    }else{
        if (appear) {
            if (self.topFuncBgView.frame.origin.y == 0) {
                return;
            }
            
            if (self.isGIF) {
                return;
            }
            
            [_topFuncBgView mas_updateConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(@0);
                make.height.equalTo(@(topHeight));
            }];
            
Han Ruisong's avatar
Han Ruisong committed
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
            if (self.isFull) {
                [_bottomFuncBgView mas_updateConstraints:^(MASConstraintMaker *make) {
                    make.bottom.equalTo(@0);
                    make.height.equalTo(@(bottomHeight));
                }];
            }else{
                [_bottomFuncBgView mas_updateConstraints:^(MASConstraintMaker *make) {
                    make.bottom.equalTo(@(-barrageBgHeight));
                    make.height.equalTo(@(bottomHeight));
                }];
            }
Han Ruisong's avatar
Han Ruisong committed
1374
1375
1376
1377
1378
1379
1380
            
            if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
                
                [_gifButton mas_updateConstraints:^(MASConstraintMaker *make) {
                    make.right.equalTo(@(-self.areaInsets.right));
                }];
                
Han Ruisong's avatar
Han Ruisong committed
1381
1382
1383
                [_screenShotButton mas_updateConstraints:^(MASConstraintMaker *make) {
                    make.right.equalTo(@(-self.areaInsets.right));
                }];
Han Ruisong's avatar
Han Ruisong committed
1384
                
Han Ruisong's avatar
Han Ruisong committed
1385
1386
1387
                [_disableGesButton mas_updateConstraints:^(MASConstraintMaker *make) {
                    make.left.equalTo(@10);
                }];
Han Ruisong's avatar
Han Ruisong committed
1388
                
Han Ruisong's avatar
Han Ruisong committed
1389
1390
1391
1392
1393
1394
1395
            }
            if (interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
                
                [_gifButton mas_updateConstraints:^(MASConstraintMaker *make) {
                    make.right.equalTo(@(-10));
                }];
                
Han Ruisong's avatar
Han Ruisong committed
1396
1397
1398
1399
                [_screenShotButton mas_updateConstraints:^(MASConstraintMaker *make) {
                    make.right.equalTo(@(-10));
                }];
                
Han Ruisong's avatar
Han Ruisong committed
1400
1401
1402
                [_disableGesButton mas_updateConstraints:^(MASConstraintMaker *make) {
                    make.left.equalTo(@(self.areaInsets.left));
                }];
Han Ruisong's avatar
Han Ruisong committed
1403
                
Han Ruisong's avatar
Han Ruisong committed
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
            }
            
            if (self.isShowMarkView && self.isFull) {
                [self showOrHiddenMarkView:NO];
            }else{
                [self showOrHiddenMarkView:YES];
            }
            
        }else{
            if (self.topFuncBgView.frame.origin.y == -self.topFuncBgView.frame.size.height) {
                return;
            }
Han Ruisong's avatar
Han Ruisong committed
1416
            
Han Ruisong's avatar
Han Ruisong committed
1417
1418
1419
1420
1421
1422
1423
1424
1425
            [_topFuncBgView mas_updateConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(@(-topHeight));
                make.height.equalTo(@(topHeight));
            }];
            
            [_bottomFuncBgView mas_updateConstraints:^(MASConstraintMaker *make) {
                make.bottom.equalTo(@(bottomHeight));
                make.height.equalTo(@(bottomHeight));
            }];
Han Ruisong's avatar
Han Ruisong committed
1426
            
Han Ruisong's avatar
Han Ruisong committed
1427
1428
1429
1430
1431
1432
1433
1434
            if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
                
                if (!self.isGIF) {
                    //如果正在录制gif ,按钮不动
                    [_gifButton mas_updateConstraints:^(MASConstraintMaker *make) {
                        make.right.equalTo(@(ScreenWidth + self.areaInsets.right + 30));
                    }];
                }
Han Ruisong's avatar
Han Ruisong committed
1435
1436
1437
1438
                
                [_screenShotButton mas_updateConstraints:^(MASConstraintMaker *make) {
                    make.right.equalTo(@(ScreenWidth + self.areaInsets.right + 30));
                }];
Han Ruisong's avatar
Han Ruisong committed
1439
                
Han Ruisong's avatar
Han Ruisong committed
1440
1441
1442
                [_disableGesButton mas_updateConstraints:^(MASConstraintMaker *make) {
                    make.left.equalTo(@(-10 - 30));
                }];
Han Ruisong's avatar
Han Ruisong committed
1443
                
Han Ruisong's avatar
Han Ruisong committed
1444
1445
1446
1447
1448
1449
1450
1451
1452
            }
            if (interfaceOrientation == UIInterfaceOrientationLandscapeRight) {