Commit fa671759440d0c801188e8899ea53e4c90d44ada
1 parent
e49b9a9a
no message
Showing
4 changed files
with
13 additions
and
8 deletions
CNLivePlayer/Classes/DataRequest/CNLivePlayerNetworkManager.h
| @@ -52,7 +52,7 @@ typedef void(^GetVideoURLSuccessBlock)(NSString * _Nullable videoURL, NSInteger | @@ -52,7 +52,7 @@ typedef void(^GetVideoURLSuccessBlock)(NSString * _Nullable videoURL, NSInteger | ||
| 52 | /** | 52 | /** |
| 53 | * 获取视频url | 53 | * 获取视频url |
| 54 | */ | 54 | */ |
| 55 | -+ (void)getVideoURL:(nullable NSString *)URL success:(GetVideoURLSuccessBlock)success; | 55 | +- (void)getVideoURL:(nullable NSString *)URL success:(GetVideoURLSuccessBlock)success; |
| 56 | 56 | ||
| 57 | 57 | ||
| 58 | @end | 58 | @end |
CNLivePlayer/Classes/DataRequest/CNLivePlayerNetworkManager.m
| @@ -177,8 +177,8 @@ static CNLivePlayerNetworkManager *_manager = nil; | @@ -177,8 +177,8 @@ static CNLivePlayerNetworkManager *_manager = nil; | ||
| 177 | /** | 177 | /** |
| 178 | * 获取视频url | 178 | * 获取视频url |
| 179 | */ | 179 | */ |
| 180 | -+ (void)getVideoURL:(nullable NSString *)URL success:(GetVideoURLSuccessBlock)success { | ||
| 181 | - [CNLivePlayerNetworkManager manager].successBlock = success; | 180 | +- (void)getVideoURL:(nullable NSString *)URL success:(GetVideoURLSuccessBlock)success { |
| 181 | + _manager.successBlock = success; | ||
| 182 | _manager.result = NO; | 182 | _manager.result = NO; |
| 183 | 183 | ||
| 184 | NSURLSessionConfiguration *sessionConfig = [NSURLSessionConfiguration defaultSessionConfiguration]; | 184 | NSURLSessionConfiguration *sessionConfig = [NSURLSessionConfiguration defaultSessionConfiguration]; |
CNLivePlayer/Classes/Player/CNLivePlayer.m
| @@ -264,6 +264,10 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang | @@ -264,6 +264,10 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang | ||
| 264 | [self removeMovieNotificationObservers]; | 264 | [self removeMovieNotificationObservers]; |
| 265 | [self removeHostStatusNotificationObservers]; | 265 | [self removeHostStatusNotificationObservers]; |
| 266 | 266 | ||
| 267 | + if (PLAYER_TestEnvironment) { | ||
| 268 | + NSLog(@"CNLivePlayer-->dealloc"); | ||
| 269 | + } | ||
| 270 | + | ||
| 267 | } | 271 | } |
| 268 | 272 | ||
| 269 | - (void)dealloc { | 273 | - (void)dealloc { |
| @@ -315,7 +319,7 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang | @@ -315,7 +319,7 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang | ||
| 315 | }else{ | 319 | }else{ |
| 316 | __weak typeof(self) weakSelf = self; | 320 | __weak typeof(self) weakSelf = self; |
| 317 | //4.不存在鉴权成功,先请求鉴权 | 321 | //4.不存在鉴权成功,先请求鉴权 |
| 318 | - [weakSelf authenticateSuccess:^{ | 322 | + [self authenticateSuccess:^{ |
| 319 | //5.鉴权成功,再请求url | 323 | //5.鉴权成功,再请求url |
| 320 | __strong typeof(self) strongSelf = weakSelf; | 324 | __strong typeof(self) strongSelf = weakSelf; |
| 321 | if([strongSelf->_contentType isEqualToString:@"vod"]){ | 325 | if([strongSelf->_contentType isEqualToString:@"vod"]){ |
| @@ -405,9 +409,9 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang | @@ -405,9 +409,9 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang | ||
| 405 | NSString *videoUrl = [CNLivePlayerTools encryptionSignWithUrl:vodUrl parameter:parameter]; | 409 | NSString *videoUrl = [CNLivePlayerTools encryptionSignWithUrl:vodUrl parameter:parameter]; |
| 406 | 410 | ||
| 407 | __weak typeof(self) weakSelf = self; | 411 | __weak typeof(self) weakSelf = self; |
| 408 | - [CNLivePlayerNetworkManager getVideoURL:videoUrl success:^(NSString * _Nullable videoURL, NSInteger code) { | 412 | + [[CNLivePlayerNetworkManager manager] getVideoURL:videoUrl success:^(NSString * _Nullable videoURL, NSInteger code) { |
| 409 | __strong typeof(self) strongSelf = weakSelf; | 413 | __strong typeof(self) strongSelf = weakSelf; |
| 410 | - CNLivePlayerDBModel *model = [[CNLivePlayerDBModel alloc]initWithContenId:self->_contentId url:videoUrl]; | 414 | + CNLivePlayerDBModel *model = [[CNLivePlayerDBModel alloc]initWithContenId:self->_contentId url:videoURL]; |
| 411 | [[CNLivePlayerDBTool shared] insertTable:model]; | 415 | [[CNLivePlayerDBTool shared] insertTable:model]; |
| 412 | 416 | ||
| 413 | __weak typeof(self) weakSelf = strongSelf; | 417 | __weak typeof(self) weakSelf = strongSelf; |
| @@ -637,6 +641,7 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang | @@ -637,6 +641,7 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang | ||
| 637 | if (!_preparedToPlay && !_statTimer) { | 641 | if (!_preparedToPlay && !_statTimer) { |
| 638 | [self mediaIsPreparedToPlayDidChange:nil]; | 642 | [self mediaIsPreparedToPlayDidChange:nil]; |
| 639 | } | 643 | } |
| 644 | + | ||
| 640 | } | 645 | } |
| 641 | 646 | ||
| 642 | } | 647 | } |
Example/CNLivePlayer/CNLivePlayerController.m
| @@ -34,7 +34,7 @@ | @@ -34,7 +34,7 @@ | ||
| 34 | 34 | ||
| 35 | //1066_716fabeaafb64236b60ecf74167c5c96 | 35 | //1066_716fabeaafb64236b60ecf74167c5c96 |
| 36 | //82_c8ff347048414b7295cef882f8361073 | 36 | //82_c8ff347048414b7295cef882f8361073 |
| 37 | - _player = [[CNLivePlayer alloc]initAudioPlayerWithAudioId:@"82_c8ff347048414b7295cef882f8361073" authSuccess:^{ | 37 | + _player = [[CNLivePlayer alloc]initAudioPlayerWithAudioId:@"1066_716fabeaafb64236b60ecf74167c5c96" authSuccess:^{ |
| 38 | NSLog(@"---------------初始化播放器成功---------------"); | 38 | NSLog(@"---------------初始化播放器成功---------------"); |
| 39 | _player.view.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.width*9/16.0); | 39 | _player.view.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.width*9/16.0); |
| 40 | 40 | ||
| @@ -84,7 +84,7 @@ | @@ -84,7 +84,7 @@ | ||
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | - (void)btnDidClicked{ | 86 | - (void)btnDidClicked{ |
| 87 | - [_player setPlayerWithContentId:@"1066_716fabeaafb64236b60ecf74167c5c96" type:CNLivePlayerVod authSuccess:^{ | 87 | + [_player setPlayerWithContentId:@"82_c8ff347048414b7295cef882f8361073" type:CNLivePlayerVod authSuccess:^{ |
| 88 | [_player prepareToPlay]; | 88 | [_player prepareToPlay]; |
| 89 | 89 | ||
| 90 | } authFailure:^(NSDictionary * _Nonnull errorInfo) { | 90 | } authFailure:^(NSDictionary * _Nonnull errorInfo) { |