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);
}