Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A VideoPlayerController was used after being disposed. Once you have called dispose() on a VideoPlayerController, it can no longer be used

Tags:

flutter

dart

screenshot

I am using chewie player to play a list of videos in pageview.builder. when i scroll my page below it works fine,but when i scroll my page to view top video it shows me this error.How can i re-initialize the videoplayercontroller.

like image 898
Azhar Mughal Avatar asked Dec 26 '19 10:12

Azhar Mughal


1 Answers

problem is you have to destroy the container that is using the video player and setting .dipose() after its destroyed. So your kill function should be something like this:

void killVidPlayer() {
    yourContainer = Container();
    setState(() {

    });

    _controller.dispose();
    _controller = null;
}
like image 185
Adrian M Cavazos Avatar answered Nov 14 '22 06:11

Adrian M Cavazos