Skip to content

Commit

Permalink
Made it so that a BetterPlayerEvent with a betterPlayerEventType of p…
Browse files Browse the repository at this point in the history
…ipStart is posted whenever we enter pip mode on iOS devices - DC
  • Loading branch information
ChopinDavid committed Feb 20, 2023
1 parent e45f447 commit 5bce4bb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions ios/Classes/BetterPlayerPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
double width = [argsMap[@"width"] doubleValue];
double height = [argsMap[@"height"] doubleValue];
[player enablePictureInPicture:CGRectMake(left, top, width, height)];
result(nil);
} else if ([@"isPictureInPictureSupported" isEqualToString:call.method]){
if (@available(iOS 9.0, *)){
if ([AVPictureInPictureController isPictureInPictureSupported]){
Expand Down
4 changes: 3 additions & 1 deletion lib/src/core/better_player_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1085,12 +1085,14 @@ class BetterPlayerController {
return;
}
final Offset position = renderBox.localToGlobal(Offset.zero);
return videoPlayerController?.enablePictureInPicture(
await videoPlayerController?.enablePictureInPicture(
left: position.dx,
top: position.dy,
width: renderBox.size.width,
height: renderBox.size.height,
);
_postEvent(BetterPlayerEvent(BetterPlayerEventType.pipStart));
return;
} else {
BetterPlayerUtils.log("Unsupported PiP in current platform.");
}
Expand Down

0 comments on commit 5bce4bb

Please sign in to comment.