Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First video freezes due to race condition with loading of first videos #14

Open
luistrivelatto opened this issue Feb 3, 2022 · 0 comments

Comments

@luistrivelatto
Copy link

I noticed that sometimes when running the app, the first video froze after a few frames and the audio from the 2nd video started playing. After analyzing, it seems to be due to a race condition on initState of _FeedScreenState:

  void initState() {
    feedViewModel.loadVideo(0);
    feedViewModel.loadVideo(1);

    super.initState();
  }
  void loadVideo(int index) async {
    if (videoSource!.listVideos.length > index) {
      await videoSource!.listVideos[index].loadController();
      videoSource!.listVideos[index].controller?.play();
      notifyListeners();
    }
  }

Both videos are loaded asynchronously, and after loading the video starts to get played. If the 1st video gets loaded before the 2nd, then when the 2nd finishes loading we call controller.play() which starts playing the audio from the 2nd video.

@luistrivelatto luistrivelatto changed the title Race condition with loading of first videos First video freezes due to race condition with loading of first videos Feb 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant