Search code examples
iphoneobjective-cioscore-audioaudiounit

iPhone: How to play a sound on top of the iPod sound?


I'm trying to play a sound on top of the iPod music but when I enter my app the iPod sound is silenced automatically. I tried:

UInt32 sessionCategory = kAudioSessionCategory_AmbientSound; 
        AudioSessionSetProperty (kAudioSessionProperty_AudioCategory,                                 
                                 sizeof (sessionCategory),
                                 &sessionCategory                                 
                                 );

But probably because I use RemoteIO/Audio Units to play my sound this has no effect (not sure if that's the cause, but it sure thing does nothing ... the sound still stops)

I am missing something?


Solution

  • AudioSessionSetProperty returns an error, are you checking it?

    You may have forgotten to call AudioSessionInitialize, something you don't need to do with the AVFoundation wrapper.