首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Chewie视频播放器

Chewie视频播放器
EN

Stack Overflow用户
提问于 2020-08-19 13:43:07
回答 1查看 1.6K关注 0票数 4

我正在使用带有定制控制栏的chewie播放器,当播放器切换到全屏时,我看不到控件。即使播放器全屏显示,我也需要显示控件。我没有使用由chewie提供的控件,因为我不希望进度搜索条可触摸,即我不希望用户倒带视频...

以下是代码:

代码语言:javascript
复制
@override
  void initState() {
    super.initState();

    _videoPlayerController1 = VideoPlayerController.network(widget.videoURL);

    _chewieController = ChewieController(
      videoPlayerController: _videoPlayerController1,
      //  aspectRatio: 3 / 2,
      autoPlay: false,
      looping: false,
      autoInitialize: true,
      showControls: true,
      fullScreenByDefault: false,
      //seekTo:value,
      startAt: Duration(milliseconds: widget.time),
      //customControls: customControl(),

      placeholder: Container(
        color: Colors.black87,
        child: Container(
          child: Center(
              child: CircularProgressIndicator(
            valueColor:
                new AlwaysStoppedAnimation<Color>(Colors.deepPurpleAccent),
          )),
        ),
      ),
    //  overlay:

      // autoInitialize: true,
    );

    setState(() {
      _loading = true;
    });

   

  }



@override
  Widget build(BuildContext context) {
    return WillPopScope(
      onWillPop: _onWillPop,
      child: SafeArea(
        child: MaterialApp(
          home: Scaffold(
            backgroundColor: Colors.black,
            body: Column(
              children: <Widget>[
                Expanded(
                  child: Center(
                    child: GestureDetector(
                      onDoubleTap: () {
                        _chewieController.enterFullScreen();
                      },
                      onTap: () {
                        if (_videoPlayerController1.value.isPlaying) {
                          setState(() {
                            _chewieController.pause();
                            isPlaying = false;
                          });
                        } else {
                          setState(() {
                            _chewieController.play();
                            isPlaying = true;
                          });
                        }
                      },
                      child: Chewie(
                        controller: _chewieController,
                      ),
                    ),
                  ),
                ),
                Row(
                  children: [
                    FlatButton(
                      onPressed: () {
                        if (_videoPlayerController1.value.isPlaying) {
                          setState(() {
                            _chewieController.pause();
                            isPlaying = false;
                          });
                        } else {
                          setState(() {
                            _chewieController.play();
                            isPlaying = true;
                          });
                        }
                      },
                      child: Icon(
                        !_videoPlayerController1.value.isPlaying
                            ? Icons.play_arrow
                            : Icons.pause,
                        color: Colors.white,
                        size: 30,
                      ),
                    ),
                    ValueListenableBuilder(
                      valueListenable: _videoPlayerController1,
                      builder: (context, VideoPlayerValue value, child) {
                        //Do Something with the value.
                        if (value.initialized && value.isPlaying) {
                          return new LinearPercentIndicator(
                            width: MediaQuery.of(context).size.width - 180,
                            lineHeight: 8.0,
                            percent: (value.position.inSeconds.toDouble() /
                                value.duration.inSeconds.toDouble()),

                            linearStrokeCap: LinearStrokeCap.roundAll,
                            backgroundColor: Colors.grey,
                            progressColor: Colors.amber,
                          );
                        } else {
                          return new LinearPercentIndicator(
                            width: MediaQuery.of(context).size.width - 180,
                            lineHeight: 8.0,
                            percent: 0.0,
                            linearStrokeCap: LinearStrokeCap.roundAll,
                            backgroundColor: Colors.grey,
                            progressColor: Colors.amber,
                          );
                        }
                      },
                      //child:
                    ),
                    FlatButton(
                      onPressed: () {
                        _chewieController.enterFullScreen();
                        setState(() {
                          isFullscreen = true;
                        });

                      },
                      child: Icon(
                        Icons.fullscreen,
                        color: Colors.white,
                        size: 30,
                      ),
                    ),
//
                  ],
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
EN

回答 1

Stack Overflow用户

发布于 2021-08-26 12:15:29

您可以使用以下命令控制颜色按钮

代码语言:javascript
复制
  materialProgressColors:ChewieProgressColors(backgroundColor: Colors.red,bufferedColor: Colors.red,

handleColor: Colors.blue,playedColor: Colors.orange),

添加到您的控制器

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63480693

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档