image_picker + video_player 显示角度不正确的视频和拉伸的视频

问题描述 投票:0回答:1

在 Flutter 应用程序中,我尝试选择视频并显示它。我的视频显示。但他们的轮换不正确。如果我的视频是垂直模式下的录制器,则视频显示在垂直视频容器中,但视频会旋转并显示为垂直模式并在宽度上拉伸。 (垂直尺寸变成水平尺寸,反之亦然,所以我的视频比应有的更宽,但比他的身高短)

Future<void> _pickVideo() async {
final XFile? video = await _picker.pickVideo(source: ImageSource.gallery);

if (video != null){
  _videoFile = File(video!.path);
  _videoController = VideoPlayerController.file(_videoFile!)..initialize().then((_) {
    setState(() {

    });
    _videoController?.play();
  });
}

}

    @override
      Widget build(BuildContext context) {
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.stretch,
        children: [
          ElevatedButton(
            onPressed: _pickVideo,
            child: const Text('Choose Video'),
          ),
          const SizedBox(height: 20),
          if (_videoFile != null)
            _videoController!.value.isInitialized ? AspectRatio(
                aspectRatio: _videoController!.value.aspectRatio,
              child: VideoPlayer(_videoController!),
            ) : Container()
          else
            const Text("Click on pick video to selecte video"),

...

我尝试旋转

    child: Transform.rotate(
       angle: 3.14159 / 2,
       child: VideoPlayer(_videoController!),
     ),

但它也旋转水平模式(这不好),对于垂直模式,它旋转它但图像变成正方形。下方和上方的其他地方占据空白背景

android flutter flutter-video-player flutter-image-picker
1个回答
0
投票

我有同样的问题。你解决了吗?

© www.soinside.com 2019 - 2024. All rights reserved.