mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: cancel seek
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -1152,27 +1152,8 @@ class PlPlayerController {
|
|||||||
_isSliderMoving.value = true;
|
_isSliderMoving.value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
double? slideDy;
|
bool? cancelSeek;
|
||||||
bool? hasToast;
|
bool? hasToast;
|
||||||
void updateSlideDy(double dy) {
|
|
||||||
slideDy ??= 0;
|
|
||||||
slideDy = slideDy! + dy;
|
|
||||||
if (slideDy!.abs() >= 100) {
|
|
||||||
if (hasToast != true) {
|
|
||||||
hasToast = true;
|
|
||||||
SmartDialog.showToast(
|
|
||||||
'取消${sliderPosition.value > position.value ? '快进' : '快退'}',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (hasToast == true) {
|
|
||||||
hasToast = null;
|
|
||||||
SmartDialog.showToast(
|
|
||||||
sliderPosition.value > position.value ? '快进' : '快退',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void onUpdatedSliderProgress(Duration value) {
|
void onUpdatedSliderProgress(Duration value) {
|
||||||
_sliderTempPosition.value = value;
|
_sliderTempPosition.value = value;
|
||||||
@@ -1180,11 +1161,11 @@ class PlPlayerController {
|
|||||||
updateSliderPositionSecond();
|
updateSliderPositionSecond();
|
||||||
}
|
}
|
||||||
|
|
||||||
void onChangedSliderEnd([bool? isCancel]) {
|
void onChangedSliderEnd() {
|
||||||
if (isCancel != true) {
|
if (cancelSeek != true) {
|
||||||
feedBack();
|
feedBack();
|
||||||
}
|
}
|
||||||
slideDy = null;
|
cancelSeek = null;
|
||||||
hasToast = null;
|
hasToast = null;
|
||||||
_isSliderMoving.value = false;
|
_isSliderMoving.value = false;
|
||||||
_hideTaskControls();
|
_hideTaskControls();
|
||||||
|
|||||||
@@ -771,10 +771,53 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
curSliderPosition + (delta.dx * scale).round());
|
curSliderPosition + (delta.dx * scale).round());
|
||||||
final Duration result =
|
final Duration result =
|
||||||
pos.clamp(Duration.zero, plPlayerController.duration.value);
|
pos.clamp(Duration.zero, plPlayerController.duration.value);
|
||||||
plPlayerController.updateSlideDy(delta.dy);
|
final height = renderBox.size.height * 0.125;
|
||||||
|
if ((details.localFocalPoint.dx >=
|
||||||
|
renderBox.size.width * 0.875 &&
|
||||||
|
details.localFocalPoint.dy <= height) ||
|
||||||
|
(details.localFocalPoint.dx <=
|
||||||
|
renderBox.size.width * 0.125 &&
|
||||||
|
details.localFocalPoint.dy <= height)) {
|
||||||
|
plPlayerController.cancelSeek = true;
|
||||||
|
plPlayerController.showPreview.value = false;
|
||||||
|
if (plPlayerController.hasToast != true) {
|
||||||
|
plPlayerController.hasToast = true;
|
||||||
|
SmartDialog.showAttach(
|
||||||
|
targetContext: context,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
animationTime: const Duration(milliseconds: 200),
|
||||||
|
animationType: SmartAnimationType.fade,
|
||||||
|
displayTime: const Duration(milliseconds: 1500),
|
||||||
|
maskColor: Colors.transparent,
|
||||||
|
builder: (context) => Container(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 8, vertical: 4),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(6),
|
||||||
|
color:
|
||||||
|
Theme.of(context).colorScheme.secondaryContainer,
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
'松开手指,取消进退',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.onSecondaryContainer,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (plPlayerController.cancelSeek == true) {
|
||||||
|
plPlayerController.cancelSeek = null;
|
||||||
|
plPlayerController.hasToast = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
plPlayerController.onUpdatedSliderProgress(result);
|
plPlayerController.onUpdatedSliderProgress(result);
|
||||||
plPlayerController.onChangedSliderStart();
|
plPlayerController.onChangedSliderStart();
|
||||||
if (plPlayerController.showSeekPreview) {
|
if (plPlayerController.showSeekPreview &&
|
||||||
|
plPlayerController.cancelSeek != true) {
|
||||||
try {
|
try {
|
||||||
plPlayerController.previewDx.value = result.inMilliseconds /
|
plPlayerController.previewDx.value = result.inMilliseconds /
|
||||||
plPlayerController
|
plPlayerController
|
||||||
@@ -835,10 +878,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
plPlayerController.showPreview.value = false;
|
plPlayerController.showPreview.value = false;
|
||||||
}
|
}
|
||||||
if (plPlayerController.isSliderMoving.value) {
|
if (plPlayerController.isSliderMoving.value) {
|
||||||
bool isCancel = plPlayerController.slideDy != null &&
|
if (plPlayerController.cancelSeek == true) {
|
||||||
plPlayerController.slideDy!.abs() >= 100;
|
|
||||||
plPlayerController.onChangedSliderEnd(isCancel);
|
|
||||||
if (isCancel) {
|
|
||||||
plPlayerController.onUpdatedSliderProgress(
|
plPlayerController.onUpdatedSliderProgress(
|
||||||
plPlayerController.position.value,
|
plPlayerController.position.value,
|
||||||
);
|
);
|
||||||
@@ -848,6 +888,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
type: 'slider',
|
type: 'slider',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
plPlayerController.onChangedSliderEnd();
|
||||||
}
|
}
|
||||||
interacting = false;
|
interacting = false;
|
||||||
_initialFocalPoint = Offset.zero;
|
_initialFocalPoint = Offset.zero;
|
||||||
|
|||||||
Reference in New Issue
Block a user