Am working in Messaging based iPhone app. I have added Beep sound to receive message from someone else. I am playing beep sound using AVAudioPlayer. My problem
You cannot do this for all applications. For applications that use the iPod player in their applications:
Assuming your application is in foreground. You can do this:
MPMusicPlayerController *mp = [MPMusicPlayerController iPodMusicPlayer];
[mp stop]; // or [mp pause]
This needs the MediaPlayer.framework and also #import .
Read more at MPMusicPlayerController Reference.
For doing it through Audio Player Sessions you can use the property kAudioSessionCategory_SoloAmbientSound. Reference here.
This is similar to AVAudioSessionCategorySoloAmbient defined in AVAudioSession class.
Quoting from the documentation:
When you use this category, audio from other apps is silenced.