【问题标题】:How to get aspect ratio of the video in Flutter如何在 Flutter 中获取视频的纵横比
【发布时间】:2021-02-23 03:28:04
【问题描述】:

我正在使用Better_Player 来显示视频,但我没有得到视频的纵横比,所以我该怎么做。如果有人拥有它,如果你分享会很棒。

【问题讨论】:

    标签: flutter dart video media-player


    【解决方案1】:

    你的意思是,你没有得到纵横比?

    可以给BetterPlayer属性aspectRatio。

    BetterPlayer.network(
        "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4",
         betterPlayerConfiguration: BetterPlayerConfiguration(
            **aspectRatio**: 16 / 9,
         ),
      ),
    

    Like this 如果这不起作用,您可以简单地尝试将播放器包装在 AspectRatio Widget 中,如文档示例:

    AspectRatio(
        **aspectRatio**: 10 / 9,
        child: BetterPlayer.network(
              "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4",
               ),
      ),
    

    Or like this

    还是我没看懂问题?

    【讨论】:

    • 我不想要静态的。它应该基于视频纵横比。假设我的视频是纵向的,那么它应该是合适的纵横比。
    • 它应该是动态的,具体取决于视频。否则视频会延长。我试过:用 aspectRatio 包装:_betterPlayerController.getAspectRatio() 但出现错误。
    【解决方案2】:

    我遇到了同样的问题并使用了 BoxFit.scaleDown,它对我有用。

    BetterPlayerConfiguration( 适合:BoxFit.scaleDown,)

    【讨论】:

      猜你喜欢
      • 2020-06-02
      • 1970-01-01
      • 2018-01-26
      • 2019-02-08
      • 1970-01-01
      • 2020-04-10
      • 2022-12-03
      • 2013-02-01
      • 1970-01-01
      相关资源
      最近更新 更多