繁体   English   中英

Flutter:CircularProgressIndicator() 在视频缓冲时不起作用

[英]Flutter: CircularProgressIndicator() not working when the video is buffering

我是 Flutter 和 Dart 的新手。 我的目标是制作具有播放、暂停、重放和缓冲功能的视频。 我现在的问题是我调用了 CircularProgressIndicator() 但它不起作用。

这就是我所做的:

final bool isBuffering = false; 

这是我调用 CircularProgressIndicator 的地方

Widget _buildPlayStack() {
    return Stack(
      children: [
        _buildPlay(),
          child: FlatButton(
            onPressed: () => setState(() {
               _vidController.value.isPlaying ? _vidController.pause() :_vidController.play();           
            }),
            child: Center(
              child: (_vidController.value.isPlaying)
                      ? Icon(Icons.pause, color: Colors.green)
                      : Icon(Icons.play_arrow, color: Colors.green),
            ),
          ),
        Center(
            child: _vidController.value.isBuffering
                ? const CircularProgressIndicator()
                : null),
      ],
    );
  }

Widget _buildPlay() {
    return Container(
      child: AspectRatio(
          aspectRatio: _vidController.value.aspectRatio,
          child: VideoPlayer(_controller),
        ),
    );
  }

您必须传入一些value: ,例如:

child: showProgress
          ? CircularProgressIndicator(value:progress)
          : Text('Click on Refreseh button

你必须使用 setState 更新进度

对于您的情况,flutter 有专门为您准备的文档。 播放和暂停视频

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM