我正在使用image_picker录制视频。我想在20秒后停止录制。有什么办法可以在20秒后停止录制。
_pickVideoFromCamera() async {
File video = await ImagePicker.pickVideo(source: ImageSource.camera);
_cameraVideo = video;
_cameraVideoPlayerController = VideoPlayerController.file(_cameraVideo)
..initialize().then((_) {
_cameraVideoPlayerController.play();
setState(() {});
});
}
答案 0 :(得分:0)
您可以使用Future.delayed
_pickVideoFromCamera() async {
File video = await ImagePicker.pickVideo(source: ImageSource.camera);
_cameraVideo = video;
_cameraVideoPlayerController = VideoPlayerController.file(_cameraVideo)
..initialize().then((_) {
_cameraVideoPlayerController.play();
setState(() {});
});
Future.delayed(Duration(seconds: 20)).then((_) { // camera stop process });
}