0

I am unable to figure this out. I have scenario, I am getting the video data in background via viewModel, coroutine and result in LiveData. The call to viewModel happens in onViewCreated of fragment. And in onResume I initialise ExoPlayer.

Now if I get the livedata result before onResume has completed and call play() by passing the videoUrl it would fail as ExoPlayer is not initialised yet.

How do I sync up this ?

  • 1
    You could try two things: a) init ExoPlayer instance after receive data, b) invoke ViewModel after init ExoPlayer. – Jose Angel Maneiro Apr 12 '21 at 07:57
  • @JoseAngelManeiro, Thanks Jose. Thought of the same, was just wondering if there is any better standard way to this, as it is a common problem. But ya get the point will use one of those. –  Apr 12 '21 at 09:11

0 Answers0