I am trying to get consistent behavior from the kAudioSessionProperty_OtherMixableAudioShouldDuck property on the iPhone to allow mixing iPod music, and I'm having problems. At the beginning of my application, I set the Ambient category as follows:
-(void) initialize { [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryAmbient error: nil]; }
Later, when I try to play audio, I set the duck property using the following method:
I call it passing the numeric "1" just before playing the sound as follows:
[self toggleCrossfadeOn:1]; [player play];
Then I call the crossfade method, passing zero when my application's sound terminates using playback, so that stops the callback:
-(void) playbackIsStoppingForPlayer:(MQAudioPlayer*)audioPlayer { NSLog(@"Releasing player"); [audioPlayer release]; [self toggleCrossfadeOn:0]; }
In my production application, this exact code works as expected, causing the iPod to fade out before playing the applicationβs sound, and then disappear when the sound ends. In the new project that I recently started, I have a different behavior. IPod sound fades and never fades. In my working application, I use AVAudioPlayer, where in my new application I wrote a custom audio player that uses audio queues. Can someone help me figure out the differences and the proper use of this API?
Cliff source share