Skip to content

Commit

Permalink
Fix the problem that OC project PIP case does not take effect when cl…
Browse files Browse the repository at this point in the history
…icking the PIP button for the first time or back to the home screen for the first time
  • Loading branch information
qinhui committed Oct 17, 2024
1 parent ec29074 commit 9d4d2f6
Showing 1 changed file with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,6 @@ - (SampleBufferDisplayView *)remoteView {
return _remoteView;
}

- (AgoraPictureInPictureController *)pipController {
if (_pipController == nil) {
_pipController = [[AgoraPictureInPictureController alloc] initWithDisplayView:self.remoteView.videoView];
if (@available(iOS 14.2, *)) {
_pipController.pipController.canStartPictureInPictureAutomaticallyFromInline = YES;
}
_pipController.pipController.delegate = self;
}
return _pipController;
}

- (void)viewDidLoad {
[super viewDidLoad];

Expand Down Expand Up @@ -139,7 +128,19 @@ - (void)viewDidLoad {
NSLog(@"joinChannel call failed: %d, please check your params", result);
}
}];

//AgoraPictureInPictureController cannot be initialized at the first click of the button, and needs to be initialized in advance (there will be bugs in lazy loading, and the first click of the pip button pip will not take effect), so initialize AgoraPictureInPictureController in viewDidLoad
[self setupPIPViewController];
}

- (void)setupPIPViewController {
_pipController = [[AgoraPictureInPictureController alloc] initWithDisplayView:self.remoteView.videoView];
if (@available(iOS 14.2, *)) {
_pipController.pipController.canStartPictureInPictureAutomaticallyFromInline = YES;
}
_pipController.pipController.delegate = self;
}

- (IBAction)onPIP:(UIButton *)sender {
if (self.pipController.pipController) {
[self.pipController.pipController startPictureInPicture];
Expand Down

0 comments on commit 9d4d2f6

Please sign in to comment.