Skip to content

Commit

Permalink
Merge branch 'feature/pip-fix-improvement' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
pyby committed Jan 6, 2021
2 parents 8215253 + 9b49908 commit 516ebc2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Sources/SRGMediaPlayer/SRGPictureInPictureFix.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ - (void)applicationDidBecomeActive:(NSNotification *)notification
// Somehow Apple manages to circumvent this issue internally with `AVPlayerViewController` which, if
// displayed once, ensures proper behavior afterwards.
SRGDummyPlayerViewController *playerViewController = [[SRGDummyPlayerViewController alloc] init];
playerViewController.modalPresentationStyle = UIModalPresentationOverCurrentContext;
playerViewController.definesPresentationContext = NO;
playerViewController.player = [AVPlayer new];

UIViewController *rootViewController = UIApplication.sharedApplication.keyWindow.rootViewController;
[rootViewController presentViewController:playerViewController animated:NO completion:^{
[rootViewController dismissViewControllerAnimated:NO completion:nil];
}];
UIView *playerView = playerViewController.view;
UIWindow *keyWindow = UIApplication.sharedApplication.keyWindow;
[keyWindow addSubview:playerView];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[playerView removeFromSuperview];
});
});
}

Expand Down

0 comments on commit 516ebc2

Please sign in to comment.