From 9db89193453877546459eefdf79cb119905ba520 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sat, 1 Jun 2024 00:21:04 +0800 Subject: [PATCH] opt: pip issues #752 --- lib/pages/video/detail/view.dart | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/pages/video/detail/view.dart b/lib/pages/video/detail/view.dart index 2dc586b6..fa531684 100644 --- a/lib/pages/video/detail/view.dart +++ b/lib/pages/video/detail/view.dart @@ -99,7 +99,6 @@ class _VideoDetailPageState extends State fullScreenStatusListener(); if (Platform.isAndroid) { floating = vdCtr.floating!; - autoEnterPip(); } WidgetsBinding.instance.addObserver(this); lifecycleListener(); @@ -128,8 +127,9 @@ class _VideoDetailPageState extends State } // 播放器状态监听 - void playerListener(PlayerStatus? status) async { - playerStatus.value = status!; + void playerListener(PlayerStatus status) async { + playerStatus.value = status; + autoEnterPip(status: status); if (status == PlayerStatus.completed) { // 结束播放退出全屏 if (autoExitFullcreen) { @@ -181,6 +181,7 @@ class _VideoDetailPageState extends State plPlayerController!.addStatusLister(playerListener); vdCtr.autoPlay.value = true; vdCtr.isShowCover.value = false; + autoEnterPip(status: PlayerStatus.playing); } void fullScreenStatusListener() { @@ -287,10 +288,12 @@ class _VideoDetailPageState extends State .subscribe(this, ModalRoute.of(context)! as PageRoute); } - void autoEnterPip() { + void autoEnterPip({PlayerStatus? status}) { final String routePath = Get.currentRoute; if (autoPiP && routePath.startsWith('/video')) { - floating.toggleAutoPip(autoEnter: autoPiP); + floating.toggleAutoPip( + autoEnter: autoPiP && status == PlayerStatus.playing, + ); } }