Hi everyone,
I’m building a music player app using ExoPlayer combined with a custom MediaNotification extension.
Problem:
When the app reloads (like reopening the screen or app regaining focus), and a song is already playing in the background, pressing a new play button causes overlapping audio — instead of pausing the previous one.
What I’ve Tried:
-
Using a
CallbackMusicPlayer
block to handle:"Play"
→ resumes ExoPlayer"Pause"
→ pauses ExoPlayer"Next"
,"Previous"
, etc.
-
Created a custom procedure:
This allows me to simulate notification actions using logic, not taps.
Tried using
TinyDB
to save playback state and song info
When I tap the Pause button on the notification manually, it works perfectly (pauses all sounds, even if overlapping).
What I Need:
How can I auto-pause any ongoing background playback (from my own app’s ExoPlayer) when:
- The screen initializes again
- Or before a new song starts playing
Bonus: Is there a way to detect and control the currently playing instance without relying only on manual notification actions?
Any help or ideas would be greatly appreciated