The app never requested audio focus, so it played over other apps and
ignored phone calls, music players, etc. Now requests AUDIOFOCUS_GAIN
before playback and handles LOSS (stop), LOSS_TRANSIENT (mute),
LOSS_TRANSIENT_CAN_DUCK (lower volume to 20%), and GAIN (restore).
Also fixes several service lifecycle issues:
- Add stopForeground(STOP_FOREGROUND_REMOVE) in cleanupResources so
the notification is dismissed when playback ends
- Add onTaskRemoved override to stop playback when the app is swiped
from recents (unless stayConnected is enabled)
- Fix wake lock leak by calling releaseLocks() before acquireLocks()
to prevent accumulating unreleased locks across pause/resume cycles
- Add AudioEngine.setVolume() for ducking support
Made-with: Cursor