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, // 启用缩放
|
scaleEnabled: true, // 启用缩放
|
||||||
minScale: 1.0,
|
minScale: 1.0,
|
||||||
maxScale: 2.0,
|
maxScale: 2.0,
|
||||||
|
panAxis: PanAxis.aligned,
|
||||||
onInteractionStart: (ScaleStartDetails details) {
|
onInteractionStart: (ScaleStartDetails details) {
|
||||||
|
// 如果起点太靠上则屏蔽
|
||||||
|
if (details.localFocalPoint.dy < 40) return;
|
||||||
if (details.pointerCount == 2) {
|
if (details.pointerCount == 2) {
|
||||||
interacting = true;
|
interacting = true;
|
||||||
}
|
}
|
||||||
_initialFocalPoint = details.localFocalPoint;
|
_initialFocalPoint = details.localFocalPoint;
|
||||||
|
// print("_initialFocalPoint$_initialFocalPoint");
|
||||||
_gestureType = null;
|
_gestureType = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
onInteractionUpdate: (ScaleUpdateDetails details) {
|
onInteractionUpdate: (ScaleUpdateDetails details) {
|
||||||
if (interacting) return;
|
if (interacting || _initialFocalPoint == Offset.zero) return;
|
||||||
Offset cumulativeDelta =
|
Offset cumulativeDelta =
|
||||||
details.localFocalPoint - _initialFocalPoint;
|
details.localFocalPoint - _initialFocalPoint;
|
||||||
if (details.pointerCount == 2 && cumulativeDelta.distance < 1.5) {
|
if (details.pointerCount == 2 && cumulativeDelta.distance < 1.5) {
|
||||||
@@ -547,20 +551,20 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
_playerKey.currentContext!.findRenderObject() as RenderBox;
|
_playerKey.currentContext!.findRenderObject() as RenderBox;
|
||||||
|
|
||||||
if (_gestureType == null) {
|
if (_gestureType == null) {
|
||||||
if (cumulativeDelta.distance < 1.5) return;
|
if (cumulativeDelta.distance < 1) return;
|
||||||
if (cumulativeDelta.dx.abs() > 4 * cumulativeDelta.dy.abs()) {
|
if (cumulativeDelta.dx.abs() > 3 * cumulativeDelta.dy.abs()) {
|
||||||
_gestureType = 'horizontal';
|
_gestureType = 'horizontal';
|
||||||
} else if (cumulativeDelta.dy.abs() >
|
} else if (cumulativeDelta.dy.abs() >
|
||||||
4 * cumulativeDelta.dx.abs()) {
|
3 * cumulativeDelta.dx.abs()) {
|
||||||
// _gestureType = 'vertical';
|
// _gestureType = 'vertical';
|
||||||
|
|
||||||
final double totalWidth = renderBox.size.width;
|
final double totalWidth = renderBox.size.width;
|
||||||
final double tapPosition = details.localFocalPoint.dx;
|
final double tapPosition = details.localFocalPoint.dx;
|
||||||
final double sectionWidth = totalWidth / 4;
|
final double sectionWidth = totalWidth / 3;
|
||||||
if (tapPosition < sectionWidth) {
|
if (tapPosition < sectionWidth) {
|
||||||
// 左边区域
|
// 左边区域
|
||||||
_gestureType = 'left';
|
_gestureType = 'left';
|
||||||
} else if (tapPosition < sectionWidth * 3) {
|
} else if (tapPosition < sectionWidth * 2) {
|
||||||
// 全屏
|
// 全屏
|
||||||
_gestureType = 'center';
|
_gestureType = 'center';
|
||||||
} else {
|
} else {
|
||||||
@@ -596,20 +600,15 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
setBrightness(result);
|
setBrightness(result);
|
||||||
} else if (_gestureType == 'center') {
|
} else if (_gestureType == 'center') {
|
||||||
// 全屏
|
// 全屏
|
||||||
const double threshold = 5; // 滑动阈值
|
const double threshold = 2; // 滑动阈值
|
||||||
// void fullScreenTrigger(bool status) async {
|
|
||||||
// EasyThrottle.throttle(
|
|
||||||
// 'fullScreen', const Duration(milliseconds: 1000), () {
|
|
||||||
// _.triggerFullScreen(status: status);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
double cumulativeDy =
|
double cumulativeDy =
|
||||||
details.localFocalPoint.dy - _initialFocalPoint.dy;
|
details.localFocalPoint.dy - _initialFocalPoint.dy;
|
||||||
if (cumulativeDy > threshold) {
|
if (cumulativeDy > threshold) {
|
||||||
_gestureType = 'center_down';
|
_gestureType = 'center_down';
|
||||||
|
// print('center_down:$cumulativeDy');
|
||||||
} else if (cumulativeDy < -threshold) {
|
} else if (cumulativeDy < -threshold) {
|
||||||
_gestureType = 'center_up';
|
_gestureType = 'center_up';
|
||||||
|
// print('center_up:$cumulativeDy');
|
||||||
}
|
}
|
||||||
} else if (_gestureType == 'right') {
|
} else if (_gestureType == 'right') {
|
||||||
// 右边区域
|
// 右边区域
|
||||||
@@ -627,10 +626,10 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
_.onChangedSliderEnd();
|
_.onChangedSliderEnd();
|
||||||
_.seekTo(_.sliderPosition.value, type: 'slider');
|
_.seekTo(_.sliderPosition.value, type: 'slider');
|
||||||
}
|
}
|
||||||
void fullScreenTrigger(bool status) async {
|
void fullScreenTrigger(bool status) {
|
||||||
EasyThrottle.throttle(
|
EasyThrottle.throttle(
|
||||||
'fullScreen', const Duration(milliseconds: 1000), () {
|
'fullScreen', const Duration(milliseconds: 500), () async {
|
||||||
_.triggerFullScreen(status: status);
|
await _.triggerFullScreen(status: status);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -695,12 +694,14 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
),
|
),
|
||||||
|
|
||||||
/// 时间进度 toast
|
/// 时间进度 toast
|
||||||
Obx(
|
IgnorePointer(
|
||||||
() => Align(
|
ignoring: true,
|
||||||
|
child: Align(
|
||||||
alignment: Alignment.topCenter,
|
alignment: Alignment.topCenter,
|
||||||
child: FractionalTranslation(
|
child: FractionalTranslation(
|
||||||
translation: const Offset(0.0, 1.0), // 上下偏移量(负数向上偏移)
|
translation: const Offset(0.0, 1.0), // 上下偏移量(负数向上偏移)
|
||||||
child: AnimatedOpacity(
|
child: Obx(
|
||||||
|
() => AnimatedOpacity(
|
||||||
curve: Curves.easeInOut,
|
curve: Curves.easeInOut,
|
||||||
opacity: _.isSliderMoving.value ? 1.0 : 0.0,
|
opacity: _.isSliderMoving.value ? 1.0 : 0.0,
|
||||||
duration: const Duration(milliseconds: 150),
|
duration: const Duration(milliseconds: 150),
|
||||||
@@ -742,11 +743,14 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
|
||||||
/// 音量🔊 控制条展示
|
/// 音量🔊 控制条展示
|
||||||
Obx(
|
IgnorePointer(
|
||||||
() => Align(
|
ignoring: true,
|
||||||
child: AnimatedOpacity(
|
child: Align(
|
||||||
|
child: Obx(
|
||||||
|
() => AnimatedOpacity(
|
||||||
curve: Curves.easeInOut,
|
curve: Curves.easeInOut,
|
||||||
opacity: _volumeIndicator.value ? 1.0 : 0.0,
|
opacity: _volumeIndicator.value ? 1.0 : 0.0,
|
||||||
duration: const Duration(milliseconds: 150),
|
duration: const Duration(milliseconds: 150),
|
||||||
@@ -793,11 +797,14 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
|
||||||
/// 亮度🌞 控制条展示
|
/// 亮度🌞 控制条展示
|
||||||
Obx(
|
IgnorePointer(
|
||||||
() => Align(
|
ignoring: true,
|
||||||
child: AnimatedOpacity(
|
child: Align(
|
||||||
|
child: Obx(
|
||||||
|
() => AnimatedOpacity(
|
||||||
curve: Curves.easeInOut,
|
curve: Curves.easeInOut,
|
||||||
opacity: _brightnessIndicator.value ? 1.0 : 0.0,
|
opacity: _brightnessIndicator.value ? 1.0 : 0.0,
|
||||||
duration: const Duration(milliseconds: 150),
|
duration: const Duration(milliseconds: 150),
|
||||||
@@ -845,6 +852,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
|
||||||
// Obx(() {
|
// Obx(() {
|
||||||
// if (_.buffered.value == Duration.zero) {
|
// if (_.buffered.value == Duration.zero) {
|
||||||
|
|||||||
Reference in New Issue
Block a user