Commit 7ba010cbcf7be41e6e524203bc44dd715cb6c949
1 parent
076d18cd
no message
Showing
1 changed file
with
31 additions
and
8 deletions
CNLivePlayer/Classes/Player/CNLivePlayer.m
| ... | ... | @@ -317,6 +317,9 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang |
| 317 | 317 | __weak typeof(self) weakSelf = self; |
| 318 | 318 | dispatch_async(dispatch_get_main_queue(), ^{ |
| 319 | 319 | __strong typeof(self) strongSelf = weakSelf; |
| 320 | + if(!strongSelf){ | |
| 321 | + return ; | |
| 322 | + } | |
| 320 | 323 | strongSelf.videoUrl = model.url; |
| 321 | 324 | if(!strongSelf.player){ |
| 322 | 325 | NSString *proxyUrl = [[CNLiveHTTPProxyService manager] getProxyUrl:strongSelf.videoUrl]; |
| ... | ... | @@ -357,13 +360,16 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang |
| 357 | 360 | [self authenticateSuccess:^{ |
| 358 | 361 | //5.鉴权成功,再请求url |
| 359 | 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 | 374 | } failure:authFailureBlock]; |
| 369 | 375 | } |
| ... | ... | @@ -403,7 +409,10 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang |
| 403 | 409 | NSLog(@"CNLivePlayer-->播放器初始化失败,失败原因:%@", authErrorDic); |
| 404 | 410 | } |
| 405 | 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 | 428 | NSLog(@"CNLivePlayer-->播放器初始化失败,失败原因:%@", authErrorDic); |
| 420 | 429 | } |
| 421 | 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 | 458 | __weak typeof(self) weakSelf = self; |
| 448 | 459 | [[CNLivePlayerNetworkManager manager] getVideoURL:videoUrl success:^(NSString * _Nullable videoURL, NSInteger code) { |
| 449 | 460 | __strong typeof(self) strongSelf = weakSelf; |
| 461 | + if(!strongSelf){ | |
| 462 | + return ; | |
| 463 | + } | |
| 450 | 464 | NSString *key = [NSString stringWithFormat:@"%@:%@",strongSelf->_contentId, strongSelf->_rate]; |
| 451 | 465 | CNLivePlayerDBModel *model = [[CNLivePlayerDBModel alloc]initWithContenId:key url:videoURL]; |
| 452 | 466 | [[CNLivePlayerDBTool shared] insertTable:model]; |
| ... | ... | @@ -454,6 +468,9 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang |
| 454 | 468 | __weak typeof(self) weakSelf = strongSelf; |
| 455 | 469 | dispatch_async(dispatch_get_main_queue(), ^{ |
| 456 | 470 | __strong typeof(self) strongSelf = weakSelf; |
| 471 | + if(!strongSelf){ | |
| 472 | + return ; | |
| 473 | + } | |
| 457 | 474 | strongSelf.videoUrl = videoURL; |
| 458 | 475 | if(!strongSelf.player){ |
| 459 | 476 | NSString *proxyUrl = [[CNLiveHTTPProxyService manager] getProxyUrl:strongSelf.videoUrl]; |
| ... | ... | @@ -509,6 +526,9 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang |
| 509 | 526 | __weak typeof(self) weakSelf = self; |
| 510 | 527 | [NSURLConnection sendAsynchronousRequest:urlRequest queue:[[NSOperationQueue alloc] init] completionHandler:^(NSURLResponse * _Nullable response, NSData * _Nullable data, NSError * _Nullable connectionError) { |
| 511 | 528 | __strong typeof(self) strongSelf = weakSelf; |
| 529 | + if(!strongSelf){ | |
| 530 | + return ; | |
| 531 | + } | |
| 512 | 532 | NSString *url = nil; |
| 513 | 533 | if (connectionError) { |
| 514 | 534 | NSError *error = connectionError.userInfo[NSUnderlyingErrorKey]; |
| ... | ... | @@ -532,6 +552,9 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang |
| 532 | 552 | __weak typeof(self) weakSelf = strongSelf; |
| 533 | 553 | dispatch_async(dispatch_get_main_queue(), ^{ |
| 534 | 554 | __strong typeof(self) strongSelf = weakSelf; |
| 555 | + if(!strongSelf){ | |
| 556 | + return ; | |
| 557 | + } | |
| 535 | 558 | strongSelf.videoUrl = url; |
| 536 | 559 | if(!strongSelf.player){ |
| 537 | 560 | NSString *proxyUrl = [[CNLiveHTTPProxyService manager] getProxyUrl:strongSelf.videoUrl]; | ... | ... |