Skip to content

Commit

Permalink
refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
mvn-hieunguyen-hn committed Oct 23, 2024
1 parent df04b45 commit 5ab3488
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions ios/Classes/BetterPlayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,6 @@ - (nonnull UIView *)view {
BetterPlayerView *playerView = [[BetterPlayerView alloc] initWithFrame:CGRectZero];
playerView.player = _player;
self._betterPlayerView = playerView;

if (_pipController) {
AVPlayerLayer *playerLayer = playerView.playerLayer;
if (playerLayer) {
_pipController.contentSource = [[AVPictureInPictureControllerContentSource alloc] initWithPlayerLayer:playerLayer];
_pipController.canStartPictureInPictureAutomaticallyFromInline = false;
}
}

return playerView;
}

Expand Down Expand Up @@ -712,8 +703,7 @@ - (void)setupPipController {
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
AVPlayerLayer *playerLayer = self._betterPlayerView.playerLayer;
if (!_pipController && playerLayer && [AVPictureInPictureController isPictureInPictureSupported]) {
AVPictureInPictureControllerContentSource *contentSource = [[AVPictureInPictureControllerContentSource alloc] initWithPlayerLayer:playerLayer];
_pipController = [[AVPictureInPictureController alloc] initWithContentSource: contentSource];
_pipController = [[AVPictureInPictureController alloc] initWithPlayerLayer: playerLayer];
if (@available(iOS 14.2, *)) {
_pipController.canStartPictureInPictureAutomaticallyFromInline = true;
}
Expand Down Expand Up @@ -925,6 +915,7 @@ - (void) hidePIPPlayerPlaceholderView {
}

- (void)resetPipController {
// use `playerLayer` from `_player` instead of `_pipController.contentSource.playerLayer` to reset `pipController`.
AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:_player];
if (!playerLayer) {
return;
Expand Down

0 comments on commit 5ab3488

Please sign in to comment.