Flutter Spla sh Экран Видеоплеер - PullRequest
0 голосов
/ 03 мая 2020

Я пытаюсь создать фоновое видео spla sh для моего приложения. В настоящее время я получаю пустой экран с помощью этого кода.

 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>[

Я подозреваю, что проблема может быть здесь, и основал мое исследование на этом Полноэкранном видео-фоне в Flutter при входе в систему , поскольку я пытаюсь добиться аналогичный результат.

          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),
              ),
            ),
          ),

1 Ответ

1 голос
/ 04 мая 2020

Мне кажется, в пакете видеопроигрывателя есть проблема с отображением видео в симуляторе Ios. У меня возникла та же проблема, и я ее нашел и обнаружил эту проблему в Github . до сих пор этот вопрос открыт. Я тестировал видеоплеер на реальном устройстве и проблем не было.

...