GraphicLiveViewController.m 25.1 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 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 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 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 240 241 242 243 244 245 246 247 248 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 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 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 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 390 391 392 393 394 395 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 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 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 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 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556
//
//  GraphicLiveViewController.m
//  SCIOLiveCN
//
//  Created by huayu on 16/5/13.
//  Copyright © 2016年 huayu. All rights reserved.
//
#import "JSONKit.h"
#import "GraphicLiveViewController.h"
#import "VideoPlayBackViewController.h"
#import "CNLiveModel.h"

@interface GraphicLiveViewController ()<CNLivePlayerControllerDelegate>
@end
@implementation GraphicLiveViewController
- (void)Pop:(id)sender{
    [self.videoController stop];
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)getData{
    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    [XWHTTPTool POST:LiveUrl params:nil success:^(id json) {

        [MBProgressHUD hideHUDForView:self.view animated:YES];
        
        // 请求成功,解析数据
        NSDictionary *dic = [NSDictionary dictionaryWithDictionary:json];
        [CNLiveModel mj_setupReplacedKeyFromPropertyName:^NSDictionary *{
            return @{ @"ID" : @"id" ,@"Description" : @"description" };
        }];
        CNLiveModel *liveModel = [CNLiveModel mj_objectWithKeyValues:dic];
        if (![self->_dictionary isEqualToDictionary:[liveModel toDictionary] ]) {
            self->_dictionary = [liveModel toDictionary];
            self.reloadData();
            [self updateUIData];
        }else{
            [self updateUIData];
        }
        
//        self->_isLoaded = YES;
        
    } failure:^(NSError *error) {
        [MBProgressHUD hideHUDForView:self.view animated:YES];
        [AlertViewTool showHUDAddedToView:self.view text:CustomStr(@"ServerBusy")];
        [self updateUIData];
    }];
}

-(void)updateUIData{
    int status = [_dictionary[@"status"] intValue];
    int liveFlag = [_dictionary[@"liveFlag"] intValue];
    if (4 == status) {
        if (_dictionary[@"playbackId"]) {
            // 回放
            isPlay = YES;
            self.type = PlayerTypeVOD;
        } else {
            isPlay = NO;
        }
    } else if (1 == status) {
        // 直播
        url = _dictionary[@"liveUrl"];
        if (0 == liveFlag) {
            isPlay = YES;
            self.type = PlayerTypeLiving;
        } else {
            isPlay = NO;
            self.type = -1;
        }
    }
    NSString* htmlHeader = [[NSString alloc] initWithFormat:@"<html><font style=\"font-size:20px;\"><strong>%@</strong></font><br><p>%@</p><p>%@:%@</p><body>",[_dictionary objectForKey:@"title"],[_dictionary objectForKey:@"liveStartDateTime"], CustomStr(@"Source"), @"国新网"];
    NSString* htmlFooter = [[NSString alloc] initWithFormat:@"<div class=\"logo\" style=\"text-indent:2em\">%@</div></body></html>",[_dictionary objectForKey:@"Description"]];

    NSString* strHtml = [[NSString alloc] initWithFormat:@"%@%@",htmlHeader,htmlFooter];
    [relatedWebView loadHTMLString:strHtml baseURL:nil];
    if (!isPlay) {
        [self loadMovieView];
    } else {
        [self addCNLivePlayerWithURL];
    }
}
- (id)initWithDictionary:(NSDictionary *)dictionary {
    if (self = [super init]) {
        _dictionary = [NSDictionary dictionaryWithDictionary:dictionary];
    }
    return self;
}

- (NSString *)setHTMLString {
    NSString* htmlBody = [[NSString alloc] initWithFormat:@"<p><font style=\"font-size:%@px;\">%@</font></p>",fontArray[fontIndex],[_dic objectForKey:@"Content"]];
    NSString* htmlFooter = @"</body></html>";
    NSString* strHtml = [[NSString alloc] initWithFormat:@"%@%@",htmlBody,htmlFooter];
    return strHtml;
}

- (void)loadData {
    if (![[Reachability reachabilityForInternetConnection] currentReachabilityStatus]) {
        return;
    }
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager POST:@"http://s.scio.gov.cn/ocms/.content/function_provider/arswitch1.json" parameters:nil headers:nil progress:NULL  success:^(NSURLSessionDataTask *task, id responseObject) {
        NSLog(@"%@",responseObject);
        NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
        NSString *errorCode = dic[@"errorCode"];
        
        if ([errorCode isEqualToString:@"1"]) {
            [self requestJsonData:dic[@"docId"]];
        }
       

    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        NSLog(@"%@",error);

    }];
    
   
}
-(void)requestJsonData:(NSString *)docId
{
    if (![[Reachability reachabilityForInternetConnection] currentReachabilityStatus]) {
        [AlertViewTool showHUDViewText:CustomStr(@"NetworkiInterruption")];
        return;
    }
    [AlertViewTool showHUDView];
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager POST:tuwen(docId.intValue) parameters:nil headers:nil  progress:^(NSProgress * _Nonnull uploadProgress) {} success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
          [AlertViewTool hideHUDView];
          // 请求成功,解析数据
          NSString * jsonString = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
          NSArray *arr = [jsonString objectFromJSONString];
          if (arr.count > 0) {
              self->_dic = [arr objectAtIndex:0];
              [self->_webView loadHTMLString:[self setHTMLString] baseURL:nil];
          } else {
              [self->_webView loadHTMLString:@"<html><body>   </body></html>" baseURL:nil];
          }
        
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
          // 请求失败
          NSLog(@"%@", [error localizedDescription]);
          [AlertViewTool hideHUDView];
          [AlertViewTool showHUDAddedToView:self.view text:CustomStr(@"ServerBusy")];
        
    }];
}
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [[JGMusicManager shareMusicManager] playStop];
    [self.navigationController setNavigationBarHidden:YES];
    
    NSError *error = nil;
    [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error: &error];
    [[AVAudioSession sharedInstance] setActive:YES error:nil];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [self.liveController stopShow];
    [self.navigationController setNavigationBarHidden:NO];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self getData];
    self.view.backgroundColor = [UIColor whiteColor];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pausePlayer) name:@"PausePlayerNotification" object:nil];
    fontIndex = (int)[[NSUserDefaults standardUserDefaults] integerForKey:@"FontSize"];
    heightArr = [NSMutableArray arrayWithArray:@[@"0",@"0",@"0"]];
    fontArray = @[@"16",@"20",@"24"];
    videoHeight = MainScreenWidth * (9.0 / 16.0);
    if (iPhoneX) {
        backgroundView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, videoHeight + 44, MainScreenWidth, MainScreenHeight - videoHeight - 44)];
    } else {
        backgroundView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, videoHeight, MainScreenWidth, MainScreenHeight - videoHeight)];
    }
    
    backgroundView.bounces = NO;
    [self.view addSubview:backgroundView];
    
    NSString *jScript = @"var meta = document.createElement('meta'); meta.setAttribute('name', 'viewport'); meta.setAttribute('content', 'width=device-width, user-scalable=no'); document.getElementsByTagName('head')[0].appendChild(meta);";

     WKUserScript *wkUScript = [[WKUserScript alloc] initWithSource:jScript injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:YES];
     WKUserContentController *wkUController = [[WKUserContentController alloc] init];
     [wkUController addUserScript:wkUScript];

     WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init];
     config.userContentController = wkUController;
     relatedWebView = [[WKWebView alloc] initWithFrame:CGRectZero configuration:config];
    relatedWebView.scrollView.backgroundColor = [UIColor whiteColor];
    relatedWebView.backgroundColor = [UIColor whiteColor];
    relatedWebView.scrollView.bounces = NO;
    relatedWebView.scrollView.scrollEnabled = NO;
    relatedWebView.navigationDelegate = self;
    relatedWebView.opaque = NO;
    relatedWebView.tag = 1000;
    [backgroundView addSubview:relatedWebView];
    
    
    [self loadData];
    isShow = NO;
    
}

- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    [self.liveController stop];
        self.liveController = nil;
}
#pragma mark - UI
- (void)loadMovieView {
    [[NSUserDefaults standardUserDefaults] setObject:@0 forKey:@"GraphicLive_DidLockScreen"];
    imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, iPhoneX ? 44 : 0, MainScreenWidth, videoHeight)];
    imageView.contentMode = UIViewContentModeScaleAspectFill;
    imageView.clipsToBounds = YES;
    [imageView sd_setImageWithURL:[NSURL URLWithString:_dictionary[@"poster"]] placeholderImage:[UIImage imageNamed:@"cnlive_placeholder"]];
    [self.view addSubview:imageView];
    
    UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [backButton addTarget:self action:@selector(Pop:) forControlEvents:UIControlEventTouchUpInside];
    [backButton setImage:[UIImage imageNamed:@"cnlive_white_back"] forState:UIControlStateNormal];
    [backButton setFrame:CGRectMake(0, StatusBarHeight, 44, 44)];
    [self.view addSubview:backButton];
    
    UIButton *shareButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [shareButton addTarget:self action:@selector(shareButton:) forControlEvents:UIControlEventTouchUpInside];
    [shareButton setImage:[UIImage imageNamed:@"cnlive_live_share"] forState:UIControlStateNormal];
    [shareButton setFrame:CGRectMake(MainScreenWidth-40, StatusBarHeight+7, 30, 30)];
    shareButton.centerY = backButton.centerY;
    [self.view addSubview:shareButton];
    
}

- (void)shareButton:(UIButton *)btn{
    NSString *img = [NSString stringWithFormat:@"%@",_dictionary[@"poster"]];
    NSString *title = [NSString stringWithFormat:@"%@",_dictionary[@"title"]];
    NSString *text = [NSString stringWithFormat:@"%@",!_dictionary[@"Description"]||[_dictionary[@"Description"] isEqualToString:@""]?title:_dictionary[@"Description"]];
    NSString *url = [NSString stringWithFormat:@"%@",_dictionary[@"shareUrl"]];
    [[TemplateShareManager manager] shareImage:img title:title text:text url:url controller:self];
    
}

- (void)pausePlayer {
    [self.liveController pause];
}

// CNLivePlayer
- (void)addCNLivePlayerWithURL {
    if (!self.liveController) {
        CGRect frame = CGRectMake(0, iPhoneX ? 44 : 0, MainScreenWidth, videoHeight);
        UIView *bgView = [[UIView alloc] initWithFrame:frame];
        bgView.backgroundColor = [UIColor blackColor];
        [self.view addSubview:bgView];

        UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
        backButton.frame = CGRectMake(20, 20, 25, 41);
        [backButton setImage:[UIImage imageNamed:@"cnlive_white_back"] forState:UIControlStateNormal];
        [backButton addTarget:self action:@selector(backButtonAction:) forControlEvents:UIControlEventTouchUpInside];
        [bgView addSubview:backButton];

        UIButton *shareButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [shareButton addTarget:self action:@selector(shareButton:) forControlEvents:UIControlEventTouchUpInside];
        [shareButton setImage:[UIImage imageNamed:@"cnlive_live_share"] forState:UIControlStateNormal];
        [shareButton setFrame:CGRectMake(MainScreenWidth-40, StatusBarHeight+7, 30, 30)];
        shareButton.centerY = backButton.centerY;
        [bgView addSubview:shareButton];
        
        if (self.type == PlayerTypeLiving) {
            // 直播
            self.liveController = [[CNLivePlayerController alloc] initLivePlayWithChannelId:_dictionary[@"channelId"] activityId:_dictionary[@"activityId"] anchorStatus:YES authSuccess:^{
                [bgView removeFromSuperview];
                [self.liveController configPlayerWithFrame:frame isLiving:YES];
                [self.liveController showInView:self.view];
            } authFailed:^(NSDictionary *errorInfo) {
                NSLog(@"初始化直播播放器失败:%@", errorInfo);
            } getAnchorStatusResult:^(BOOL result) {
                NSLog(@"获取主播状态%d", result ? YES : NO);
            }];
            self.liveController.delegate = self;

        } else {
            // 点播
            self.liveController = [[CNLivePlayerController alloc] initVodPlayWithVId:_dictionary[@"playbackId"] authSuccess:^{
                [bgView removeFromSuperview];
                [self.liveController configPlayerWithFrame:frame isLiving:NO];
                [self.liveController showInView:self.view];
            } authFailed:^(NSDictionary *errorInfo) {
                NSLog(@"初始化点播播放器失败%@", errorInfo);
            }];
            self.liveController.delegate = self;
        }
        [[NSUserDefaults standardUserDefaults] setObject:@0 forKey:@"ZXVideoPlayer_DidLockScreen"];
        __weak typeof(self) weakSelf = self;
        self.liveController.videoPlayerGoBackBlock = ^{
            __strong typeof(self) strongSelf = weakSelf;
            [[NSUserDefaults standardUserDefaults] setObject:@0 forKey:@"ZXVideoPlayer_DidLockScreen"];
            [strongSelf.liveController destroyPlayer];
//            strongSelf.liveController = nil;
            [strongSelf Pop:nil];
        };
    }
    MJWeakSelf
    self.liveController.videoPlayerWillChangeToFullScreenModeBlock = ^{
        weakSelf.navigationController.interactivePopGestureRecognizer.enabled = NO;
    };
    self.liveController.videoPlayerWillChangeToOriginalScreenModeBlock = ^{
        weakSelf.navigationController.interactivePopGestureRecognizer.enabled = YES;
    };
    ZXVideo *video = [[ZXVideo alloc] init];
    video.title = _dictionary[@"title"];
    self.liveController.video = video;
}

- (void)shareButtonCNLivePlayerController:(CNLivePlayerController *)view{
    [self shareButton:nil];
    
}
- (void)backButtonAction:(UIButton *)sender {
    [self.navigationController popViewControllerAnimated:YES];
}

//隐藏navigation tabbar 电池栏
- (void)toolbarHidden:(BOOL)Bool{
    [[UIApplication sharedApplication] setStatusBarHidden:Bool withAnimation:UIStatusBarAnimationFade];
    [self.navigationController setNavigationBarHidden:Bool];
}

#pragma mark - WKNavigationDelegate
// 页面开始加载时调用
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
{
    NSURL *requestURL = navigationAction.request.URL;
    NSString *scheme = navigationAction.request.URL.scheme;
    if (([scheme isEqualToString: @"http"] || [scheme isEqualToString:@"https"] || [scheme isEqualToString: @"mailto" ]) && (navigationAction.navigationType == WKNavigationTypeLinkActivated )) {
        [[UIApplication sharedApplication] openURL:requestURL];
        decisionHandler(WKNavigationActionPolicyCancel);
    }
    decisionHandler(WKNavigationActionPolicyAllow);
}

// 页面加载完成之后调用
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
{
    if (webView == relatedWebView) {
        CGRect frame = relatedWebView.frame;
        frame.size.width = MainScreenWidth;
        frame.size.height = 1;
        relatedWebView.frame = frame;
        [webView evaluateJavaScript:@"document.body.scrollHeight"completionHandler:^(id _Nullable result,NSError * _Nullable error){
            NSLog(@"scrollHeight高度:%.2f",[result floatValue]);
            self->descriptionHeight = [result floatValue];
            [self->relatedWebView setFrame:CGRectMake(0, 0, MainScreenWidth, self->descriptionHeight)];
            [self setUpUIWithTag:1000 Height:40.0];
        }];
    }
    if (webView.tag==2000) {
        CGFloat width = MainScreenWidth - 20;
        NSString *string = [NSString stringWithFormat:
                            @"var script = document.createElement('script');"
                            "script.type = 'text/javascript';"
                            "script.text = \"function ResizeImages() { "
                            "var myimg,oldwidth;"
                            "var maxwidth=%f;" //缩放系数
                            "for(i=0;i <document.images.length;i++){"
                            "myimg = document.images[i];"
                            "if(myimg.width > maxwidth){"
                            "oldwidth = myimg.width;"
                            "myimg.width = maxwidth;"
                            "myimg.height = myimg.height * (maxwidth/oldwidth);"
                            "}"
                            "}"
                            "}\";"
                            "document.getElementsByTagName('head')[0].appendChild(script);",width];

        [webView evaluateJavaScript:string completionHandler:nil];
        [webView evaluateJavaScript:@"ResizeImages();" completionHandler:nil];
        
        CGRect frame = webView.frame;
        frame.size.width = MainScreenWidth;
        frame.size.height = 1;
        webView.frame = frame;
        [webView evaluateJavaScript:@"document.body.scrollHeight"completionHandler:^(id _Nullable result,NSError * _Nullable error){
            self->graphicLiveHeight = [result floatValue];
            if (0 == [self->heightArr[self->fontIndex] floatValue]) {
                [self->heightArr replaceObjectAtIndex:self->fontIndex withObject:[NSString stringWithFormat:@"%f",self->graphicLiveHeight]];
            }
            
            if (self->isShow) {
                NSLog(@"fontIndex = %d",self->fontIndex);
                [self->backgroundView setContentSize:CGSizeMake(MainScreenWidth, 40 + self->descriptionHeight + [self->heightArr[self->fontIndex] floatValue] + 221)];
                [webView setFrame:CGRectMake(0, 40 + self->descriptionHeight, MainScreenWidth, [self->heightArr[self->fontIndex] floatValue])];
                [self showRelatedInformation:40 + self->descriptionHeight + [self->heightArr[self->fontIndex] floatValue]];
            }
        }];
    }
   
}
- (void)setUpUIWithTag:(NSInteger)tag Height:(NSInteger)height{

    if (1000 == tag) {
        lineImage1 = [[UIImageView alloc] initWithFrame:CGRectMake(0, descriptionHeight, MainScreenWidth, 1)];
        lineImage1.backgroundColor = Color_Line;
        [backgroundView addSubview:lineImage1];
        
        upDownButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [upDownButton addTarget:self action:@selector(showGraphicLive:) forControlEvents:UIControlEventTouchUpInside];
        [upDownButton setFrame:CGRectMake(0, descriptionHeight, MainScreenWidth, height)];
        [backgroundView addSubview:upDownButton];
        
        UILabel *graphicLive = [[UILabel alloc] initWithFrame:CGRectMake(20, descriptionHeight, MainScreenWidth/2, height)];
        graphicLive.font = [UIFont systemFontOfSize:13];
        graphicLive.backgroundColor = [UIColor clearColor];
        graphicLive.textColor = HEXCOLOR(0x184085);
        [backgroundView addSubview:graphicLive];
        graphicLive.text = @"发布会图文播报";
        
        upDownImage = [[UIImageView alloc] initWithFrame:CGRectMake(MainScreenWidth - 31, descriptionHeight + 16, 13, 7)];
        upDownImage.image = [UIImage imageNamed:@"cnlive_button_down"];
        upDownImage.hidden = height != 40;
        [backgroundView addSubview:upDownImage];
        
        lineImage2 = [[UIImageView alloc] initWithFrame:CGRectMake(0, height + descriptionHeight, MainScreenWidth, 1)];
        lineImage2.backgroundColor = Color_Line;
        [backgroundView addSubview:lineImage2];
        
        [backgroundView setContentSize:CGSizeMake(MainScreenWidth, height + descriptionHeight + 960)];
        
        NSString *jScript = @"var meta = document.createElement('meta'); meta.setAttribute('name', 'viewport'); meta.setAttribute('content', 'width=device-width, user-scalable=no'); document.getElementsByTagName('head')[0].appendChild(meta);";

         WKUserScript *wkUScript = [[WKUserScript alloc] initWithSource:jScript injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:YES];
         WKUserContentController *wkUController = [[WKUserContentController alloc] init];
         [wkUController addUserScript:wkUScript];

         WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init];
         config.userContentController = wkUController;
        _webView = [[WKWebView alloc] initWithFrame:CGRectZero configuration:config];
        _webView.scrollView.backgroundColor = [UIColor clearColor];
        _webView.backgroundColor = [UIColor clearColor];
        _webView.scrollView.bounces = NO;
        _webView.navigationDelegate = self;
        _webView.hidden = YES;
        _webView.opaque = NO;
        _webView.tag = 2000;
        
        [backgroundView addSubview:_webView];
        
        relatedInformationView = [[UIView alloc] initWithFrame:CGRectMake(0, height + descriptionHeight, MainScreenWidth, 960)];
        [backgroundView addSubview:relatedInformationView];
        
        [self showRelatedInformation:height + descriptionHeight];
        
    }
}

- (void)showRelatedInformation:(CGFloat)y {
    for (UIView *view in relatedInformationView.subviews) {
        [view removeFromSuperview];
    }
    
    UIImageView *lineImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, MainScreenWidth, 1)];
    lineImage.backgroundColor = Color_Line;
    [relatedInformationView addSubview:lineImage];
    
    UILabel *relatedInformation = [[UILabel alloc] initWithFrame:CGRectMake(12, 0, MainScreenWidth - 24, 33)];
    relatedInformation.backgroundColor = [UIColor clearColor];
    relatedInformation.textColor = HEXCOLOR(0x333333);
    relatedInformation.font = [UIFont systemFontOfSize:15];
    [relatedInformationView addSubview:relatedInformation];
    relatedInformation.text = CustomStr(@"RelevantInformation");
    
    CGFloat height = 0.0;
    for (int i = 0; i < 10; i++) {
        if (0 == self.relatedArray.count) return;
        
        NSDictionary *dic = self.relatedArray[i];
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        [btn addTarget:self action:@selector(relatedInfoTaped:) forControlEvents:UIControlEventTouchUpInside];
        [btn setFrame:CGRectMake(0, 23 + i*94, MainScreenWidth, 94)];
        [btn setTag:1000 + i];
        [relatedInformationView addSubview:btn];
        
        UIImageView *_backImage = [[UIImageView alloc] initWithFrame:CGRectMake(12, 33 + i*94, 120, 74)];
        [relatedInformationView addSubview:_backImage];
        [_backImage sd_setImageWithURL:[NSURL URLWithString:dic[@"img"]] placeholderImage:[UIImage imageNamed:@"backDefault"]];
        
        UILabel *_titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(142, 33 + i*94, MainScreenWidth - 154, 55)];
        _titleLabel.backgroundColor = [UIColor clearColor];
        _titleLabel.textColor = HEXCOLOR(0x333333);
        _titleLabel.font = [UIFont systemFontOfSize:16];
        _titleLabel.numberOfLines = 3;
        [relatedInformationView addSubview:_titleLabel];
        _titleLabel.text = dic[@"title"];
    
        UILabel *_timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(142, 95 + i*94, MainScreenWidth - 154, 19)];
        _timeLabel.textColor = HEXCOLOR(0x666666);
        _timeLabel.font = [UIFont systemFontOfSize:12];
        _timeLabel.backgroundColor = [UIColor clearColor];
        [relatedInformationView addSubview:_timeLabel];
        _timeLabel.text = dic[@"createDate"];
        
        height = CGRectGetMaxY(_timeLabel.frame);
    }

    CGRect frame = relatedInformationView.frame;
    frame.origin.y = y;
    frame.size.height = height;
    [relatedInformationView setFrame:frame];
    [backgroundView setContentSize:CGSizeMake(MainScreenWidth, relatedInformationView.bottom)];

}
- (void)showGraphicLive:(id)sender {
    isShow = !isShow;
    if (isShow) {
        upDownImage.image = [UIImage imageNamed:@"cnlive_button_up"];
        [backgroundView setContentSize:CGSizeMake(MainScreenWidth, 40 + descriptionHeight + graphicLiveHeight + 221)];
        [_webView setFrame:CGRectMake(0, 40 + descriptionHeight, MainScreenWidth, [heightArr[fontIndex] floatValue])];
        [self showRelatedInformation:40 + descriptionHeight + graphicLiveHeight];
        _webView.hidden = NO;
    } else {
        upDownImage.image = [UIImage imageNamed:@"cnlive_button_down"];
        [backgroundView setContentSize:CGSizeMake(MainScreenWidth, 40 + descriptionHeight + 221)];
        [self showRelatedInformation:40 + descriptionHeight];
        _webView.hidden = YES;
    }
}

- (void)relatedInfoTaped:(id)sender {
    UIButton *btn = (UIButton *)sender;
    NSDictionary *dic = self.relatedArray[btn.tag - 1000];
    NSLog(@"%@",dic);
    VideoPlayBackViewController *vc = [[VideoPlayBackViewController alloc] initWithDictionary:dic];
    vc.title = _dic[@"cmsColumnName"];
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

- (BOOL)shouldAutorotate {
    return isPlay;
}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAllButUpsideDown;
}

- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleDefault;
}

@end