DWVodPlayViewController.m 20.7 KB
Newer Older
Han Ruisong's avatar
Han Ruisong committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//
//  DWVodPlayViewController.m
//  Demo
//
//  Created by zwl on 2019/4/15.
//  Copyright © 2019 com.bokecc.www. All rights reserved.
//

#import "DWVodPlayViewController.h"
#import "DWVodPlayTableViewCell.h"
#import "DWVodPlayBottomView.h"
#import "DWVodPlayerView.h"
#import "DWAdShouView.h"
#import "DWNetworkMonitorViewController.h"
Han Ruisong's avatar
Han Ruisong committed
15
16
#import "DWScreeningListViewController.h"
#import "DWScreeningBgView.h"
Han Ruisong's avatar
Han Ruisong committed
17
18
19
20
21
22

typedef enum : NSUInteger {
    DWVodPlayTableViewCellStyleDefault,
    DWVodPlayTableViewCellStyleChoose,
} DWVodPlayTableViewCellStyle;

Han Ruisong's avatar
Han Ruisong committed
23
@interface DWVodPlayViewController ()<UITableViewDelegate,UITableViewDataSource,DWVodPlayBottomViewDelegate,DWVodPlayerViewDelegate,DWAdShouViewDelegate,DWScreeningListViewControllerDelegate,DWScreeningBgViewDelegate>
Han Ruisong's avatar
Han Ruisong committed
24
25
26
27
28
29
30
31
32
33

@property(nonatomic,assign)CGSize playerViewSize;
@property(nonatomic,strong)DWVodPlayerView * playerView;
@property(nonatomic,strong)UITableView * listTableView;
@property(nonatomic,strong)DWVodPlayBottomView * bottomView;

@property(nonatomic,assign)DWVodPlayTableViewCellStyle cellStyle;

@property(nonatomic,strong)DWAdShouView * adShowView;//广告

Han Ruisong's avatar
Han Ruisong committed
34
35
@property(nonatomic,strong)DWScreeningBgView * screenBgView;//投屏控制器

Han Ruisong's avatar
Han Ruisong committed
36
37
38
39
40
41
42
43
44
45
46
47
48
@end

@implementation DWVodPlayViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    

    [self initParams];
    [self initUI];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceOrientationChangeNotification) name:UIDeviceOrientationDidChangeNotification object:nil];
Han Ruisong's avatar
Han Ruisong committed
49
50
51
52
53
54
55
56
57
    
    //判断是否小窗播放
    if (DWAPPDELEGATE.vodPlayerView) {
        if ([DWAPPDELEGATE.vodPlayerView.videoModel.videoId isEqualToString:self.vodModel.videoId]) {
            //当前正在窗口播放的视频
            return;
        }
    }
    
Han Ruisong's avatar
Han Ruisong committed
58
59
60
61
62
63
64
65
66
67
68
69
70
71
    DWConfigurationManager * manager = [DWConfigurationManager sharedInstance];
    if (manager.isOpenAd) {
        //广告模式
        [self startRequestAdInfo:NO];
    }else{
        //正常播放
        [self startRequestVideo:self.vodModel.videoId];
    }

}

-(void)startRequestVideo:(NSString *)videoId
{
    __weak typeof(self) weakSelf = self;
Han Ruisong's avatar
Han Ruisong committed
72

Han Ruisong's avatar
Han Ruisong committed
73
74
75
76
    DWPlayInfo * playInfo = [[DWPlayInfo alloc]initWithUserId:[DWConfigurationManager sharedInstance].DWAccount_userId andVideoId:videoId key:[DWConfigurationManager sharedInstance].DWAccount_apikey hlsSupport:@"1"];
    playInfo.timeoutSeconds = 30;
    //音频 + 视频数据,这里仅做示范,可根据自己项目业务逻辑来调整
    playInfo.mediatype = @"0";
Han Ruisong's avatar
Han Ruisong committed
77
    //开启授权验证功能传入
Han Ruisong's avatar
Han Ruisong committed
78
    playInfo.verificationCode = [DWConfigurationManager sharedInstance].verification;
Han Ruisong's avatar
Han Ruisong committed
79
80
    //客户端用户id,选填
//    playInfo.roleId = @"";
Han Ruisong's avatar
Han Ruisong committed
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
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
    playInfo.finishBlock = ^(DWVodVideoModel *vodVideo) {
        NSLog(@"%@",vodVideo);
        //下载时,保存图片,名字等数据
        weakSelf.playerView.vodModel = weakSelf.vodModel;
        [weakSelf.playerView setVodVideo:vodVideo];
    };
    playInfo.errorBlock = ^(NSError *error) {
        [error.localizedDescription showAlert];
    };
    [playInfo start];
}

-(void)startRequestAdInfo:(BOOL)isPauseAd
{
    __weak typeof(self) weakSelf = self;
    if (isPauseAd) {
        //暂停广告
        DWAdInfo * adInfo = [[DWAdInfo alloc]initWithUserId:[DWConfigurationManager sharedInstance].DWAccount_userId andVideoId:self.vodModel.videoId type:@"2"];
        [adInfo start];
        adInfo.finishBlock = ^(DWVodAdInfoModel *adInfo) {
            [weakSelf.adShowView playAdVideo:adInfo];
        };
        adInfo.errorBlock = ^(NSError *error) {
            [@"暂停广告请求失败" showAlert];
        };
    }else{
        //片头广告
        DWAdInfo * adInfo = [[DWAdInfo alloc]initWithUserId:[DWConfigurationManager sharedInstance].DWAccount_userId andVideoId:self.vodModel.videoId type:@"1"];
        [adInfo start];
        adInfo.finishBlock = ^(DWVodAdInfoModel *adInfo) {
            [weakSelf.adShowView playAdVideo:adInfo];
        };
        adInfo.errorBlock = ^(NSError *error) {
            [@"片头广告请求失败" showAlert];
        };
    }
}

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
    self.navigationController.navigationBar.hidden = YES;
    
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
}

-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    
    self.navigationController.navigationBar.hidden = NO;
    
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
}

-(void)dealloc
{
    NSLog(@"DWVodPlayViewController dealloc");
    
    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil];
}

-(void)screenOrientationDidChange:(BOOL)isFull
{
    self.listTableView.hidden = isFull;
    self.bottomView.hidden = isFull;
    
    if (isFull) {
        [_playerView mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.and.top.equalTo(@0);
            make.right.and.bottom.equalTo(@0);
        }];
        
        [_adShowView mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.and.top.equalTo(@0);
            make.right.and.bottom.equalTo(@0);
        }];
Han Ruisong's avatar
Han Ruisong committed
159
160
161
162
163
164
165
166
        
        if (self.screenBgView) {
            [_screenBgView mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.left.and.top.equalTo(@0);
                make.right.and.bottom.equalTo(@0);
            }];

        }
Han Ruisong's avatar
Han Ruisong committed
167
168
169
170
171
172
173
174
175
176
177
178
    }else{
        [_playerView mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.top.and.left.equalTo(@0);
            make.width.equalTo(@(self.playerViewSize.width));
            make.height.equalTo(@(self.playerViewSize.height));
        }];
        
        [_adShowView mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.top.and.left.equalTo(@0);
            make.width.equalTo(@(self.playerViewSize.width));
            make.height.equalTo(@(self.playerViewSize.height));
        }];
Han Ruisong's avatar
Han Ruisong committed
179
180
181
182
183
184
185
186
        
        if (self.screenBgView) {
            [_screenBgView mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.top.and.left.equalTo(@0);
                make.width.equalTo(@(self.playerViewSize.width));
                make.height.equalTo(@(self.playerViewSize.height));
            }];
        }
Han Ruisong's avatar
Han Ruisong committed
187
188
189
190
    }
    
    [self.adShowView screenRotate:isFull];
    [self.playerView reLayoutWithScreenState:isFull];
Han Ruisong's avatar
Han Ruisong committed
191
192
193
194

    if (self.screenBgView) {
        [self.screenBgView screenRotate:isFull];
    }
Han Ruisong's avatar
Han Ruisong committed
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
}

#pragma mark - notification
-(void)deviceOrientationChangeNotification
{
    UIDeviceOrientation orientation = [UIDevice currentDevice].orientation;
    UIInterfaceOrientation interfaceOrientation = (UIInterfaceOrientation)orientation;
    
    switch (interfaceOrientation) {
        case UIInterfaceOrientationUnknown:{
            break;
        }
        case UIInterfaceOrientationPortrait:{
            [self screenOrientationDidChange:NO];
            break;
        }
        case UIInterfaceOrientationLandscapeLeft:{
            [self screenOrientationDidChange:YES];
            break;
        }
        case UIInterfaceOrientationLandscapeRight:{
            [self screenOrientationDidChange:YES];
            break;
        }
        default:
            break;
    }
}

#pragma mark - DWAdShouViewDelegate
-(void)adShowPlayDidFinish:(DWAdShouView*)adShowView AndAdType:(NSInteger)type
{
    if (type == 1) {
        //片头广告结束,播放正片
        [self startRequestVideo:self.vodModel.videoId];
    }
    
    if (type == 2) {
        //暂停广告结束,继续播放
        [self.playerView play];
    }
}

-(void)adShowPlay:(DWAdShouView*)adShowView DidScreenRotate:(BOOL)isFull
{
Han Ruisong's avatar
Han Ruisong committed
240

Han Ruisong's avatar
Han Ruisong committed
241
242
243
244
245
246
247
}

#pragma mark - DWVodPlayerViewDelegate
//返回事件
-(void)vodPlayerView:(DWVodPlayerView *)playerView ReturnBackAction:(BOOL)isFull
{
    if (!isFull) {
Han Ruisong's avatar
Han Ruisong committed
248
        DWAPPDELEGATE.vodPlayerView = nil;
Han Ruisong's avatar
Han Ruisong committed
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
        [self.playerView closePlayer];
        [self.navigationController popViewControllerAnimated:YES];
    }else{
        [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationPortrait] forKey:@"orientation"];
    }
}

//播放状态改变事件
-(void)vodPlayerView:(DWVodPlayerView *)playerView PlayStatus:(BOOL)isPlaying
{
    if (![DWConfigurationManager sharedInstance].isOpenAd) {
        return;
    }
    
    if (!isPlaying) {
        //播放暂停广告
        [self startRequestAdInfo:YES];
    }else{
        self.adShowView.hidden = YES;
    }
}

//选集选择事件
-(void)vodPlayerView:(DWVodPlayerView *)playerView ChooseSelection:(NSInteger)selectionIndex
{
    DWVodModel * vodModel = [self.vidoeList objectAtIndex:selectionIndex];
    self.vodModel = vodModel;
    [self startRequestVideo:self.vodModel.videoId];
    [self.listTableView reloadData];
}

//播放下一集事件
-(void)vodPlayerView:(DWVodPlayerView *)playerView NextSelection:(NSInteger)nextIndex
{
    DWVodModel * vodModel = [self.vidoeList objectAtIndex:nextIndex];
    self.vodModel = vodModel;
    [self startRequestVideo:self.vodModel.videoId];
    [self.listTableView reloadData];
}

Han Ruisong's avatar
Han Ruisong committed
289
290
291
292
293
294
295
296
297
298
299
//投屏事件
-(void)vodPlayerView:(DWVodPlayerView *)playerView ScreeningJumpAction:(NSString *)playUrl
{
    DWScreeningListViewController * screeningListVC = [[DWScreeningListViewController alloc]init];
    screeningListVC.playUrl = playUrl;
    screeningListVC.delegate = self;
    [self.navigationController pushViewController:screeningListVC animated:YES];
    
    self.playerView.isScreening = YES;
}

Han Ruisong's avatar
Han Ruisong committed
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
//网络检测事件
-(void)vodPlayerView:(DWVodPlayerView *)playerView DidNetworkMonitor:(NSString *)vid AndPlayUrl:(NSString *)playUrl
{
    [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationPortrait] forKey:@"orientation"];

    DWNetworkMonitorViewController * networkMonitorVC = [[DWNetworkMonitorViewController alloc]initWithVideoId:vid];
    networkMonitorVC.currentPlayurl = playUrl;
    [self.navigationController pushViewController:networkMonitorVC animated:YES];
}

//访客信息收集器,退出填写
-(void)vodPlayerViewVisitorReturnBack:(DWVodPlayerView *)playerView
{
    [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationPortrait] forKey:@"orientation"];

    [self.playerView closePlayer];
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self.navigationController popViewControllerAnimated:YES];
    });
}

Han Ruisong's avatar
Han Ruisong committed
322
323
324
325
//窗口模式播放
-(void)vodPlayerViewDidEnterWindowsModel:(DWVodPlayerView *)playerView
{
    //如果开启了小窗,开小窗,没开启正常
Han Ruisong's avatar
Han Ruisong committed
326
    DWAPPDELEGATE.vodPlayerView = self.playerView;
Han Ruisong's avatar
Han Ruisong committed
327
328
329
330
    [DWAPPDELEGATE.vodPlayerView enterWindowsModel];
    [self.navigationController popViewControllerAnimated:YES];
}

Han Ruisong's avatar
Han Ruisong committed
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
#pragma mark - 投屏相关
-(void)screeningReturnButtonAction
{
    self.playerView.isScreening = NO;
}

-(void)screeningListDidSelectAction:(DWUPnPDevice *)device AndPlayUrl:(NSString *)playUrl
{
    self.screenBgView = [[DWScreeningBgView alloc]initWithDevice:device AndPlayUrl:playUrl];
    self.screenBgView.delegate = self;
    self.screenBgView.title = self.playerView.videoTitle;
    self.screenBgView.seekTime = self.playerView.currentPlayDuration;
    [self.view addSubview:self.screenBgView];
    [_screenBgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.and.left.equalTo(@0);
        make.width.equalTo(@(self.playerViewSize.width));
        make.height.equalTo(@(self.playerViewSize.height));
    }];
    
}

-(void)screeningBgViewCloseAction
{
    
    dispatch_async(dispatch_get_main_queue(), ^{
        [self.screenBgView removeFromSuperview];
        self.screenBgView = nil;
    });
}

Han Ruisong's avatar
Han Ruisong committed
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
#pragma mark - tabelViewDelegate
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.vidoeList.count;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 7.5 + 90 + 7.5;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString * identifier = self.cellStyle == DWVodPlayTableViewCellStyleDefault ? @"CellStyleDefault" : @"CellStyleChoose";
    DWVodPlayTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (!cell) {
        cell = [[DWVodPlayTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    }
    
    DWVodModel * vodModel = [self.vidoeList objectAtIndex:indexPath.row];
    [cell setVodModel:vodModel AndPlaying:[vodModel.videoId isEqualToString:self.vodModel.videoId]];
    
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
Han Ruisong's avatar
Han Ruisong committed
390
391
392
393
394
395
    if (self.playerView.isScreening) {
        //正在投屏
        [@"正在投屏中,请退出投屏再切换视频" showAlert];
        return;
    }
    
Han Ruisong's avatar
Han Ruisong committed
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
    DWVodModel * vodModel = [self.vidoeList objectAtIndex:indexPath.row];
    
    if ([vodModel.videoId isEqualToString:self.vodModel.videoId]) {
        [@"当前正在播放此集" showAlert];
        return;
    }
    
    self.vodModel = vodModel;
    [self startRequestVideo:self.vodModel.videoId];
    
    [tableView reloadData];
}

#pragma mark - bottomViewDelegate
-(void)vodPlayBottomViewDownloadButtonAction
{
    self.cellStyle = DWVodPlayTableViewCellStyleChoose;
    [self.listTableView reloadData];
}
    
-(void)vodPlayBottomViewSureButtonAction
{
    self.cellStyle = DWVodPlayTableViewCellStyleDefault;
    [self.listTableView reloadData];
    
    NSMutableArray * downloadArray = [NSMutableArray array];
    [self.vidoeList enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        DWVodModel * vodModel = (DWVodModel *)obj;
        if (vodModel.isSelect) {
            [downloadArray addObject:vodModel.videoId];
        }
    }];
    
    if (downloadArray.count == 0) {
        [@"请选择下载视频" showAlert];
        return;
    }
    
    //批量下载
    DWBatchDownloadUtility * bdUtility = [[DWBatchDownloadUtility alloc]initWithUserId:[DWConfigurationManager sharedInstance].DWAccount_userId key:[DWConfigurationManager sharedInstance].DWAccount_apikey AndVideoIds:downloadArray];
    bdUtility.verificationCode = [DWConfigurationManager sharedInstance].verification;
    //音频 + 视频数据,这里仅做示范,可根据自己项目业务逻辑来调整
    bdUtility.mediatype = @"0";
Han Ruisong's avatar
Han Ruisong committed
439
    __weak typeof(self) weakSelf = self;
Han Ruisong's avatar
Han Ruisong committed
440
441
442
443
444
445
446
    bdUtility.finishBlock = ^(NSArray<DWVodVideoModel *> * _Nonnull playInfosArray) {
        
        if (playInfosArray.count == 0) {
            [@"未获取到视频数据" showAlert];
            return;
        }
        
Han Ruisong's avatar
Han Ruisong committed
447
        [weakSelf startDownloadTask:playInfosArray];
Han Ruisong's avatar
Han Ruisong committed
448
449
450
451
452
453
454
455
    };
    
    bdUtility.errorBlock = ^(NSError * _Nonnull error) {
        [error.localizedDescription showAlert];
    };
    [bdUtility start];

}
Han Ruisong's avatar
Han Ruisong committed
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
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

-(void)startDownloadTask:(NSArray<DWVodVideoModel *> *)playInfosArray
{
    for (DWVodVideoModel * videoModel in playInfosArray) {

        if (!videoModel) {
            //某个视频数据获取失败
            continue;
        }
        
        if (videoModel.authorize && !videoModel.authorize.enable) {
            //授权验证未通过,无法下载
            continue;
        }
        
        //这里根据自身业务逻辑进行调整, 默认全部下载首个媒体数据
        DWVideoQualityModel * qualityModel = videoModel.videoQualities.firstObject;
        if (!qualityModel) {
            qualityModel = videoModel.radioQualities.firstObject;
        }
        
        DWDownloadSessionManager * manager = [DWDownloadSessionManager manager];
        //验证当前任务是否已经在下载队列中
        if ([manager checkLocalResourceWithVideoId:videoModel.videoId WithQuality:qualityModel.quality]) {
            continue;
        }
        
        //获取视频图片地址,保存
        NSString * imageUrl = @"icon_placeholder.png";
        NSString * title = @"";
        for (DWVodModel * vodModel in self.vidoeList) {
            if ([vodModel.videoId isEqualToString:videoModel.videoId]) {
                imageUrl = vodModel.imageUrl;
                title = vodModel.title;
                break;
            }
        }
        
        DWDownloadModel * model = [DWDownloadSessionManager createDownloadModel:videoModel Quality:qualityModel.quality AndOthersInfo:@{@"imageUrl":imageUrl,@"title":title}];
        
        if (!model) {
            [@"DownloadModel创建失败,请检查参数" showAlert];
            continue;
        }
        
        [manager startWithDownloadModel:model];
        
    }
    
    [[NSString stringWithFormat:@"已开始下载%lu个视频",(unsigned long)playInfosArray.count] showAlert];
}
Han Ruisong's avatar
Han Ruisong committed
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
    
-(void)vodPlayBottomViewCancelButtonAction
{
    self.cellStyle = DWVodPlayTableViewCellStyleDefault;
    [self.listTableView reloadData];
    
    //清空选中数据
    for (DWVodModel * vodModel in self.vidoeList) {
        vodModel.isSelect = NO;
    }
}

#pragma mark - init
-(void)initParams
{
    self.cellStyle = DWVodPlayTableViewCellStyleDefault;
}

-(void)initUI
{
    CGSize viewSize = CGSizeZero;
    if (@available(iOS 11.0, *)) {
        CGFloat a =  [[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom;
        if (a > 0) {
            viewSize = CGSizeMake(ScreenWidth, ScaleHeight(ScreenWidth, 375 / 211.0) + 64);
        }else{
            viewSize = CGSizeMake(ScreenWidth, ScaleHeight(ScreenWidth, 375 / 211.0));
        }
    } else {
        viewSize = CGSizeMake(ScreenWidth, ScaleHeight(ScreenWidth, 375 / 211.0));
    }
    self.playerViewSize = viewSize;
    
Han Ruisong's avatar
Han Ruisong committed
540
541
542
543
544
545
546
547
548
549
550
    if (DWAPPDELEGATE.vodPlayerView) {
        self.playerView = DWAPPDELEGATE.vodPlayerView;
        //选集,要在退出小窗之前设置,否则选集列表会有显示问题
        self.playerView.selectionList = self.vidoeList;
        [self.playerView quitWindowsModel];
    }else{
        self.playerView = [[DWVodPlayerView alloc]init];
        //选集
        self.playerView.selectionList = self.vidoeList;
    }
    
Han Ruisong's avatar
Han Ruisong committed
551
552
    self.playerView.delegate = self;
    [self.view addSubview:self.playerView];
Han Ruisong's avatar
Han Ruisong committed
553
    [_playerView mas_remakeConstraints:^(MASConstraintMaker *make) {
Han Ruisong's avatar
Han Ruisong committed
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
        make.top.and.left.equalTo(@0);
        make.width.equalTo(@(self.playerViewSize.width));
        make.height.equalTo(@(self.playerViewSize.height));
    }];
    
    self.adShowView = [[DWAdShouView alloc]init];
    self.adShowView.hidden = YES;
    self.adShowView.delegate = self;
    [self.view addSubview:self.adShowView];
    [_adShowView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.and.left.equalTo(@0);
        make.width.equalTo(@(self.playerViewSize.width));
        make.height.equalTo(@(self.playerViewSize.height));
    }];
    
    self.listTableView = [[UITableView alloc]init];
    self.listTableView.delegate = self;
    self.listTableView.dataSource = self;
    self.listTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
Han Ruisong's avatar
Han Ruisong committed
573
574

    self.listTableView.backgroundColor = self.view.backgroundColor;
Han Ruisong's avatar
Han Ruisong committed
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
    [self.view addSubview:self.listTableView];
    [_listTableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.equalTo(@0);
        make.top.equalTo(self.playerView.mas_bottom);
        make.bottom.equalTo(@(-15 - 40 - 15));
    }];
    
    UIView * headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 15 + 14 + 2.5)];
    self.listTableView.tableHeaderView = headerView;
    UILabel * headerTsLabel = [[UILabel alloc]init];
    headerTsLabel.text = @"课程目录";
    headerTsLabel.font = TitleFont(14);
    headerTsLabel.textColor = TitleColor_51;
    headerTsLabel.textAlignment = NSTextAlignmentLeft;
    [headerView addSubview:headerTsLabel];
    [headerTsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@10);
        make.top.equalTo(@15);
        make.width.equalTo(@(ScreenWidth - 20));
        make.height.equalTo(@14);
    }];
    
    self.bottomView = [[DWVodPlayBottomView alloc]init];
    self.bottomView.delegate = self;
    [self.view addSubview:self.bottomView];
    [_bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.listTableView.mas_bottom);
        make.bottom.equalTo(@0);
        make.left.and.right.equalTo(@0);
    }];
Han Ruisong's avatar
Han Ruisong committed
605
606
607
608
    
    if (self.landScape) {
        [self screenOrientationDidChange:YES];
    }
Han Ruisong's avatar
Han Ruisong committed
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
}

-(BOOL)shouldAutorotate
{
    return YES;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end