初始化后播放flutter video_player会延迟播放
我正在使用Flutter Video_player在循环中显示视频。只要视频播放器尚未初始化,我会显示一个加载指示器。问题在于,调用了初始化()。然后调用(),视频仍需要大约3-5秒钟,直到播放视频。
另一个问题是我想循环播放视频。我以这样的方式剪切了视频,以至于无法在循环中看到过渡。问题是Video_player即将停止视频,然后重新启动视频。
有人知道我是否可以做出任何改进来获得所需的结果?
这是我的代码:
void initVideo() {
setState(() {
isLoading = true;
});
_controller = VideoPlayerController.network(
videoUrl,
);
_controller!.addListener(() {
setState(() {});
});
_controller!.initialize().then((_) async {
setState(() {
_controller!.play();
isLoading = false;
});
});
_controller!.setLooping(true);
_controller!.setVolume(0.0);
}
I'm using the flutter video_player to display videos in a loop. I show a loading indicator as long as the video player is not initialized yet. The problem is that after initialize().then() is called, the video still needs about 3 - 5 seconds until it plays the video.
Another problem is that I want to play the video in a loop. I cut the video in such a way that no transition can be seen in the loop. The problem is that the video_player shortly stops the video and then restarts it.
Does someone have an idea if I can make any improvements to get the desired result?
Here is my code:
void initVideo() {
setState(() {
isLoading = true;
});
_controller = VideoPlayerController.network(
videoUrl,
);
_controller!.addListener(() {
setState(() {});
});
_controller!.initialize().then((_) async {
setState(() {
_controller!.play();
isLoading = false;
});
});
_controller!.setLooping(true);
_controller!.setVolume(0.0);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论