Commit 7ba010cbcf7be41e6e524203bc44dd715cb6c949

Authored by zhangxiaowen
1 parent 076d18cd

no message

CNLivePlayer/Classes/Player/CNLivePlayer.m
@@ -317,6 +317,9 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang @@ -317,6 +317,9 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang
317 __weak typeof(self) weakSelf = self; 317 __weak typeof(self) weakSelf = self;
318 dispatch_async(dispatch_get_main_queue(), ^{ 318 dispatch_async(dispatch_get_main_queue(), ^{
319 __strong typeof(self) strongSelf = weakSelf; 319 __strong typeof(self) strongSelf = weakSelf;
  320 + if(!strongSelf){
  321 + return ;
  322 + }
320 strongSelf.videoUrl = model.url; 323 strongSelf.videoUrl = model.url;
321 if(!strongSelf.player){ 324 if(!strongSelf.player){
322 NSString *proxyUrl = [[CNLiveHTTPProxyService manager] getProxyUrl:strongSelf.videoUrl]; 325 NSString *proxyUrl = [[CNLiveHTTPProxyService manager] getProxyUrl:strongSelf.videoUrl];
@@ -357,13 +360,16 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang @@ -357,13 +360,16 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang
357 [self authenticateSuccess:^{ 360 [self authenticateSuccess:^{
358 //5.鉴权成功,再请求url 361 //5.鉴权成功,再请求url
359 __strong typeof(self) strongSelf = weakSelf; 362 __strong typeof(self) strongSelf = weakSelf;
360 - if([strongSelf->_contentType isEqualToString:@"vod"]){  
361 - [strongSelf getVodVideoURLSuccess:authSuccessBlock failure:authFailureBlock];  
362 -  
363 - }else{  
364 - [strongSelf getLiveVideoURLSuccess:authSuccessBlock failure:authFailureBlock];  
365 - 363 + if(strongSelf){
  364 + if([strongSelf->_contentType isEqualToString:@"vod"]){
  365 + [strongSelf getVodVideoURLSuccess:authSuccessBlock failure:authFailureBlock];
  366 +
  367 + }else{
  368 + [strongSelf getLiveVideoURLSuccess:authSuccessBlock failure:authFailureBlock];
  369 +
  370 + }
366 } 371 }
  372 +
367 373
368 } failure:authFailureBlock]; 374 } failure:authFailureBlock];
369 } 375 }
@@ -403,7 +409,10 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang @@ -403,7 +409,10 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang
403 NSLog(@"CNLivePlayer-->播放器初始化失败,失败原因:%@", authErrorDic); 409 NSLog(@"CNLivePlayer-->播放器初始化失败,失败原因:%@", authErrorDic);
404 } 410 }
405 authFailureBlock ? authFailureBlock(responseObject) : nil; 411 authFailureBlock ? authFailureBlock(responseObject) : nil;
406 - [CNLivePlayerTools errorStat:authErrorDic[@"errorMessage"] contentId:strongSelf->_activityId ? strongSelf->_activityId : strongSelf->_contentId idName:strongSelf->_idName]; 412 + if(strongSelf){
  413 + [CNLivePlayerTools errorStat:authErrorDic[@"errorMessage"] contentId:strongSelf->_activityId ? strongSelf->_activityId : strongSelf->_contentId idName:strongSelf->_idName];
  414 + }
  415 +
407 416
408 } 417 }
409 418
@@ -419,7 +428,9 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang @@ -419,7 +428,9 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang
419 NSLog(@"CNLivePlayer-->播放器初始化失败,失败原因:%@", authErrorDic); 428 NSLog(@"CNLivePlayer-->播放器初始化失败,失败原因:%@", authErrorDic);
420 } 429 }
421 authFailureBlock ? authFailureBlock(authErrorDic) : nil; 430 authFailureBlock ? authFailureBlock(authErrorDic) : nil;
422 - [CNLivePlayerTools errorStat:authErrorDic[@"errorMessage"] contentId:strongSelf->_activityId ? strongSelf->_activityId : strongSelf->_contentId idName:strongSelf->_idName]; 431 + if(strongSelf){
  432 + [CNLivePlayerTools errorStat:authErrorDic[@"errorMessage"] contentId:strongSelf->_activityId ? strongSelf->_activityId : strongSelf->_contentId idName:strongSelf->_idName];
  433 + }
423 434
424 }]; 435 }];
425 436
@@ -447,6 +458,9 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang @@ -447,6 +458,9 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang
447 __weak typeof(self) weakSelf = self; 458 __weak typeof(self) weakSelf = self;
448 [[CNLivePlayerNetworkManager manager] getVideoURL:videoUrl success:^(NSString * _Nullable videoURL, NSInteger code) { 459 [[CNLivePlayerNetworkManager manager] getVideoURL:videoUrl success:^(NSString * _Nullable videoURL, NSInteger code) {
449 __strong typeof(self) strongSelf = weakSelf; 460 __strong typeof(self) strongSelf = weakSelf;
  461 + if(!strongSelf){
  462 + return ;
  463 + }
450 NSString *key = [NSString stringWithFormat:@"%@:%@",strongSelf->_contentId, strongSelf->_rate]; 464 NSString *key = [NSString stringWithFormat:@"%@:%@",strongSelf->_contentId, strongSelf->_rate];
451 CNLivePlayerDBModel *model = [[CNLivePlayerDBModel alloc]initWithContenId:key url:videoURL]; 465 CNLivePlayerDBModel *model = [[CNLivePlayerDBModel alloc]initWithContenId:key url:videoURL];
452 [[CNLivePlayerDBTool shared] insertTable:model]; 466 [[CNLivePlayerDBTool shared] insertTable:model];
@@ -454,6 +468,9 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang @@ -454,6 +468,9 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang
454 __weak typeof(self) weakSelf = strongSelf; 468 __weak typeof(self) weakSelf = strongSelf;
455 dispatch_async(dispatch_get_main_queue(), ^{ 469 dispatch_async(dispatch_get_main_queue(), ^{
456 __strong typeof(self) strongSelf = weakSelf; 470 __strong typeof(self) strongSelf = weakSelf;
  471 + if(!strongSelf){
  472 + return ;
  473 + }
457 strongSelf.videoUrl = videoURL; 474 strongSelf.videoUrl = videoURL;
458 if(!strongSelf.player){ 475 if(!strongSelf.player){
459 NSString *proxyUrl = [[CNLiveHTTPProxyService manager] getProxyUrl:strongSelf.videoUrl]; 476 NSString *proxyUrl = [[CNLiveHTTPProxyService manager] getProxyUrl:strongSelf.videoUrl];
@@ -509,6 +526,9 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang @@ -509,6 +526,9 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang
509 __weak typeof(self) weakSelf = self; 526 __weak typeof(self) weakSelf = self;
510 [NSURLConnection sendAsynchronousRequest:urlRequest queue:[[NSOperationQueue alloc] init] completionHandler:^(NSURLResponse * _Nullable response, NSData * _Nullable data, NSError * _Nullable connectionError) { 527 [NSURLConnection sendAsynchronousRequest:urlRequest queue:[[NSOperationQueue alloc] init] completionHandler:^(NSURLResponse * _Nullable response, NSData * _Nullable data, NSError * _Nullable connectionError) {
511 __strong typeof(self) strongSelf = weakSelf; 528 __strong typeof(self) strongSelf = weakSelf;
  529 + if(!strongSelf){
  530 + return ;
  531 + }
512 NSString *url = nil; 532 NSString *url = nil;
513 if (connectionError) { 533 if (connectionError) {
514 NSError *error = connectionError.userInfo[NSUnderlyingErrorKey]; 534 NSError *error = connectionError.userInfo[NSUnderlyingErrorKey];
@@ -532,6 +552,9 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang @@ -532,6 +552,9 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang
532 __weak typeof(self) weakSelf = strongSelf; 552 __weak typeof(self) weakSelf = strongSelf;
533 dispatch_async(dispatch_get_main_queue(), ^{ 553 dispatch_async(dispatch_get_main_queue(), ^{
534 __strong typeof(self) strongSelf = weakSelf; 554 __strong typeof(self) strongSelf = weakSelf;
  555 + if(!strongSelf){
  556 + return ;
  557 + }
535 strongSelf.videoUrl = url; 558 strongSelf.videoUrl = url;
536 if(!strongSelf.player){ 559 if(!strongSelf.player){
537 NSString *proxyUrl = [[CNLiveHTTPProxyService manager] getProxyUrl:strongSelf.videoUrl]; 560 NSString *proxyUrl = [[CNLiveHTTPProxyService manager] getProxyUrl:strongSelf.videoUrl];