fix: 修复播放器重复暂停手势

This commit is contained in:
Zhou Weidong committed 2026-10-22 22:34:18 +08:00
1 parent 76c4b528d3
commit 5794dd4e4d
5 files changed
+52 -32

No files matched your search

@@ -27,14 +27,14 @@ class _PlayerDoubleTapHeartBurstState extends State<PlayerDoubleTapHeartBurst>
super.initState();
final random = Random();
var delay = 0;
_particles = List.generate(6 + random.nextInt(3), (index) {
_particles = List.generate(3 + random.nextInt(2), (index) {
if (index > 0) delay += 40 + random.nextInt(21);
return _HeartParticle(
delay: delay,
duration: 700 + random.nextInt(201),
travel: 120 + random.nextInt(41),
drift: -30 + random.nextInt(61),
size: (22 + random.nextInt(13)).toDouble(),
duration: 600 + random.nextInt(101),
travel: 90 + random.nextInt(31),
drift: -18 + random.nextInt(37),
size: (20 + random.nextInt(7)).toDouble(),
color: random.nextBool()
? AppColors.doubleTapHeartRed
: AppColors.doubleTapHeartPink,
@@ -17,13 +17,13 @@ class PlayerVideoSurface extends StatefulWidget {
required this.controller,
required this.videoUrl,
required this.theater,
required this.onTap,
this.onTap,
});
final VideoPlayerController? controller;
final String videoUrl;
final bool theater;
final VoidCallback onTap;
final VoidCallback? onTap;
@override
State<PlayerVideoSurface> createState() => _PlayerVideoSurfaceState();
@@ -147,21 +147,24 @@ class _VideoLayer extends StatelessWidget {
final VideoPlayerController controller;
final VideoPlayerValue value;
final bool theater;
final VoidCallback onTap;
final VoidCallback? onTap;
@override
Widget build(BuildContext context) {
final child = FittedBox(
fit: theater ? BoxFit.contain : BoxFit.cover,
child: SizedBox(
width: value.size.width,
height: value.size.height,
child: VideoPlayer(controller, key: ValueKey(controller)),
),
);
final tap = onTap;
if (tap == null) return child;
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: onTap,
child: FittedBox(
fit: theater ? BoxFit.contain : BoxFit.cover,
child: SizedBox(
width: value.size.width,
height: value.size.height,
child: VideoPlayer(controller, key: ValueKey(controller)),
),
),
onTap: tap,
child: child,
);
}
}