Commit 79b8cafa3445723ec7cca77d9ae08cec5ec8058f
1 parent
f969a1ba
no message
Showing
2 changed files
with
10 additions
and
10 deletions
CNLivePlayer/Classes/Player/CNLivePlayer.m
| @@ -69,7 +69,6 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang | @@ -69,7 +69,6 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang | ||
| 69 | [self addMovieNotificationObservers]; | 69 | [self addMovieNotificationObservers]; |
| 70 | 70 | ||
| 71 | self.player = [[KSYMoviePlayerController alloc] initWithContentURL:url]; | 71 | self.player = [[KSYMoviePlayerController alloc] initWithContentURL:url]; |
| 72 | - | ||
| 73 | [self.view addSubview:_player.view]; | 72 | [self.view addSubview:_player.view]; |
| 74 | _player.view.frame = self.view.bounds; | 73 | _player.view.frame = self.view.bounds; |
| 75 | _player.view.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight; | 74 | _player.view.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight; |
| @@ -271,8 +270,7 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang | @@ -271,8 +270,7 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang | ||
| 271 | } | 270 | } |
| 272 | 271 | ||
| 273 | - (void)dealloc { | 272 | - (void)dealloc { |
| 274 | - [self destroyPlayer]; | ||
| 275 | - | 273 | + |
| 276 | } | 274 | } |
| 277 | 275 | ||
| 278 | #pragma mark - 查找本地是否有缓存url | 276 | #pragma mark - 查找本地是否有缓存url |
Example/CNLivePlayer/CNLivePlayerController.m
| @@ -34,21 +34,24 @@ | @@ -34,21 +34,24 @@ | ||
| 34 | 34 | ||
| 35 | //1066_716fabeaafb64236b60ecf74167c5c96 | 35 | //1066_716fabeaafb64236b60ecf74167c5c96 |
| 36 | //82_c8ff347048414b7295cef882f8361073 | 36 | //82_c8ff347048414b7295cef882f8361073 |
| 37 | - _player = [[CNLivePlayer alloc]initAudioPlayerWithAudioId:@"1066_716fabeaafb64236b60ecf74167c5c96" authSuccess:^{ | 37 | + __weak typeof(self) weakSelf = self; |
| 38 | + self.player = [[CNLivePlayer alloc]initAudioPlayerWithAudioId:@"1066_716fabeaafb64236b60ecf74167c5c96" authSuccess:^{ | ||
| 38 | NSLog(@"---------------初始化播放器成功---------------"); | 39 | NSLog(@"---------------初始化播放器成功---------------"); |
| 39 | - _player.view.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.width*9/16.0); | 40 | + __strong typeof(self) strongSelf = weakSelf; |
| 41 | + strongSelf.player.view.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.width*9/16.0); | ||
| 40 | 42 | ||
| 41 | - [_player prepareToPlay]; | ||
| 42 | - [self.view addSubview:_player.view]; | 43 | + [strongSelf.player prepareToPlay]; |
| 44 | + [strongSelf.view addSubview:weakSelf.player.view]; | ||
| 43 | 45 | ||
| 44 | - NSLog(@"-----%@", _player.contentURL); | 46 | + NSLog(@"-----%@", strongSelf.player.contentURL); |
| 45 | 47 | ||
| 46 | 48 | ||
| 47 | } authFailure:^(NSDictionary * _Nonnull errorInfo) { | 49 | } authFailure:^(NSDictionary * _Nonnull errorInfo) { |
| 48 | NSLog(@"%@", errorInfo); | 50 | NSLog(@"%@", errorInfo); |
| 49 | 51 | ||
| 50 | }]; | 52 | }]; |
| 51 | - | 53 | + _player.view.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.width*9/16.0); |
| 54 | + | ||
| 52 | UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; | 55 | UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; |
| 53 | btn.frame =CGRectMake(0, 0, 100, 100); | 56 | btn.frame =CGRectMake(0, 0, 100, 100); |
| 54 | btn.center = self.view.center; | 57 | btn.center = self.view.center; |
| @@ -80,7 +83,6 @@ | @@ -80,7 +83,6 @@ | ||
| 80 | 83 | ||
| 81 | - (void)dealloc{ | 84 | - (void)dealloc{ |
| 82 | [_player destroyPlayer]; | 85 | [_player destroyPlayer]; |
| 83 | - | ||
| 84 | } | 86 | } |
| 85 | 87 | ||
| 86 | - (void)btnDidClicked{ | 88 | - (void)btnDidClicked{ |