Because your app does not mix with others, its audio session is being interrupted by whatever music app is starting up. You can detect when this has happened by listening for the kAudioSessionProperty_Interruption property (but I strongly urge you switch to using AVAudioSession because it is the API we actively support going forward). However, once this happens, given the un-mixability of your app, it is the user's responsibility to choose to restart your app, not yours. Imagine two music apps -- you start app A, then start app B -- you don't want A to say "hey, I was stopped -- I am going to restart myself now!". If you detect that you have been interrupted, and the user requests a restart, you will need to set your audio session active first. There are some talks from the last few WWDC's which address audio session issues.
-DS On Jun 26, 2013, at 12:09 PM, Beinan Li < email@hidden> wrote: Hello CoreAudio,
My app needs to handle a remote-control case: - My app uses kAudioSessionCategory_PlayAndRecord or kAudioSessionCategory_AmbientSound category and needs to mute other apps (kAudioSessionProperty_OverrideCategoryMixWithOthers set to FALSE)
- If another app, e.g., built-in music player, is playing audio before my app starts, their audio gets muted when my app starts.
- When user tries to control their other audio apps (e.g., the music player), they can do so by using the remote-control either through double-clicking home button then swiping to the transport, or by the earbud control.
Here is my problem, it seems that my app lost audio when user pauses/resumes their music app and it's not clear why and I have no way to bring back my app's audio.
I first tried to register callbacks to listen to the properties kAudioSessionProperty_AudioRouteChange and kAudioSessionProperty_OtherAudioIsPlaying, the first one is not always triggered and the second one simply cannot be registered with a listener (which in itself was surprising because I thought all AudioSession properties are listenable).
Then I tried to handle Remote-Control Event in my app, and then pass the message to the nextResponder. This worked to the point that my app did not lose audio at all but the music player stopped receiving the remote-control events so it beats the purpose.
I wonder what would be the right way to define and detect such a scenario and safely control both my app and the other apps without losing audio from any one?
Thanks a lot!
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
|