Flutter Splash Screen Video Player

问题描述 投票:0回答:1

我正在尝试为我的应用创建背景视频启动屏幕。目前,我通过运行此代码来实现黑屏。

 void main() => runApp(WalkThrough());

class WalkThrough extends StatefulWidget {
  @override
  _WalkThroughState createState() => _WalkThroughState();
}

class _WalkThroughState extends State<WalkThrough> {
  VideoPlayerController _controller;

  @override
  void initState() {
    super.initState();
    // Pointing the video controller to our local asset.
    _controller = VideoPlayerController.asset('assets/video.mp4')
      ..initialize().then((_) {
        // Once the video has been loaded we play the video and set looping to true.
        _controller.play();
        _controller.setLooping(true);
        _controller.setVolume(0.0);
        _controller.play();
        // Ensure the first frame is shown after the video is initialized.
        setState(() {});
      });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Stack(
        children: <Widget>[

[我怀疑问题可能在这里,并根据Full screen video background in Flutter on Login进行了研究,因为我试图获得类似的结果。

          SizedBox.expand(
            child: FittedBox(
              // If your background video doesn't look right, try changing the BoxFit property.
              // BoxFit.fill created the look I was going for.
              fit: BoxFit.fill,
              child: SizedBox(
                width: _controller.value.size?.width ?? 0,
                height: _controller.value.size?.height ?? 0,
                child: VideoPlayer(_controller),
              ),
            ),
          ),
flutter flutter-layout flutter-dependencies
1个回答
0
投票

我认为视频播放器包在Ios模拟器中显示视频时出现问题。我遇到了同样的问题,并进行搜索并找到了此问题issue in Github。到现在为止,此问题尚未解决。

© www.soinside.com 2019 - 2024. All rights reserved.