如何适应播放视频

发布于 2025-01-23 13:40:26 字数 595 浏览 1 评论 0原文

我试图用视频制作一个容器,但是当然不能将完整视频放在尺寸容器中,我尝试适合,但甚至有错误,所以我尝试使用剪辑,这里是谁想要的解决方案:

如果有一个。使用合适盖的方式,有人???

带夹子的代码在这里:它可以正常工作:

ClipRect(
        clipBehavior: Clip.hardEdge,
        child: Container(
          width: double.infinity, \\ another size
          height: 400, \\another size
          alignment: Alignment.center,
          child: Transform.scale( scale: 2,
            child: AspectRatio( aspectRatio: _controller!.value.aspectRatio,
                child: VideoPlayer(_controller as VideoPlayerController)
            ),
          ),
        ),
      ),

i trying to make a container with a video but of course its not possible to put full video in a dimension container, i try with fit, but even have errors, so i try with clip, here the solution for who wants:

if have a way using fit cover, someone???

the code with clip it here: and it works fine:

ClipRect(
        clipBehavior: Clip.hardEdge,
        child: Container(
          width: double.infinity, \\ another size
          height: 400, \\another size
          alignment: Alignment.center,
          child: Transform.scale( scale: 2,
            child: AspectRatio( aspectRatio: _controller!.value.aspectRatio,
                child: VideoPlayer(_controller as VideoPlayerController)
            ),
          ),
        ),
      ),

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

通知家属抬走 2025-01-30 13:40:26

尝试,为我工作

SizedBox.expand(
  child: FittedBox(
    alignment: Alignment.center,
    fit: BoxFit.cover,
    child: SizedBox(
      height: _controller.value.size.height,
      width: _controller.value.size.width,
      child: VideoPlayer(
        _controller,
      ),
    ),
  ),
),

try it, worked for me

SizedBox.expand(
  child: FittedBox(
    alignment: Alignment.center,
    fit: BoxFit.cover,
    child: SizedBox(
      height: _controller.value.size.height,
      width: _controller.value.size.width,
      child: VideoPlayer(
        _controller,
      ),
    ),
  ),
),
猥琐帝 2025-01-30 13:40:26

使用fittedbox窗口小部件,您可以调整任何子小部件大小以适合容器内:

Container(
  width: 500,
  height: 300,
  child: FittedBox(
    fit: BoxFit.cover,
    child: AspectRatio( 
      aspectRatio: _controller!.value.aspectRatio,
      child: VideoPlayer(_controller as VideoPlayerController),
    ),
  ),
),

Using a FittedBox widget you can resize any child widget to fit inside the container:

Container(
  width: 500,
  height: 300,
  child: FittedBox(
    fit: BoxFit.cover,
    child: AspectRatio( 
      aspectRatio: _controller!.value.aspectRatio,
      child: VideoPlayer(_controller as VideoPlayerController),
    ),
  ),
),
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文