improve handling video pop

Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-04-28 18:23:29 +08:00
parent 9ed8b14d1b
commit 88c01ffca3
5 changed files with 17 additions and 26 deletions

View File

@@ -57,6 +57,7 @@ import 'package:media_kit/media_kit.dart';
import 'package:media_kit_video/media_kit_video.dart';
import 'package:native_device_orientation/native_device_orientation.dart';
import 'package:path/path.dart' as path;
import 'package:screen_brightness_platform_interface/screen_brightness_platform_interface.dart';
import 'package:wakelock_plus/wakelock_plus.dart';
import 'package:window_manager/window_manager.dart';
@@ -281,10 +282,6 @@ class PlPlayerController with BlockConfigMixin {
return _isVideoPage(routing.current);
}
static bool get _isPreviousVideoPage {
return _isVideoPage(Get.previousRoute);
}
static bool _isVideoPage(String routeName) {
return routeName == '/videoV' || routeName == '/liveRoom';
}
@@ -301,12 +298,6 @@ class PlPlayerController with BlockConfigMixin {
}
}
void _disableAutoEnterPipIfNeeded() {
if (!_isPreviousVideoPage) {
_disableAutoEnterPip();
}
}
void _disableAutoEnterPip() {
if (_shouldSetPip) {
Utils.channel.invokeMethod('setPipAutoEnterEnabled', {
@@ -1636,10 +1627,6 @@ class PlPlayerController with BlockConfigMixin {
if (!_isCloseAll && _playerCount > 1) {
_playerCount -= 1;
_heartDuration = 0;
// called after pop
if (!_isCurrVideoPage) {
pause();
}
return;
}
@@ -1798,11 +1785,22 @@ class PlPlayerController with BlockConfigMixin {
void onPopInvokedWithResult(bool didPop, Object? result) {
if (didPop) {
if (Platform.isAndroid) {
_disableAutoEnterPipIfNeeded();
if (playerStatus.isPlaying) {
pause();
}
setPlayCallBack(null);
if (Platform.isAndroid && _playerCount <= 1) {
_disableAutoEnterPip();
if (!setSystemBrightness) {
ScreenBrightnessPlatform.instance.resetApplicationScreenBrightness();
}
}
return;
}
if (controlsLock.value) {
onLockControl(false);
return;