januwA / flutter_video_box

flutter_video_box
MIT License
22 stars 12 forks source link

how to handle error screens #32

Closed gamestap99 closed 4 years ago

gamestap99 commented 4 years ago

First, thank you for read question of me. Second, i want to handle error when video build error.

januwA commented 4 years ago

Catch initialization errors:

  bool loadingError = false;

  @override
  void initState() {
    super.initState();
    init();
  }

  void init() async {
    vc = VideoController(
        source: VideoPlayerController.network('https://example/videos/a.mp4'));
    try {
      await vc.initialize();
    } catch (e) {
      print('initialize error: '+ e.message);
      setState(() {
        loadingError = true;
      });
    }
  }

Handling errors:

AspectRatio(
  aspectRatio: 16 / 9,
  child: loadingError ? Placeholder() : VideoBox(controller: vc),
 ),

Now it can only capture the initial errors of the video, and it is difficult to handle other errors during playback @gamestap99

gamestap99 commented 4 years ago

@januwA i have a problem . I posted a new issue. please, read it