You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter中BetterPlayer滚动时停止播放的问题求助

BetterPlayer滚动时视频停止播放问题

我曾见过一个类似问题《Better Player滚动时反复重启》,但该问题的解决方案对我无效。

我的页面结构如下:

@override
Widget build(BuildContext context) {
    return Scaffold(
      appBar: appBar(),
      body: SafeArea(
        child: SingleChildScrollView(
          child: Column(
            children: [
              header(),
              body(),
            ],
          ),
        ),
      ),
    );
}

其中header()组件包含视频,body()组件是较长的文本内容。现在的问题是:向下滚动页面时,视频会停止播放,这不是我想要的效果。我也尝试过用ListView替代SingleChildScrollView,但问题依然存在。

视频加载的代码如下:

Widget header() 
{
    BetterPlayerDataSource betterPlayerDataSource = BetterPlayerDataSource(
      BetterPlayerDataSourceType.NETWORK,
      widget.banner.file.url,
    );
    betterPlayerController = new BetterPlayerController(
      BetterPlayerConfiguration(
        autoPlay: true,
        fit: BoxFit.cover,
        controlsConfiguration: BetterPlayerControlsConfiguration(
          enableOverflowMenu: false,
          enableSkips: false,
        ),
        autoDispose: false,
      ),
      betterPlayerDataSource: betterPlayerDataSource,
    );

    return Hero(
      tag: 'banner-' + widget.banner.id.toString(),
      child: Container(
        width: double.infinity,
        height: 300,
        padding: EdgeInsets.only(bottom: 15),
        child: AspectRatio(
          aspectRatio: 4 / 3,
          child: BetterPlayer(
            controller: betterPlayerController,
          ),
        ),
      ),
    );
}

内容的提问来源于stack exchange,提问作者Linesofcode

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.20 07:24:26