chudongvip / awesome_video_player

This is a flutter package of video player. it's a very simple and easy to use.
MIT License
196 stars 36 forks source link

Please support error handling #48

Open alr2413 opened 4 years ago

alr2413 commented 4 years ago

Hello,

Is it possible to add the error handling mechanism if video player failed to load source? Currently, It'll stay in loading state forever. I read your code & found that maybe you can define a new variable "errorCatched" like initialized variable, and set its value in your listener method like below:

if (!mounted) {
      return;
}
if (controller != null) {
      if (controller.value.initialized) {
        ...
      }
      else if (controller.value.hasError) {
        setState(() {
          errorCatched = true;
        });
      }
}

And then use this value to change the loading state & notify the parent widget. Please let me know if I'm wrong. Thanks.