I'm writing a wrapper around ExoPlayer as a custom view. The goal is to create a very simple abstraction for our streams and ad logic so that we can distribute a JAR file to clients and they can drag-and-drop a "BFPlayer" into their custom apps, hand it an ID referencing one of our broadcasts, and everything will play like magic.
As ExoPlayer needs to be released whenever an activity is paused or stopped, if possible I would like to do this automatically. I would like to detect when the parent activity is paused, release ExoPlayer, then detect when it's unpaused and spin up a new ExoPlayer silently and resume the previous state.
I found this StackOverflow post, describing how to get the hosting Activity from a View, however once I have the activity I don't know of a way to register a function to run automatically when the activity is paused.