Henrique Ramalho
Henrique Ramalho

Reputation: 21

VideoPlayer loses reference when the app stays in the background for a long time

Steps to reproduce 1st step: Initialize the videoController with a file using VideoPlayerController.file().

2nd step: Check if the video has loaded.

3rd step: Leave the app in the background for 3-5 minutes.

4th step: Return to the app, and the video loses its reference.

Expected results When returning to the app, the videoController loses the reference to the video it was pointing to

I don't know why the video loses its reference; this causes an error in the app that I can't handle

late VideoPlayerController videoPlayerController;

  @override
  void initState() {
    File file = File(
        '/data/user/0/path/cache/442decbe-9c29-4e0c-86ef-7e4159d864d7/1000042017.mp4');
    videoPlayerController = VideoPlayerController.file(file,);
    videoPlayerController.initialize();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        height: double.maxFinite,
        width: double.maxFinite,
        color: Colors.blue,
        child: VideoPlayer(videoPlayerController),
      ),
    );

.

Upvotes: 0

Views: 31

Answers (0)

Related Questions