• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: No interruption events when pausing music using headphone controller
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: No interruption events when pausing music using headphone controller


  • Subject: Re: No interruption events when pausing music using headphone controller
  • From: Beinan Li <email@hidden>
  • Date: Wed, 29 May 2013 14:56:25 -0400

Thanks a lot Kevin.

I think you are right about the UIApplication/UIResponder part. I just read the same thing about remote control as you described in the book Learning CoreAudio: A Hands-on Guide to Audio Programming. There seems to be no other way.

Thanks,
Beinan


On Wed, May 29, 2013 at 2:04 PM, Kevin Dixon <email@hidden> wrote:
Hi Beinan,

Looking at the docs (http://developer.apple.com/library/ios/documentation/Audio/Conceptual/AudioSessionProgrammingGuide/Cookbook/Cookbook.html#//apple_ref/doc/uid/TP40007875-CH6-SW7) I guess both callbacks should behave the same. AVAudioSession is an Objective C wrapper for these APIs.

I don't believe there is any other way to handle the remote control because you have to access the APIs provided on the UIApplication class, but I'm not 100% sure there's not another way.
Best of luck,

-Kevin


On Wed, May 29, 2013 at 7:42 AM, Beinan Li <email@hidden> wrote:
Thanks Kevin.

About the AVAudioSession interruption part, I thought adding a listener function in AudioSessionInitialize() call does the same thing as adding a delegate that handles begin/endInterruption:. We added this listener in our C++ CoreAudio client code. However, that callback seems to only respond to interruptions such as incoming phone calls and alarms, but is not called when we do remote controls.

About your remote control part, if I understand you correctly, it's a Cocoa thing and there is no way to handle it inside our CoreAudio C++ code, right? I don't see our app icon in the media control bar you described there. I guess that would be where the problem is because doing media control with the double-click home button=>swipe left gives us the exact same problem.

Thanks,
Beinan





On Tue, May 28, 2013 at 9:37 PM, Kevin Dixon <email@hidden> wrote:
The routes represent the "physical" path the audio takes after it leaves your application. It probably has nothing to do with your problem at hand.


You should have a delegate attached to the AVAudioSession. Add a delegate which implements -(void)beginInterruption and -(void)endInterruptionWithFlags:(NSUInteger)flags

Furthermore, the "focus" for the remote control API is determined by several things.

1. you must called [[UIApplication sharedApplication] beginReceiginvRemoteControlEvents]
2. you must override your application's -(BOOL)canBecomeFirstResponder method
3. call [self becomeFirstResponder]

you will then get called on -(void)removeControlReceivedWithEvent:(UIEvent*)event

you can see if your app is receiving remote control events if you double-click the home button, then swipe left to see the media controls. If your app icon is there, you are receiving the events.


Hope that helps

-Kevin


On Tue, May 28, 2013 at 8:27 AM, Beinan Li <email@hidden> wrote:
I further checked the doc about Audio Routes.

It looks like they are in charge of routing to I/O hardware instead of software (apps). For example, output routes include:

const CFStringRef kAudioSessionOutputRoute_LineOut;
const CFStringRef kAudioSessionOutputRoute_Headphones;
const CFStringRef kAudioSessionOutputRoute_BluetoothHFP;
const CFStringRef kAudioSessionOutputRoute_BluetoothA2DP;
const CFStringRef kAudioSessionOutputRoute_BuiltInReceiver;
const CFStringRef kAudioSessionOutputRoute_BuiltInSpeaker;
const CFStringRef kAudioSessionOutputRoute_USBAudio;
const CFStringRef kAudioSessionOutputRoute_HDMI;
const CFStringRef kAudioSessionOutputRoute_AirPlay;
In my scenario, I "imagine" that a possible route change would be audio stream was routed to Music app or my own app. So I fail to see how the routes listed above can account for my scenario.


Beinan 


On Tue, May 28, 2013 at 11:02 AM, Beinan Li <email@hidden> wrote:
Hello Valentin,

I tried to use this property and gave it a listener callback. Unfortunately, in my scenario, my callback wasn't called. I tried to set that property after AudioSessionInitialize(NULL, NULL, interruptListener, myObj), then before or after the AudioSessionSetActive(true) call. Didn't make any difference. 

Am I calling it in the wrong way or order or is it simply saying that my audio route hasn't changed when I pause/resume the background Music playback?

Thanks,
Beinan 


On Mon, May 27, 2013 at 1:21 PM, Valentin Radu <email@hidden> wrote:
Hi Beinan,

Not sure if I get your question right, but if I do, there is 

AudioSessionAddPropertyListener (kAudioSessionProperty_AudioRouteChange,
                                     yourCallback, (__bridge void *)(objectThatCanBeReferencedFromCallback));

that allows you to listen for audio route changes, like the one you described.

Cheers,
Valentin



On 27 May 2013, at 19:13, Beinan Li <email@hidden> wrote:

Hi CoreAudio,

Our iOS app uses AudioSessionCategory_SoloAmbientSound.
And if we follow this procedure, the audio of our app will become silence:
1. Turn on the built-in Music app and play it.
2. Turn on our app and make the app sounds play and observe that the Music app is silenced (as expected).
3. Resume the music app playback using the playback control on the bundled iPhone earplug. Notice that app sounds stopped (as expected).
4. Pause the music app playback using the earplug control. 

Now we notice that our app is silent. Audio doesn't come back as "expected".

I initially suspected that maybe the audio session was hijacked by the Music app. So I tried to reset active session in several delegates applicationWillResignActive and applicationDidBecomeActive. But that didn't work.

Is there a way (e.g., a delegate) to track this kind of interruptions?

Thansk!
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)

This email sent to email@hidden

Valentin Radu
cocoaexposed.com
@CocoaExposed




 _______________________________________________
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





 _______________________________________________
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

References: 
 >No interruption events when pausing music using headphone controller (From: Beinan Li <email@hidden>)
 >Re: No interruption events when pausing music using headphone controller (From: Valentin Radu <email@hidden>)
 >Re: No interruption events when pausing music using headphone controller (From: Beinan Li <email@hidden>)
 >Re: No interruption events when pausing music using headphone controller (From: Beinan Li <email@hidden>)
 >Re: No interruption events when pausing music using headphone controller (From: Kevin Dixon <email@hidden>)
 >Re: No interruption events when pausing music using headphone controller (From: Beinan Li <email@hidden>)
 >Re: No interruption events when pausing music using headphone controller (From: Kevin Dixon <email@hidden>)

  • Prev by Date: Re: No interruption events when pausing music using headphone controller
  • Next by Date: AUGraph with a single node
  • Previous by thread: Re: No interruption events when pausing music using headphone controller
  • Next by thread: aurioTouch2 error message and FFT
  • Index(es):
    • Date
    • Thread