Commit 7600abed1fe5e947d2a6b605945b8f7f5a040bbf

Authored by yanglingyu
1 parent e9177677

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

CNLiveScioLive/Pages/Home/新闻详情/OldController/OldVideoDetailViewController.h
... ... @@ -6,7 +6,6 @@
6 6 // Copyright © 2018年 CNLive. All rights reserved.
7 7 //
8 8  
9   -#import "ZXVideoPlayerController.h"
10 9 #import "CNLiveMyCollectionViewController.h"
11 10 #import "CNLivePlayerController.h"
12 11 #import "BaseViewController.h"
... ... @@ -29,7 +28,6 @@
29 28 }
30 29 @property (strong, nonatomic) UILabel *errorLabe;
31 30 @property (strong, nonatomic) UITableView *tableView;
32   -@property (strong, nonatomic) ZXVideoPlayerController *videoController;
33 31  
34 32 @property (nonatomic, strong) CNLivePlayerController *liveController;
35 33  
... ...
CNLiveScioLive/Pages/Home/新闻详情/OldController/OldVideoDetailViewController.m
... ... @@ -50,9 +50,9 @@
50 50 NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:self->_dictionary[@"imgSmall"]]];
51 51 self->bgImg = [UIImage imageWithData:data];
52 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 95 {
96 96 [self.liveController stop];
97 97 self.liveController = nil;
98   - self.videoController = nil;
99 98 NSLog(@"delloc");
100 99 }
101 100 - (void)loadShareView {
... ... @@ -201,7 +200,6 @@
201 200 }
202 201 - (void)viewWillDisappear:(BOOL)animated {
203 202 [super viewWillDisappear:animated];
204   - [self.videoController stop];
205 203 [self.liveController stopShow];
206 204 // self.liveController = nil;
207 205 [self.navigationController setNavigationBarHidden:NO];
... ... @@ -269,11 +267,7 @@
269 267 [backgroundView addSubview:self.errorLabe];
270 268 self.errorLabe.text = @"没有数据";
271 269 self.errorLabe.hidden = YES;
272   - if (!_dictionary[@"imgSmall"]||[_dictionary[@"imgSmall"] isEqualToString:@""]) {
273 270 [self addCNLivePlayer];
274   - } else {
275   - [self addZXVideo:movieUrl];
276   - }
277 271 }
278 272  
279 273 // CNLivePlayer
... ... @@ -290,6 +284,10 @@
290 284 [bgView addSubview:backButton];
291 285 [self.view addSubview:bgView];
292 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 291 [[AVAudioSession sharedInstance] setActive:YES error:nil];
294 292 [bgView removeFromSuperview];
295 293 [self.liveController configPlayerWithFrame:frame isLiving:NO];
... ... @@ -317,44 +315,6 @@
317 315 [strongSelf.liveController destroyPlayer];
318 316 // strongSelf.liveController = nil;
319 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 319 if ([strongSelf->_dictionary[@"cmsColumnId"] isEqualToString:@"spzl/djzw/"]) {
360 320 //记者问答
... ... @@ -380,9 +340,7 @@
380 340 }
381 341  
382 342 };
383   -
384 343 }
385   -
386 344 //时长统计开始
387 345 if ([_dictionary[@"cmsColumnId"] isEqualToString:@"spzl/djzw/"]) {
388 346 //记者问答
... ... @@ -407,10 +365,19 @@
407 365 [CNLiveStat beginEvent:@"gxzssc"];
408 366 }
409 367 ZXVideo *video = [[ZXVideo alloc] init];
410   - video.playUrl = url;
411 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 381 - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {
415 382 NSURL *requestURL = webView.URL;
416 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