ExoPlayer icon indicating copy to clipboard operation
ExoPlayer copied to clipboard

PlaybackStatsListener callback is not called if the playback is paused and the app is killed.

Open VivekBhalodiyaMM opened this issue 5 years ago • 4 comments

I need to collect getTotalPlayTimeMs() from the PlaybackStatsListener.

Describe the bug PlaybackStatsListener callback is not called if the playback is paused and the app is killed.

To Reproduce

  1. Play any content (audio in my case) for a while, let's say for 30 seconds.
  2. Pause the content
  3. Kill the app
  4. PlaybackStatsListener callback is not called.

Expected I needgetTotalPlayTimeMs() from the PlaybackStats which should return 30 seconds in Ms.

ExoPlayer version number - 2.13.2 Android version - Any Android device - Any

VivekBhalodiyaMM avatar Mar 30 '21 06:03 VivekBhalodiyaMM

I realized that exoplayer.stop(true) was being called in the onTaskRemoved() of the music service, which was resetting the player.

VivekBhalodiyaMM avatar Mar 30 '21 07:03 VivekBhalodiyaMM

On updating the ExoPlayer to 2.13.2, the issue still persists. I was able to call finishAllSession() in 2.11.1 but now that method is not public.

VivekBhalodiyaMM avatar Mar 31 '21 05:03 VivekBhalodiyaMM

Kill the app

I'm not sure what this step means exactly in your case. If you close your app in a normal way, I'd assume you call player.release() at some point which also finishes all pending session in the PlaybackStatsListener.

I realized that exoplayer.stop(true) was being called.

This stop call is indeed not triggering the callback immediately (only when re-preparing the player with something else, or when the player is released). We can fix this, but not sure it is your original problem.

tonihei avatar Mar 31 '21 13:03 tonihei

Issue was fixed by the commit above.

tonihei avatar May 20 '21 10:05 tonihei