From aee00e14940d4a8506a355b57c0cb75776fd9074 Mon Sep 17 00:00:00 2001 From: David Chopin Date: Mon, 20 Feb 2023 10:14:12 -0600 Subject: [PATCH] Made it so that a BetterPlayerEvent with a betterPlayerEventType of pipStart is posted whenever we enter pip mode on iOS devices - DC --- ios/Classes/BetterPlayerPlugin.m | 1 + lib/src/core/better_player_controller.dart | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ios/Classes/BetterPlayerPlugin.m b/ios/Classes/BetterPlayerPlugin.m index ed50403fa..63d93499d 100644 --- a/ios/Classes/BetterPlayerPlugin.m +++ b/ios/Classes/BetterPlayerPlugin.m @@ -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]){ diff --git a/lib/src/core/better_player_controller.dart b/lib/src/core/better_player_controller.dart index d1a53bc31..8bd613758 100644 --- a/lib/src/core/better_player_controller.dart +++ b/lib/src/core/better_player_controller.dart @@ -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."); }