Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-01-22 11:00:45 +08:00
parent 05e8ded86a
commit 92e5fae29c
6 changed files with 247 additions and 260 deletions

View File

@@ -1,6 +1,6 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'dart:async' show StreamSubscription, Timer;
import 'dart:convert' show ascii;
import 'dart:io' show Platform, File, Directory;
import 'dart:math' show max, min;
import 'dart:ui' as ui;
@@ -36,7 +36,7 @@ import 'package:PiliPlus/utils/extension/num_ext.dart';
import 'package:PiliPlus/utils/extension/string_ext.dart';
import 'package:PiliPlus/utils/feed_back.dart';
import 'package:PiliPlus/utils/image_utils.dart';
import 'package:PiliPlus/utils/page_utils.dart' show PageUtils;
import 'package:PiliPlus/utils/page_utils.dart';
import 'package:PiliPlus/utils/path_utils.dart';
import 'package:PiliPlus/utils/platform_utils.dart';
import 'package:PiliPlus/utils/storage.dart';
@@ -50,7 +50,8 @@ import 'package:easy_debounce/easy_throttle.dart';
import 'package:floating/floating.dart';
import 'package:flutter/foundation.dart' show kDebugMode;
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter/services.dart'
show rootBundle, HapticFeedback, Uint8List;
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:flutter_volume_controller/flutter_volume_controller.dart';
import 'package:get/get.dart';
@@ -235,8 +236,6 @@ class PlPlayerController {
return windowManager.setAlwaysOnTop(value);
}
Offset initialFocalPoint = Offset.zero;
Future<void> exitDesktopPip() {
isDesktopPip = false;
return Future.wait([
@@ -307,13 +306,13 @@ class PlPlayerController {
}
}
void disableAutoEnterPipIfNeeded() {
void _disableAutoEnterPipIfNeeded() {
if (!_isPreviousVideoPage) {
disableAutoEnterPip();
_disableAutoEnterPip();
}
}
void disableAutoEnterPip() {
void _disableAutoEnterPip() {
if (_shouldSetPip) {
Utils.channel.invokeMethod('setPipAutoEnterEnabled', {
'autoEnable': false,
@@ -1003,12 +1002,12 @@ class PlPlayerController {
if (_isCurrVideoPage) {
enterPip(isAuto: true);
} else {
disableAutoEnterPip();
_disableAutoEnterPip();
}
}
playerStatus.value = PlayerStatus.playing;
} else {
disableAutoEnterPip();
_disableAutoEnterPip();
playerStatus.value = PlayerStatus.paused;
}
videoPlayerServiceHandler?.onStatusChange(
@@ -1698,7 +1697,7 @@ class PlPlayerController {
danmakuController = null;
_stopListenerForVideoFit();
_stopListenerForEnterFullScreen();
disableAutoEnterPip();
_disableAutoEnterPip();
setPlayCallBack(null);
dmState.clear();
if (showSeekPreview) {
@@ -1873,4 +1872,23 @@ class PlPlayerController {
}
});
}
bool onPopInvokedWithResult(bool didPop, Object? result) {
if (Platform.isAndroid && didPop) {
_disableAutoEnterPipIfNeeded();
}
if (controlsLock.value) {
onLockControl(false);
return true;
}
if (isDesktopPip) {
exitDesktopPip();
return true;
}
if (isFullScreen.value) {
triggerFullScreen(status: false);
return true;
}
return false;
}
}