Resuming iPod playback after calling AVAudioSession setActive: NO

What is the best way to resume playing your iPod or other audio after your application is terminated with its session?

NOTE. I already tried calling ...

[_session setActive:NO withFlags:AVAudioSessionSetActiveFlags_NotifyOthersOnDeactivation error:outError]; 

I am creating an iOS application for VoIP that uses AVAudioSessionCategoryPlayAndRecord as its category and kAudioSessionMode_VoiceChat as its mode. To simplify the handling of audio session management, I have a singleton that listens for notifications about application status and other important events. However, the code above does not seem to cause music to resume in the iPod app.

Finally, we also noticed that the musical controls that appear at the bottom of the screen when you double-click the home button act as if our application is one of the audio being played. However, we have already established that it is inactive.

I would like to know more about what is happening here if anyone has any kind of clue.

+4
source share
1 answer

It seems to me that you cannot notify iOS that you no longer need an audio session. Are you sure the setActive call did not end? Or maybe in another place in the code you are activating your session.

In addition, the Music application should be able to re-receive its audio as soon as the system realizes that you are not using it. This can be done by third-party applications using the AVAudioSessionInterruptionNotification notification. For debugging, you can try adding yourself as an observer and see if your callback is called. So, if you successfully deactivate the session, other applications should be able to do the rest.

0
source

All Articles