mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-20 03:06:59 +08:00
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,6 +140,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
|
||||
GestureType? _gestureType;
|
||||
|
||||
Offset initialFocalPoint = Offset.zero;
|
||||
|
||||
//播放器放缩
|
||||
bool interacting = false;
|
||||
|
||||
@@ -941,7 +943,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
if (details.pointerCount > 1) {
|
||||
interacting = true;
|
||||
}
|
||||
plPlayerController.initialFocalPoint = localFocalPoint;
|
||||
initialFocalPoint = localFocalPoint;
|
||||
// if (kDebugMode) {
|
||||
// debugPrint("_initialFocalPoint$_initialFocalPoint");
|
||||
// }
|
||||
@@ -951,11 +953,10 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
void _onInteractionUpdate(ScaleUpdateDetails details) {
|
||||
showRestoreScaleBtn.value =
|
||||
transformationController.value.storage[0] != 1.0;
|
||||
if (interacting || plPlayerController.initialFocalPoint == Offset.zero) {
|
||||
if (interacting || initialFocalPoint == Offset.zero) {
|
||||
return;
|
||||
}
|
||||
Offset cumulativeDelta =
|
||||
details.localFocalPoint - plPlayerController.initialFocalPoint;
|
||||
Offset cumulativeDelta = details.localFocalPoint - initialFocalPoint;
|
||||
if (details.pointerCount > 1 && cumulativeDelta.distanceSquared < 2.25) {
|
||||
interacting = true;
|
||||
_gestureType = null;
|
||||
@@ -1083,8 +1084,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
} else if (_gestureType == GestureType.center) {
|
||||
// 全屏
|
||||
const double threshold = 2.5; // 滑动阈值
|
||||
double cumulativeDy =
|
||||
details.localFocalPoint.dy - plPlayerController.initialFocalPoint.dy;
|
||||
double cumulativeDy = details.localFocalPoint.dy - initialFocalPoint.dy;
|
||||
|
||||
void fullScreenTrigger(bool status) {
|
||||
plPlayerController.triggerFullScreen(status: status);
|
||||
@@ -1143,7 +1143,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
plPlayerController.onChangedSliderEnd();
|
||||
}
|
||||
interacting = false;
|
||||
plPlayerController.initialFocalPoint = Offset.zero;
|
||||
initialFocalPoint = Offset.zero;
|
||||
_gestureType = null;
|
||||
}
|
||||
|
||||
@@ -1261,9 +1261,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
status: !isFullScreen,
|
||||
inAppFullScreen: isSecondaryBtn,
|
||||
)
|
||||
.whenComplete(
|
||||
() => plPlayerController.initialFocalPoint = Offset.zero,
|
||||
);
|
||||
.whenComplete(() => initialFocalPoint = Offset.zero);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user