diff --git a/lib/pages/live_room/widgets/bottom_control.dart b/lib/pages/live_room/widgets/bottom_control.dart index 6d00ea901..b91cde184 100644 --- a/lib/pages/live_room/widgets/bottom_control.dart +++ b/lib/pages/live_room/widgets/bottom_control.dart @@ -102,7 +102,9 @@ class _BottomControlState extends State { canUsePiP = false; } if (canUsePiP) { - await widget.floating!.enable(); + await widget.floating!.enable( + const EnableManual() + ); } else {} }, icon: const Icon( diff --git a/lib/pages/video/detail/view.dart b/lib/pages/video/detail/view.dart index 45f56f5d8..737f6e546 100644 --- a/lib/pages/video/detail/view.dart +++ b/lib/pages/video/detail/view.dart @@ -117,7 +117,9 @@ class _VideoDetailPageState extends State onUserLeaveHintListener = const MethodChannel("onUserLeaveHint"); onUserLeaveHintListener.setMethodCallHandler((call) async { if (call.method == 'onUserLeaveHint') { - if (autoPiP) { + if (autoPiP && + plPlayerController != null && + playerStatus == PlayerStatus.playing) { autoEnterPip(); } } @@ -364,10 +366,17 @@ class _VideoDetailPageState extends State final String routePath = Get.currentRoute; if (autoPiP && routePath.startsWith('/video')) { - floating.enable( - aspectRatio: Rational( - videoDetailController.data.dash!.video!.first.width!, - videoDetailController.data.dash!.video!.first.height!, + floating.enable(EnableManual( + aspectRatio: Rational( + videoDetailController.data.dash!.video!.first.width!, + videoDetailController.data.dash!.video!.first.height!, + ), + sourceRectHint: Rectangle( + 0, + 0, + context.width.toInt(), + context.height.toInt(), + ), )); } } diff --git a/lib/pages/video/detail/widgets/header_control.dart b/lib/pages/video/detail/widgets/header_control.dart index 2688ab2ae..ffb102a5e 100644 --- a/lib/pages/video/detail/widgets/header_control.dart +++ b/lib/pages/video/detail/widgets/header_control.dart @@ -1206,7 +1206,7 @@ class _HeaderControlState extends State { }, )), if (!isFullScreen || - MediaQuery.of(context).orientation != Orientation.portrait) + MediaQuery.of(context).orientation != Orientation.portrait) SizedBox( width: 42, height: 34, @@ -1420,7 +1420,16 @@ class _HeaderControlState extends State { widget.videoDetailCtr!.data.dash!.video!.first.width!, widget.videoDetailCtr!.data.dash!.video!.first.height!, ); - await widget.floating!.enable(aspectRatio: aspectRatio); + if (!context.mounted) return; + await widget.floating!.enable(EnableManual( + aspectRatio: aspectRatio, + sourceRectHint: Rectangle( + 0, + 0, + context.width.toInt(), + context.height.toInt(), + ), + )); } else {} }, icon: const Icon( diff --git a/pubspec.lock b/pubspec.lock index 62590a0d2..a8b44c4da 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -501,10 +501,10 @@ packages: dependency: "direct main" description: name: floating - sha256: "04c3c96909b94dd6d2d121c69707739825e1f3dceca5ae451a9b8c0e652d246b" + sha256: ddcd7f28247746dbb62997c48c89d1824118676796df47fdc6f864f8d02849bc url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" source: hosted - version: "2.0.2" + version: "3.0.0" flutter: dependency: "direct main" description: flutter diff --git a/pubspec.yaml b/pubspec.yaml index fc732b8dd..07cef833f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -122,7 +122,7 @@ dependencies: # 代理 system_proxy: ^0.1.0 # pip - floating: ^2.0.2 + floating: ^3.0.0 # html解析 html: ^0.15.4 # html渲染