Commit 7600abed1fe5e947d2a6b605945b8f7f5a040bbf

Authored by yanglingyu
1 parent e9177677

解决答记者问部分视频不播放问题

CNLiveScioLive/Pages/Home/新闻详情/OldController/OldVideoDetailViewController.h
@@ -6,7 +6,6 @@ @@ -6,7 +6,6 @@
6 // Copyright © 2018年 CNLive. All rights reserved. 6 // Copyright © 2018年 CNLive. All rights reserved.
7 // 7 //
8 8
9 -#import "ZXVideoPlayerController.h"  
10 #import "CNLiveMyCollectionViewController.h" 9 #import "CNLiveMyCollectionViewController.h"
11 #import "CNLivePlayerController.h" 10 #import "CNLivePlayerController.h"
12 #import "BaseViewController.h" 11 #import "BaseViewController.h"
@@ -29,7 +28,6 @@ @@ -29,7 +28,6 @@
29 } 28 }
30 @property (strong, nonatomic) UILabel *errorLabe; 29 @property (strong, nonatomic) UILabel *errorLabe;
31 @property (strong, nonatomic) UITableView *tableView; 30 @property (strong, nonatomic) UITableView *tableView;
32 -@property (strong, nonatomic) ZXVideoPlayerController *videoController;  
33 31
34 @property (nonatomic, strong) CNLivePlayerController *liveController; 32 @property (nonatomic, strong) CNLivePlayerController *liveController;
35 33
CNLiveScioLive/Pages/Home/新闻详情/OldController/OldVideoDetailViewController.m
@@ -50,9 +50,9 @@ @@ -50,9 +50,9 @@
50 NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:self->_dictionary[@"imgSmall"]]]; 50 NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:self->_dictionary[@"imgSmall"]]];
51 self->bgImg = [UIImage imageWithData:data]; 51 self->bgImg = [UIImage imageWithData:data];
52 dispatch_async(dispatch_get_main_queue(), ^{ 52 dispatch_async(dispatch_get_main_queue(), ^{
53 - if (self.videoController && self->bgImg) {  
54 - self.videoController.view.contentMode=UIViewContentModeScaleToFill;  
55 - self.videoController.view.layer.contents = (__bridge id _Nullable) (self->bgImg.CGImage); 53 + if (self.liveController && self->bgImg) {
  54 + self.liveController.view.contentMode=UIViewContentModeScaleToFill;
  55 + self.liveController.view.layer.contents = (__bridge id _Nullable) (self->bgImg.CGImage);
56 56
57 } 57 }
58 }); 58 });
@@ -95,7 +95,6 @@ @@ -95,7 +95,6 @@
95 { 95 {
96 [self.liveController stop]; 96 [self.liveController stop];
97 self.liveController = nil; 97 self.liveController = nil;
98 - self.videoController = nil;  
99 NSLog(@"delloc"); 98 NSLog(@"delloc");
100 } 99 }
101 - (void)loadShareView { 100 - (void)loadShareView {
@@ -201,7 +200,6 @@ @@ -201,7 +200,6 @@
201 } 200 }
202 - (void)viewWillDisappear:(BOOL)animated { 201 - (void)viewWillDisappear:(BOOL)animated {
203 [super viewWillDisappear:animated]; 202 [super viewWillDisappear:animated];
204 - [self.videoController stop];  
205 [self.liveController stopShow]; 203 [self.liveController stopShow];
206 // self.liveController = nil; 204 // self.liveController = nil;
207 [self.navigationController setNavigationBarHidden:NO]; 205 [self.navigationController setNavigationBarHidden:NO];
@@ -269,11 +267,7 @@ @@ -269,11 +267,7 @@
269 [backgroundView addSubview:self.errorLabe]; 267 [backgroundView addSubview:self.errorLabe];
270 self.errorLabe.text = @"没有数据"; 268 self.errorLabe.text = @"没有数据";
271 self.errorLabe.hidden = YES; 269 self.errorLabe.hidden = YES;
272 - if (!_dictionary[@"imgSmall"]||[_dictionary[@"imgSmall"] isEqualToString:@""]) {  
273 [self addCNLivePlayer]; 270 [self addCNLivePlayer];
274 - } else {  
275 - [self addZXVideo:movieUrl];  
276 - }  
277 } 271 }
278 272
279 // CNLivePlayer 273 // CNLivePlayer
@@ -290,6 +284,10 @@ @@ -290,6 +284,10 @@
290 [bgView addSubview:backButton]; 284 [bgView addSubview:backButton];
291 [self.view addSubview:bgView]; 285 [self.view addSubview:bgView];
292 self.liveController = [[CNLivePlayerController alloc] initWithContentURL:[NSURL URLWithString:self -> url]]; 286 self.liveController = [[CNLivePlayerController alloc] initWithContentURL:[NSURL URLWithString:self -> url]];
  287 + if (!(nil==bgImg)) {
  288 + self.liveController.view.contentMode=UIViewContentModeScaleToFill;
  289 + self.liveController.view.layer.contents = (__bridge id _Nullable)(self->bgImg.CGImage);
  290 + }
293 [[AVAudioSession sharedInstance] setActive:YES error:nil]; 291 [[AVAudioSession sharedInstance] setActive:YES error:nil];
294 [bgView removeFromSuperview]; 292 [bgView removeFromSuperview];
295 [self.liveController configPlayerWithFrame:frame isLiving:NO]; 293 [self.liveController configPlayerWithFrame:frame isLiving:NO];
@@ -317,44 +315,6 @@ @@ -317,44 +315,6 @@
317 [strongSelf.liveController destroyPlayer]; 315 [strongSelf.liveController destroyPlayer];
318 // strongSelf.liveController = nil; 316 // strongSelf.liveController = nil;
319 [strongSelf Pop:nil]; 317 [strongSelf Pop:nil];
320 - };  
321 - }  
322 - ZXVideo *video = [[ZXVideo alloc] init];  
323 - video.title = _dictionary[@"title"];  
324 - video.playUrl = url;  
325 - self.liveController.video = video;  
326 -}  
327 -- (void)viewDidDisappear:(BOOL)animated{  
328 - [(AppDelegate *)[UIApplication sharedApplication].delegate initializeSDKConfiguration];  
329 -  
330 -}  
331 -- (void)backButtonAction:(UIButton *)sender {  
332 - [(AppDelegate *)[UIApplication sharedApplication].delegate initializeSDKConfiguration];  
333 - [self.navigationController popViewControllerAnimated:YES];  
334 -}  
335 -  
336 -- (void)addZXVideo:(NSURL *)videoUrl {  
337 - if (!self.videoController) {  
338 - CGRect frame = CGRectMake(0, iPhoneX ? 44 : 0, MainScreenWidth, videoHeight);  
339 - self.videoController = [[ZXVideoPlayerController alloc] initWithFrame:frame];  
340 - //增加播放器背景图片  
341 - if (!(nil==bgImg)) {  
342 - self.videoController.view.contentMode=UIViewContentModeScaleToFill;  
343 - self.videoController.view.layer.contents = (__bridge id _Nullable)(self->bgImg.CGImage);  
344 - }  
345 - self.liveController.delegate = self;  
346 - [self.videoController showInView:self.view];  
347 -  
348 - __weak typeof(self) weakSelf = self;  
349 - self.videoController.videoPlayerShare = ^{  
350 - __strong typeof(self) strongSelf = weakSelf;  
351 - [strongSelf shareButtonTaped:strongSelf->_shareBtn];  
352 - };  
353 - self.videoController.videoPlayerGoBackBlock = ^{  
354 - __strong typeof(self) strongSelf = weakSelf;  
355 - [[NSUserDefaults standardUserDefaults] setObject:@0 forKey:@"ZXVideoPlayer_DidLockScreen"];  
356 -// strongSelf.videoController = nil;  
357 - [strongSelf Pop:nil];  
358 //时长统计结束 318 //时长统计结束
359 if ([strongSelf->_dictionary[@"cmsColumnId"] isEqualToString:@"spzl/djzw/"]) { 319 if ([strongSelf->_dictionary[@"cmsColumnId"] isEqualToString:@"spzl/djzw/"]) {
360 //记者问答 320 //记者问答
@@ -380,9 +340,7 @@ @@ -380,9 +340,7 @@
380 } 340 }
381 341
382 }; 342 };
383 -  
384 } 343 }
385 -  
386 //时长统计开始 344 //时长统计开始
387 if ([_dictionary[@"cmsColumnId"] isEqualToString:@"spzl/djzw/"]) { 345 if ([_dictionary[@"cmsColumnId"] isEqualToString:@"spzl/djzw/"]) {
388 //记者问答 346 //记者问答
@@ -407,10 +365,19 @@ @@ -407,10 +365,19 @@
407 [CNLiveStat beginEvent:@"gxzssc"]; 365 [CNLiveStat beginEvent:@"gxzssc"];
408 } 366 }
409 ZXVideo *video = [[ZXVideo alloc] init]; 367 ZXVideo *video = [[ZXVideo alloc] init];
410 - video.playUrl = url;  
411 video.title = _dictionary[@"title"]; 368 video.title = _dictionary[@"title"];
412 - self.videoController.video = video; 369 + video.playUrl = url;
  370 + self.liveController.video = video;
  371 +}
  372 +- (void)viewDidDisappear:(BOOL)animated{
  373 + [(AppDelegate *)[UIApplication sharedApplication].delegate initializeSDKConfiguration];
  374 +
413 } 375 }
  376 +- (void)backButtonAction:(UIButton *)sender {
  377 + [(AppDelegate *)[UIApplication sharedApplication].delegate initializeSDKConfiguration];
  378 + [self.navigationController popViewControllerAnimated:YES];
  379 +}
  380 +
414 - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler { 381 - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {
415 NSURL *requestURL = webView.URL; 382 NSURL *requestURL = webView.URL;
416 if (([[requestURL scheme] isEqualToString: @"http"] || [[requestURL scheme] isEqualToString:@"https"] || [[requestURL scheme] isEqualToString: @"mailto" ]) && (navigationAction.navigationType == WKNavigationTypeLinkActivated)) { 383 if (([[requestURL scheme] isEqualToString: @"http"] || [[requestURL scheme] isEqualToString:@"https"] || [[requestURL scheme] isEqualToString: @"mailto" ]) && (navigationAction.navigationType == WKNavigationTypeLinkActivated)) {
CNLiveScioLive/Pages/Tools/CNLivePlayer/CNLivePlayerController.m
No preview for this file type