gpt4 book ai didi

Flutter 闪屏视频播放器

转载 作者:行者123 更新时间:2023-12-04 12:59:07 25 4
gpt4 key购买 nike

I am trying to create a background video splash screen for my app. Currently, I am achieving a blank screen by running this code.


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

I suspect the problem may be here and have based my research off this Full screen video background in Flutter on Login as I am trying to achieve a similar result.


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

最佳答案

我认为视频播放器包在 Ios 模拟器中显示视频有问题。我遇到了同样的问题并搜索它并找到了这个 issue in Github .直到现在这个问题是开放的。我在真实设备上测试了视频播放器,没有任何问题。

关于Flutter 闪屏视频播放器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61577492/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com