diff --git a/lib/pages/video/view.dart b/lib/pages/video/view.dart index 27bf1704..e1995f0b 100644 --- a/lib/pages/video/view.dart +++ b/lib/pages/video/view.dart @@ -2149,6 +2149,9 @@ class _VideoDetailPageVState extends State } void _onPopInvokedWithResult(bool didPop, result) { + if (didPop) { + videoDetailController.plPlayerController.disableAutoEnterPipIfNeeded(); + } if (plPlayerController?.controlsLock.value == true) { plPlayerController?.onLockControl(false); return; diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index 40bbaf70..41c99f7d 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -310,12 +310,19 @@ class PlPlayerController { } late bool _shouldSetPip = false; - bool get _isVideoPage { + + bool get _isCurrVideoPage { final currentRoute = Get.currentRoute; return currentRoute.startsWith('/video') || currentRoute.startsWith('/liveRoom'); } + bool get _isPreviousVideoPage { + final previousRoute = Get.previousRoute; + return previousRoute.startsWith('/video') || + previousRoute.startsWith('/liveRoom'); + } + void enterPip({bool isAuto = false}) { if (videoController != null) { final state = videoController!.player.state; @@ -327,6 +334,12 @@ class PlPlayerController { } } + void disableAutoEnterPipIfNeeded() { + if (!_isPreviousVideoPage) { + disableAutoEnterPip(); + } + } + void disableAutoEnterPip() { if (_shouldSetPip) { Utils.channel.invokeMethod('setPipAutoEnterEnabled', { @@ -576,7 +589,7 @@ class PlPlayerController { if (sdkInt < 31) { Utils.channel.setMethodCallHandler((call) async { if (call.method == 'onUserLeaveHint') { - if (playerStatus.playing && _isVideoPage) { + if (playerStatus.playing && _isCurrVideoPage) { enterPip(); } } @@ -1025,7 +1038,7 @@ class PlPlayerController { videoPlayerController!.stream.playing.listen((event) { if (event) { if (_shouldSetPip) { - if (_isVideoPage) { + if (_isCurrVideoPage) { enterPip(isAuto: true); } else { disableAutoEnterPip(); @@ -1720,8 +1733,7 @@ class PlPlayerController { if (!isCloseAll && _playerCount > 1) { _playerCount -= 1; _heartDuration = 0; - if (!_isVideoPage) { - disableAutoEnterPip(); + if (!_isPreviousVideoPage) { pause(); } return;