I have an application that keeps a global instance of an ExoPlayer instance to facilitate audio streams in the background. After opening lots of apps, the audio stops playing.
It happens as follows:
- open
Activitythat starts playing audio - press back button to close
Activity - the audio is still playing and keeps doing so if you leave the device alone (as intended)
However, when you open a dozen or more apps after the last step, the ExoPlayer stops playing at some point. My guess is that a memory cleanup happens and thus ExoPlayer gets deallocated. I tried to get more information from the logs, but that has provided little help so far.
Keeping a reference of the ExoPlayer inside an android.app.Service doesn't make a difference.
The device I am testing on is a Nexus 5 with Android 5.1.x, but the issue happens on other devices too.
I couldn't find a solution in the ExoPlayer documentation pages nor on StackOverflow or Google. Does anyone know the correct way to prevent the ExoPlayer from stopping playback?
Service? - Ricardoandroid.app.Service. - Byte Welder