0

我创建了一个屏幕,我可以在其中使用按钮打开相机并拍摄视频。在那个按钮上方,我制作了一个容器来显示视频。但我想显示这个包含视频的容器以显示在下一页上。由于我是新来的,我相信我的代码很乱。你能帮我解决这个问题吗?

以及如何在屏幕上显示多个视频,然后像这里的图像一样循环通过这个相机?

颤动捕获后在同一屏幕上显示多个视频/图像

这是我的代码 -

 class video_record02 extends StatefulWidget {
      final Function? onSelectVideo;
    
      const video_record02({Key? key, this.onSelectVideo});
    
      @override
      _video_record02State createState() => _video_record02State();
    }
    
    class _video_record02State extends State<video_record02> {
      String dropdownValue = 'Bedroom';
    
      File? storedVideo;
    
      Future<void> _takeVideo() async {
        final picker = ImagePicker();
        final videoFile = await picker.pickVideo(
          source: ImageSource.camera,
          preferredCameraDevice: CameraDevice.rear,
          maxDuration: Duration(
            seconds: 25,
          ),
        );
        if (videoFile == null) {
          return;
        }
        final rlyvideoFile = File(videoFile.path);
        setState(() {
          storedVideo = rlyvideoFile;
        });
        final appDir = await syspaths.getApplicationDocumentsDirectory();
        final fileName = path.basename(rlyvideoFile.path);
        final savedVideo = await rlyvideoFile.copy('${appDir.path}/$fileName');
        widget.onSelectVideo?.call(savedVideo);
      }
    
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          home: Scaffold(
            backgroundColor: Colors.white,
            body: Center(
              child: ListView(
                shrinkWrap: true,
                children: [
                  Column(
                    children: [
                      Container(
                          width: 150,
                          height: 100,
                          decoration: BoxDecoration(
                            border: Border.all(
                              width: 0.5,
                              color: Colors.grey,
                            ),
                          ),
                          child: storedVideo != null 
? VideoWidget(storedVideo!)
                                  : Text(
                                      'No Video Taken',
                                      textAlign: TextAlign.center,
                                    ),
                              alignment: Alignment.center),
                          Align(
                            alignment: Alignment.center,
                            child: Column(
                              children: [
    IconButton(
                                  icon: Icon(Icons.play_circle_fill),
                                  color: Colors.red,
                                  iconSize: 100.0,
                                  onPressed: _takeVideo,
        ),
                              ],
                            ),
                          ),
                          Text(
                            'Click to start',
                            style: TextStyle(
                              fontSize: 25.0,
                              color: Colors.red,
                              fontWeight: FontWeight.w300,
                            ),
                          ),
                          Container(
                            margin: EdgeInsets.fromLTRB(125, 0, 125, 0),
                            height: 50,
                            padding: EdgeInsets.fromLTRB(0, 0, 0, 0),
                            child: TextButton(
                              child: Text(
                                '< Back',
                                style: TextStyle(fontSize: 17, color: Colors.black),
                              ),
                              onPressed: () {
                                Navigator.push(
                                  context,
                                  MaterialPageRoute(
                                      builder: (context) => video_record01()),
                                );
                              },
                            ),
                          ),
                        ],
                      ),
                    ],
                  ),
                ),
              ),
            );
          }
        }
4

0 回答 0