In an Android project developed with Jetpack Compose, I am using ExoPlayer to play music and simultaneously show a notification to the user that music is playing. However, the problem is that the music plays both from the notification and from the player I created, causing the music to play twice simultaneously. When I stop the music from the notification, it works correctly and only one sound plays. To completely stop the music, I have to stop both the notification and the music player simultaneously. I am using a service to play the music and have delegated handling the notification to ExoPlayer. How can I prevent this issue and ensure that the sound plays only once?
I am using Hilt for dependency injection and creating an ExoPlayer module in the DI section.
dexis team is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1