I have implemented a VoIP application and everything works fine. When a user is playing a music on his device using Android default music player or any other third party apps, and my app starts to ring or a message is received, my app's ringtone is not played and the music player is still playing and this situation keeps happening even in incall and call termination states.
How do I detect when a music player (default player for this stage) is playing a music and how to pause and resume it on my app's ringing and call termination states?