fix: 修复播放器重复暂停手势
This commit is contained in:
1 parent
76c4b528d3
commit
5794dd4e4d
5 files changed
+52
-32
No files matched your search
@@ -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,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user