简体   繁体   中英

Resuming iPod Playback after calling AVAudioSession setActive:NO

What's the best way to resume playback of the ipod or other audio sessions after your app has completed using its session?

NOTE I've already tried calling...

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

I'm building an iOS VoIP app which uses AVAudioSessionCategoryPlayAndRecord as its category and kAudioSessionMode_VoiceChat as its mode. To simplify handling of audio session management, I've got a singleton which listens for notifications on application state and other important events. However, the above code does not seem to cause the music to resume on the iPod app.

Finally, we've also noticed that the music controls that are shown on the bottom of the screen when the home button is double tapped act as if our application is the one playing audio. Yet we've already set it to be inactive.

Would love to understand more about what's going on here if anyone has any clue.

I seems to me that you are unable to notify the iOS that you no longer require an audio session. Are you sure that the call to "setActive" doesn't fail? Or maybe somewhere else in the code you reactivate your session.

Other than that, the Music application should be able to re-gain it's audio as soon as the system realizes you are not using it. This can be accomplished by third-party applications using the AVAudioSessionInterruptionNotification notification. For debugging you might try adding yourself as observer and see if your callback gets called. So, if you successfully deactivate your session, other applications should be able to do the rest.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM