mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
fix: 全屏手势被遮挡导致难以触发;回调竖向手势触发范围(1:1:1),避免亮度音量调整困难;调高手势灵敏度;屏蔽过于顶部的手势
This commit is contained in:
@@ -523,16 +523,20 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
scaleEnabled: true, // 启用缩放
|
||||
minScale: 1.0,
|
||||
maxScale: 2.0,
|
||||
panAxis: PanAxis.aligned,
|
||||
onInteractionStart: (ScaleStartDetails details) {
|
||||
// 如果起点太靠上则屏蔽
|
||||
if (details.localFocalPoint.dy < 40) return;
|
||||
if (details.pointerCount == 2) {
|
||||
interacting = true;
|
||||
}
|
||||
_initialFocalPoint = details.localFocalPoint;
|
||||
// print("_initialFocalPoint$_initialFocalPoint");
|
||||
_gestureType = null;
|
||||
},
|
||||
|
||||
onInteractionUpdate: (ScaleUpdateDetails details) {
|
||||
if (interacting) return;
|
||||
if (interacting || _initialFocalPoint == Offset.zero) return;
|
||||
Offset cumulativeDelta =
|
||||
details.localFocalPoint - _initialFocalPoint;
|
||||
if (details.pointerCount == 2 && cumulativeDelta.distance < 1.5) {
|
||||
@@ -547,20 +551,20 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
_playerKey.currentContext!.findRenderObject() as RenderBox;
|
||||
|
||||
if (_gestureType == null) {
|
||||
if (cumulativeDelta.distance < 1.5) return;
|
||||
if (cumulativeDelta.dx.abs() > 4 * cumulativeDelta.dy.abs()) {
|
||||
if (cumulativeDelta.distance < 1) return;
|
||||
if (cumulativeDelta.dx.abs() > 3 * cumulativeDelta.dy.abs()) {
|
||||
_gestureType = 'horizontal';
|
||||
} else if (cumulativeDelta.dy.abs() >
|
||||
4 * cumulativeDelta.dx.abs()) {
|
||||
3 * cumulativeDelta.dx.abs()) {
|
||||
// _gestureType = 'vertical';
|
||||
|
||||
final double totalWidth = renderBox.size.width;
|
||||
final double tapPosition = details.localFocalPoint.dx;
|
||||
final double sectionWidth = totalWidth / 4;
|
||||
final double sectionWidth = totalWidth / 3;
|
||||
if (tapPosition < sectionWidth) {
|
||||
// 左边区域
|
||||
_gestureType = 'left';
|
||||
} else if (tapPosition < sectionWidth * 3) {
|
||||
} else if (tapPosition < sectionWidth * 2) {
|
||||
// 全屏
|
||||
_gestureType = 'center';
|
||||
} else {
|
||||
@@ -596,20 +600,15 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
setBrightness(result);
|
||||
} else if (_gestureType == 'center') {
|
||||
// 全屏
|
||||
const double threshold = 5; // 滑动阈值
|
||||
// void fullScreenTrigger(bool status) async {
|
||||
// EasyThrottle.throttle(
|
||||
// 'fullScreen', const Duration(milliseconds: 1000), () {
|
||||
// _.triggerFullScreen(status: status);
|
||||
// });
|
||||
// }
|
||||
|
||||
const double threshold = 2; // 滑动阈值
|
||||
double cumulativeDy =
|
||||
details.localFocalPoint.dy - _initialFocalPoint.dy;
|
||||
if (cumulativeDy > threshold) {
|
||||
_gestureType = 'center_down';
|
||||
// print('center_down:$cumulativeDy');
|
||||
} else if (cumulativeDy < -threshold) {
|
||||
_gestureType = 'center_up';
|
||||
// print('center_up:$cumulativeDy');
|
||||
}
|
||||
} else if (_gestureType == 'right') {
|
||||
// 右边区域
|
||||
@@ -627,10 +626,10 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
_.onChangedSliderEnd();
|
||||
_.seekTo(_.sliderPosition.value, type: 'slider');
|
||||
}
|
||||
void fullScreenTrigger(bool status) async {
|
||||
void fullScreenTrigger(bool status) {
|
||||
EasyThrottle.throttle(
|
||||
'fullScreen', const Duration(milliseconds: 1000), () {
|
||||
_.triggerFullScreen(status: status);
|
||||
'fullScreen', const Duration(milliseconds: 500), () async {
|
||||
await _.triggerFullScreen(status: status);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -695,12 +694,14 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
),
|
||||
|
||||
/// 时间进度 toast
|
||||
Obx(
|
||||
() => Align(
|
||||
IgnorePointer(
|
||||
ignoring: true,
|
||||
child: Align(
|
||||
alignment: Alignment.topCenter,
|
||||
child: FractionalTranslation(
|
||||
translation: const Offset(0.0, 1.0), // 上下偏移量(负数向上偏移)
|
||||
child: AnimatedOpacity(
|
||||
child: Obx(
|
||||
() => AnimatedOpacity(
|
||||
curve: Curves.easeInOut,
|
||||
opacity: _.isSliderMoving.value ? 1.0 : 0.0,
|
||||
duration: const Duration(milliseconds: 150),
|
||||
@@ -742,11 +743,14 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
/// 音量🔊 控制条展示
|
||||
Obx(
|
||||
() => Align(
|
||||
child: AnimatedOpacity(
|
||||
IgnorePointer(
|
||||
ignoring: true,
|
||||
child: Align(
|
||||
child: Obx(
|
||||
() => AnimatedOpacity(
|
||||
curve: Curves.easeInOut,
|
||||
opacity: _volumeIndicator.value ? 1.0 : 0.0,
|
||||
duration: const Duration(milliseconds: 150),
|
||||
@@ -793,11 +797,14 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
/// 亮度🌞 控制条展示
|
||||
Obx(
|
||||
() => Align(
|
||||
child: AnimatedOpacity(
|
||||
IgnorePointer(
|
||||
ignoring: true,
|
||||
child: Align(
|
||||
child: Obx(
|
||||
() => AnimatedOpacity(
|
||||
curve: Curves.easeInOut,
|
||||
opacity: _brightnessIndicator.value ? 1.0 : 0.0,
|
||||
duration: const Duration(milliseconds: 150),
|
||||
@@ -845,6 +852,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Obx(() {
|
||||
// if (_.buffered.value == Duration.zero) {
|
||||
|
||||
Reference in New Issue
Block a user