mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
fix: seek anim
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -86,8 +86,6 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
|
|
||||||
final RxBool _mountSeekBackwardButton = false.obs;
|
final RxBool _mountSeekBackwardButton = false.obs;
|
||||||
final RxBool _mountSeekForwardButton = false.obs;
|
final RxBool _mountSeekForwardButton = false.obs;
|
||||||
final RxBool _hideSeekBackwardButton = false.obs;
|
|
||||||
final RxBool _hideSeekForwardButton = false.obs;
|
|
||||||
|
|
||||||
final RxDouble _brightnessValue = 0.0.obs;
|
final RxDouble _brightnessValue = 0.0.obs;
|
||||||
final RxBool _brightnessIndicator = false.obs;
|
final RxBool _brightnessIndicator = false.obs;
|
||||||
@@ -1500,36 +1498,21 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
|
|
||||||
/// 点击 快进/快退
|
/// 点击 快进/快退
|
||||||
Obx(
|
Obx(
|
||||||
() => Visibility(
|
() => _mountSeekBackwardButton.value || _mountSeekForwardButton.value
|
||||||
visible:
|
? Positioned.fill(
|
||||||
_mountSeekBackwardButton.value || _mountSeekForwardButton.value,
|
|
||||||
child: Positioned.fill(
|
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
|
if (_mountSeekBackwardButton.value)
|
||||||
Expanded(
|
Expanded(
|
||||||
child: _mountSeekBackwardButton.value
|
child: TweenAnimationBuilder<double>(
|
||||||
? TweenAnimationBuilder<double>(
|
tween: Tween<double>(begin: 0.0, end: 1.0),
|
||||||
tween: Tween<double>(
|
|
||||||
begin: 0.0,
|
|
||||||
end: _hideSeekBackwardButton.value ? 0.0 : 1.0,
|
|
||||||
),
|
|
||||||
duration: const Duration(milliseconds: 500),
|
duration: const Duration(milliseconds: 500),
|
||||||
builder: (BuildContext context, double value,
|
builder: (context, value, child) => Opacity(
|
||||||
Widget? child) =>
|
|
||||||
Opacity(
|
|
||||||
opacity: value,
|
opacity: value,
|
||||||
child: child,
|
child: child,
|
||||||
),
|
),
|
||||||
onEnd: () {
|
|
||||||
if (_hideSeekBackwardButton.value) {
|
|
||||||
_hideSeekBackwardButton.value = false;
|
|
||||||
_mountSeekBackwardButton.value = false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: BackwardSeekIndicator(
|
child: BackwardSeekIndicator(
|
||||||
onChanged: (Duration value) => {},
|
|
||||||
onSubmitted: (Duration value) {
|
onSubmitted: (Duration value) {
|
||||||
_hideSeekBackwardButton.value = true;
|
|
||||||
_mountSeekBackwardButton.value = false;
|
_mountSeekBackwardButton.value = false;
|
||||||
final Player player = widget
|
final Player player = widget
|
||||||
.plPlayerController.videoPlayerController!;
|
.plPlayerController.videoPlayerController!;
|
||||||
@@ -1538,44 +1521,27 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
Duration.zero,
|
Duration.zero,
|
||||||
player.state.duration,
|
player.state.duration,
|
||||||
);
|
);
|
||||||
plPlayerController.seekTo(result,
|
plPlayerController.seekTo(
|
||||||
type: 'slider');
|
result,
|
||||||
|
type: 'slider',
|
||||||
|
);
|
||||||
plPlayerController.play();
|
plPlayerController.play();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
|
||||||
: const SizedBox.shrink(),
|
|
||||||
),
|
),
|
||||||
const Spacer(),
|
),
|
||||||
// Expanded(
|
const Spacer(flex: 2),
|
||||||
// child: SizedBox(
|
if (_mountSeekForwardButton.value)
|
||||||
// width: context.width / 4,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: _mountSeekForwardButton.value
|
child: TweenAnimationBuilder<double>(
|
||||||
? TweenAnimationBuilder<double>(
|
tween: Tween<double>(begin: 0.0, end: 1.0),
|
||||||
tween: Tween<double>(
|
|
||||||
begin: 0.0,
|
|
||||||
end: _hideSeekForwardButton.value ? 0.0 : 1.0,
|
|
||||||
),
|
|
||||||
duration: const Duration(milliseconds: 500),
|
duration: const Duration(milliseconds: 500),
|
||||||
builder: (BuildContext context, double value,
|
builder: (context, value, child) => Opacity(
|
||||||
Widget? child) =>
|
|
||||||
Opacity(
|
|
||||||
opacity: value,
|
opacity: value,
|
||||||
child: child,
|
child: child,
|
||||||
),
|
),
|
||||||
onEnd: () {
|
|
||||||
if (_hideSeekForwardButton.value) {
|
|
||||||
_hideSeekForwardButton.value = false;
|
|
||||||
_mountSeekForwardButton.value = false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: ForwardSeekIndicator(
|
child: ForwardSeekIndicator(
|
||||||
onChanged: (Duration value) => {},
|
|
||||||
onSubmitted: (Duration value) {
|
onSubmitted: (Duration value) {
|
||||||
_hideSeekForwardButton.value = true;
|
|
||||||
_mountSeekForwardButton.value = false;
|
_mountSeekForwardButton.value = false;
|
||||||
final Player player = widget
|
final Player player = widget
|
||||||
.plPlayerController.videoPlayerController!;
|
.plPlayerController.videoPlayerController!;
|
||||||
@@ -1584,18 +1550,19 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
Duration.zero,
|
Duration.zero,
|
||||||
player.state.duration,
|
player.state.duration,
|
||||||
);
|
);
|
||||||
plPlayerController.seekTo(result,
|
plPlayerController.seekTo(
|
||||||
type: 'slider');
|
result,
|
||||||
|
type: 'slider',
|
||||||
|
);
|
||||||
plPlayerController.play();
|
plPlayerController.play();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
: const SizedBox.shrink(),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
),
|
: const SizedBox.shrink(),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ import 'dart:async';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class BackwardSeekIndicator extends StatefulWidget {
|
class BackwardSeekIndicator extends StatefulWidget {
|
||||||
final void Function(Duration) onChanged;
|
// final void Function(Duration) onChanged;
|
||||||
final void Function(Duration) onSubmitted;
|
final void Function(Duration) onSubmitted;
|
||||||
const BackwardSeekIndicator({
|
const BackwardSeekIndicator({
|
||||||
super.key,
|
super.key,
|
||||||
required this.onChanged,
|
// required this.onChanged,
|
||||||
required this.onSubmitted,
|
required this.onSubmitted,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -28,18 +28,24 @@ class BackwardSeekIndicatorState extends State<BackwardSeekIndicator> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void increment() {
|
@override
|
||||||
|
void dispose() {
|
||||||
timer?.cancel();
|
timer?.cancel();
|
||||||
timer = Timer(const Duration(milliseconds: 400), () {
|
super.dispose();
|
||||||
widget.onSubmitted.call(value);
|
|
||||||
});
|
|
||||||
widget.onChanged.call(value);
|
|
||||||
// 重复点击 快退秒数累加10
|
|
||||||
setState(() {
|
|
||||||
value += const Duration(seconds: 10);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// void increment() {
|
||||||
|
// timer?.cancel();
|
||||||
|
// timer = Timer(const Duration(milliseconds: 400), () {
|
||||||
|
// widget.onSubmitted.call(value);
|
||||||
|
// });
|
||||||
|
// widget.onChanged.call(value);
|
||||||
|
// // 重复点击 快退秒数累加10
|
||||||
|
// setState(() {
|
||||||
|
// value += const Duration(seconds: 10);
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
@@ -53,10 +59,10 @@ class BackwardSeekIndicatorState extends State<BackwardSeekIndicator> {
|
|||||||
end: Alignment.centerRight,
|
end: Alignment.centerRight,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: InkWell(
|
// child: InkWell(
|
||||||
splashColor: const Color(0x44767676),
|
// splashColor: const Color(0x44767676),
|
||||||
onTap: increment,
|
// onTap: increment,
|
||||||
child: Center(
|
alignment: Alignment.center,
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
@@ -77,8 +83,7 @@ class BackwardSeekIndicatorState extends State<BackwardSeekIndicator> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
// ),
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ import 'dart:async';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class ForwardSeekIndicator extends StatefulWidget {
|
class ForwardSeekIndicator extends StatefulWidget {
|
||||||
final void Function(Duration) onChanged;
|
// final void Function(Duration) onChanged;
|
||||||
final void Function(Duration) onSubmitted;
|
final void Function(Duration) onSubmitted;
|
||||||
const ForwardSeekIndicator({
|
const ForwardSeekIndicator({
|
||||||
super.key,
|
super.key,
|
||||||
required this.onChanged,
|
// required this.onChanged,
|
||||||
required this.onSubmitted,
|
required this.onSubmitted,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -28,18 +28,24 @@ class ForwardSeekIndicatorState extends State<ForwardSeekIndicator> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void increment() {
|
@override
|
||||||
|
void dispose() {
|
||||||
timer?.cancel();
|
timer?.cancel();
|
||||||
timer = Timer(const Duration(milliseconds: 400), () {
|
super.dispose();
|
||||||
widget.onSubmitted.call(value);
|
|
||||||
});
|
|
||||||
widget.onChanged.call(value);
|
|
||||||
// 重复点击 快进秒数累加10
|
|
||||||
setState(() {
|
|
||||||
value += const Duration(seconds: 10);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// void increment() {
|
||||||
|
// timer?.cancel();
|
||||||
|
// timer = Timer(const Duration(milliseconds: 400), () {
|
||||||
|
// widget.onSubmitted.call(value);
|
||||||
|
// });
|
||||||
|
// widget.onChanged.call(value);
|
||||||
|
// // 重复点击 快进秒数累加10
|
||||||
|
// setState(() {
|
||||||
|
// value += const Duration(seconds: 10);
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
@@ -53,10 +59,10 @@ class ForwardSeekIndicatorState extends State<ForwardSeekIndicator> {
|
|||||||
end: Alignment.centerRight,
|
end: Alignment.centerRight,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: InkWell(
|
// child: InkWell(
|
||||||
splashColor: const Color(0x44767676),
|
// splashColor: const Color(0x44767676),
|
||||||
onTap: increment,
|
// onTap: increment,
|
||||||
child: Center(
|
alignment: Alignment.center,
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
@@ -77,8 +83,7 @@ class ForwardSeekIndicatorState extends State<ForwardSeekIndicator> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
// ),
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user