Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-10-18 17:21:14 +08:00
parent d908f58528
commit 6ca0de96f4
2 changed files with 20 additions and 5 deletions

View File

@@ -2149,6 +2149,9 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
} }
void _onPopInvokedWithResult(bool didPop, result) { void _onPopInvokedWithResult(bool didPop, result) {
if (didPop) {
videoDetailController.plPlayerController.disableAutoEnterPipIfNeeded();
}
if (plPlayerController?.controlsLock.value == true) { if (plPlayerController?.controlsLock.value == true) {
plPlayerController?.onLockControl(false); plPlayerController?.onLockControl(false);
return; return;

View File

@@ -310,12 +310,19 @@ class PlPlayerController {
} }
late bool _shouldSetPip = false; late bool _shouldSetPip = false;
bool get _isVideoPage {
bool get _isCurrVideoPage {
final currentRoute = Get.currentRoute; final currentRoute = Get.currentRoute;
return currentRoute.startsWith('/video') || return currentRoute.startsWith('/video') ||
currentRoute.startsWith('/liveRoom'); currentRoute.startsWith('/liveRoom');
} }
bool get _isPreviousVideoPage {
final previousRoute = Get.previousRoute;
return previousRoute.startsWith('/video') ||
previousRoute.startsWith('/liveRoom');
}
void enterPip({bool isAuto = false}) { void enterPip({bool isAuto = false}) {
if (videoController != null) { if (videoController != null) {
final state = videoController!.player.state; final state = videoController!.player.state;
@@ -327,6 +334,12 @@ class PlPlayerController {
} }
} }
void disableAutoEnterPipIfNeeded() {
if (!_isPreviousVideoPage) {
disableAutoEnterPip();
}
}
void disableAutoEnterPip() { void disableAutoEnterPip() {
if (_shouldSetPip) { if (_shouldSetPip) {
Utils.channel.invokeMethod('setPipAutoEnterEnabled', { Utils.channel.invokeMethod('setPipAutoEnterEnabled', {
@@ -576,7 +589,7 @@ class PlPlayerController {
if (sdkInt < 31) { if (sdkInt < 31) {
Utils.channel.setMethodCallHandler((call) async { Utils.channel.setMethodCallHandler((call) async {
if (call.method == 'onUserLeaveHint') { if (call.method == 'onUserLeaveHint') {
if (playerStatus.playing && _isVideoPage) { if (playerStatus.playing && _isCurrVideoPage) {
enterPip(); enterPip();
} }
} }
@@ -1025,7 +1038,7 @@ class PlPlayerController {
videoPlayerController!.stream.playing.listen((event) { videoPlayerController!.stream.playing.listen((event) {
if (event) { if (event) {
if (_shouldSetPip) { if (_shouldSetPip) {
if (_isVideoPage) { if (_isCurrVideoPage) {
enterPip(isAuto: true); enterPip(isAuto: true);
} else { } else {
disableAutoEnterPip(); disableAutoEnterPip();
@@ -1720,8 +1733,7 @@ class PlPlayerController {
if (!isCloseAll && _playerCount > 1) { if (!isCloseAll && _playerCount > 1) {
_playerCount -= 1; _playerCount -= 1;
_heartDuration = 0; _heartDuration = 0;
if (!_isVideoPage) { if (!_isPreviousVideoPage) {
disableAutoEnterPip();
pause(); pause();
} }
return; return;