Closed flackbash closed 5 years ago
Cool, thanks! I'll look at the changes this week!
Sorry it took me so long to look into this, i've moved twice since my last comment and things have been a bit hectic, but i looked into the issues you mentioned and it does seem to be much better this way, thank you for taking the time to put this PR together!
Previously, the app crashed when it lost audio focus because another app requested the focus. This was because upon audio focus loss, mediaPlayer was set to null and was not initialized again when regaining focus and resuming playback. Now mediaPlayer is being initialized in loadSentences() if it is null.
Because the app started playing automatically when another app had the audio focus and the power button was pressed to activate the lock screen (this lead to onResume() being called), I removed startSession() from connectToService() and instead call it separately in onCreateView().
Also, the app now requests audio focus every time when resuming playback. This prevents other apps from continuing to play audio when Natibo starts playing.