Issue
This Content is from Stack Overflow. Question asked by Rajat Jain
I am using video_player with GetX. And as you can see in official example, to get and set first frame of video as thumbnail, you have to use empty setState.
@override
void initState() {
super.initState();
_controller = VideoPlayerController.network(
'https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4')
..initialize().then((_) {
// Ensure the first frame is shown after the video is initialized,
// even before the play button has been pressed.
setState(() {});
});
}
Now I am not able to understand even that how to figure out below code using GetX. (i.e. how do I get first frame using GetX and set it on video player as thumbnail.)
// Ensure the first frame is shown after the video is initialized,
// even before the play button has been pressed.
setState(() {});
Any help is much appreciated.
Solution
actually the comment is pretty clear
Ensure the first frame is shown after the video is initialized,
even before the play button has been pressed.
the purpose of the empty setState
executed after video initialize is to rebuild ui once. so first frame of your video shown in the ui.
This Question was asked in StackOverflow by BlazingR and Answered by Sayyid J It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.