feat: 手指滑动快进、快退
This commit is contained in:
@ -505,15 +505,16 @@ class PlPlayerController {
|
||||
}
|
||||
|
||||
void onChangedSliderStart() {
|
||||
feedBack();
|
||||
_isSliderMoving.value = true;
|
||||
}
|
||||
|
||||
void onUodatedSliderProgress(value) {
|
||||
void onUodatedSliderProgress(Duration value) {
|
||||
_sliderTempPosition.value = value;
|
||||
_sliderPosition.value = value;
|
||||
}
|
||||
|
||||
void onChangedSliderEnd() {
|
||||
feedBack();
|
||||
_isSliderMoving.value = false;
|
||||
_hideTaskControls();
|
||||
}
|
||||
|
@ -57,6 +57,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
Timer? _volumeTimer;
|
||||
|
||||
double _distance = 0.0;
|
||||
// 初始手指落下位置
|
||||
double _initTapPositoin = 0.0;
|
||||
|
||||
bool _volumeInterceptEventStream = false;
|
||||
|
||||
@ -464,8 +466,28 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
_.setPlaybackSpeed(currentSpeed / 2);
|
||||
},
|
||||
// 水平位置 快进
|
||||
onHorizontalDragUpdate: (DragUpdateDetails details) {},
|
||||
onHorizontalDragEnd: (DragEndDetails details) {},
|
||||
onHorizontalDragUpdate: (DragUpdateDetails details) {
|
||||
final tapPosition = details.localPosition.dx;
|
||||
int curSliderPosition = _.sliderPosition.value.inSeconds;
|
||||
late int result;
|
||||
if (tapPosition - _initTapPositoin > 0) {
|
||||
// 快进
|
||||
/// TODO 优化屏幕越小效果越明显
|
||||
result = (curSliderPosition + 1)
|
||||
.clamp(0, _.duration.value.inSeconds);
|
||||
} else {
|
||||
// 快退
|
||||
result = (curSliderPosition - 1)
|
||||
.clamp(0, _.duration.value.inSeconds);
|
||||
}
|
||||
_.onUodatedSliderProgress(Duration(seconds: result));
|
||||
_.onChangedSliderStart();
|
||||
_initTapPositoin = tapPosition;
|
||||
},
|
||||
onHorizontalDragEnd: (DragEndDetails details) {
|
||||
_.onChangedSliderEnd();
|
||||
_.seekTo(_.sliderPosition.value);
|
||||
},
|
||||
// 垂直方向 音量/亮度调节
|
||||
onVerticalDragUpdate: (DragUpdateDetails details) async {
|
||||
final totalWidth = MediaQuery.of(context).size.width;
|
||||
@ -546,7 +568,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
return Container();
|
||||
}
|
||||
return Positioned(
|
||||
bottom: -3,
|
||||
bottom: -3.5,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: SlideTransition(
|
||||
|
@ -4,6 +4,7 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/plugin/pl_player/index.dart';
|
||||
import 'package:pilipala/plugin/pl_player/widgets/play_pause_btn.dart';
|
||||
import 'package:pilipala/utils/feed_back.dart';
|
||||
|
||||
class BottomControl extends StatelessWidget implements PreferredSizeWidget {
|
||||
final PlPlayerController? controller;
|
||||
@ -55,6 +56,7 @@ class BottomControl extends StatelessWidget implements PreferredSizeWidget {
|
||||
barHeight: 3.0,
|
||||
thumbRadius: 5.5,
|
||||
onDragStart: (duration) {
|
||||
feedBack();
|
||||
_.onChangedSliderStart();
|
||||
},
|
||||
onDragUpdate: (duration) {
|
||||
|
Reference in New Issue
Block a user