Re: My Iphone audio player app gets interrupted by the iPod
Re: My Iphone audio player app gets interrupted by the iPod
- Subject: Re: My Iphone audio player app gets interrupted by the iPod
- From: Greg Chapman <email@hidden>
- Date: Wed, 14 Oct 2009 10:43:57 -0700
On Oct 14, 2009, at 10:22 AM, Roni Music wrote:
> Thanks for the fast reply!
>
>> There are 3 interlocking issues here.
>>
>> 1. You really want to get those play/pause commands from the headphones cable.
>> Currently there is no way to do that. I cannot comment on the content of future releases,
>> but you might imagine that this is causing pain internally (we are all iPhone users, too).
>> This happens to me when listening to podcasts in Safari: I hit the play/pause button on the headphones cable,
>> and iPod app starts up and interrupts Safari. <bleah>
>
> OK, then we hope for something in a future update of the OS ;-)
>
>>
>> 2. You should be getting an interruption callback "end interruption" when iPod app stops.
>> I'm surprised you aren't... what iPhone OS version are you running on?
>
> I just updated to OS 3.1.2 and I can confirm that my app never receives the kAudioSessionEndInterruption
> when one pauses the iPod player again.
That's bad, and unexpected. Can you file a bug please? I want to make sure this gets fixed.
>> 3. When the user touches your apps play button, you fail to play because you are not active.
>> This you can fix! If the user presses the play button in your app, calling AudioSessionSetActive(true) before
>> starting playback is a perfectly reasonable thing to do. It's OK to interrupt other apps' audio if the user asks you to,
> <even if you haven't received an "end interruption" callback. Even without the bug in (2) above, iPod app might still
>> be playing when the user hits the play button, so you legitimately might not have received the "end interruption" callback.
>
> OK, that was an easy fix, works fine.
> So one can call AudioSessionSetActive(true) before every playback call even though it's already active?
Yes you can, but please do not do it unless you are trying to play because the user asked you to. Otherwise this is considered "not playing nice with others". In your app, I think it is always the case that you only play if the user asks you to, but other apps might have different behaviours.
> Also, after a kAudioSessionEndInterruption, I also set the kAudioSessionCategory_xx plus AudioSessionSetActive(true)
> I think I do that after reading some docs long ago, is this needed?
We don't forget your category when you are interrupted, so this is not necessary. It would only be necessary if you really want to _change_ your category before becoming active again.
Greg
>>
>>
>> On Oct 14, 2009, at 7:58 AM, Roni Music wrote:
>>
>>>
>>> My iPhone audio player uses the kAudioSessionCategory_MediaPlayback category.
>>>
>>> When it's playing and a user presses the "play/pause button" on the headphones cable,
>>> my interruption listener callback gets called with a kAudioSessionBeginInterruption event,
>>> my player stops and the iPod player starts playing in the background.
>>>
>>> The user that presses the "play/pause button" on the headphones cable does this with the intention to play/pause my app and
>>> NOT the iPod player. He then presses the "play/pause button" on the headphones cable again to stop the iPod player
>>> but my application is never informed by the interruption listener callback about this and thus never calls AudioSessionSetActive(true)
>>> and it fails to start when the user presses the regular screen play button.
>>>
>>> So, when my app is running, how can I prevent the iPod player to start playing in the background
>>> or even better,
>>> is there a way to trap the presses on the headphones cables and in that way control my player?
>>>
>>> Thanks for any help,
>>> Rolf Nilsson
>>> _______________________________________________
>>> 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
>>
>> -------------- next part --------------
>> An HTML attachment was scrubbed...
>> URL: http://lists.apple.com/mailman/private/coreaudio-api/attachments/20091014/1fa5d22b/attachment.html
>>
>> ------------------------------
>>
>> _______________________________________________
>> Coreaudio-api mailing list
>> email@hidden
>> http://lists.apple.com/mailman/listinfo/coreaudio-api
>>
>> End of Coreaudio-api Digest, Vol 6, Issue 391
>> *********************************************
>
_______________________________________________
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