如何:默认显示 video_player 插件的播放控件 (flutter-web)

How to: show playback controls by default for video_player plugin (flutter-web)

有什么方法可以默认显示视频播放器的控件吗?如果我在浏览器中右键单击视频,我就可以显示它们,所以我假设必须有一种默认显示方式..

我想不出一种方法来默认显示 video_player 控件,而是使用了这个包,它适用于 Flutter-web:https://pub.dev/packages/chewie

我很确定您还需要默认的 video_player 包...

这是一个例子:

import 'package:chewie/chewie.dart';
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';

class ChewieVideo extends StatefulWidget {
  // This will contain the URL/asset path which we want to play
  final VideoPlayerController videoPlayerController;
  final bool looping;

  ChewieVideo({
    @required this.videoPlayerController,
    this.looping,
    Key key,
  }) : super(key: key);

  @override
  _ChewieVideoState createState() => _ChewieVideoState();
}

class _ChewieVideoState extends State<ChewieVideo> {
  ChewieController _chewieController;

  @override
  void initState() {
    super.initState();
    // Wrapper on top of the videoPlayerController

    _chewieController = ChewieController(
      videoPlayerController: widget.videoPlayerController,

      // Prepare the video to be played and display the first frame
      autoInitialize: true,
      allowFullScreen: false,
      aspectRatio: 16 / 9,
      looping: widget.looping,
      autoPlay: false,
      showControlsOnInitialize: false,
      // Errors can occur for example when trying to play a video
      // from a non-existent URL
      errorBuilder: (context, errorMessage) {
        return Center(
          child: Text(
            errorMessage,
            style: TextStyle(color: Colors.white),
          ),
        );
      },
    );
  }

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.all(8.0),
      child: Chewie(
        controller: _chewieController,
      ),
    );
  }

  @override
  void dispose() {
    widget.videoPlayerController.dispose();
    _chewieController.dispose();
    super.dispose();
  }
}