如何在Flutter中获得视频的长宽比

问题描述

我正在使用Better_Player显示视频,但是我没有获得视频的长宽比,所以我该怎么做。如果有人分享,那就太好了。

解决方法

什么意思,您没有获得长宽比?

您可以赋予AspectRatio的BetterPlayer属性。

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

还是我不明白这个问题对吗?

,

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

BetterPlayerConfiguration( 适合:BoxFit.scaleDown,)