PlaybackStatsListener callback is not called if the playback is paused and the app is killed.
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
- Play any content (audio in my case) for a while, let's say for 30 seconds.
- Pause the content
- Kill the app
- 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
I realized that exoplayer.stop(true) was being called in the onTaskRemoved() of the music service, which was resetting the player.
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.
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.
Issue was fixed by the commit above.