Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing kAudioSessionProperty_OtherMixableAudioShouldDuck on iPhone
    primarykey
    data
    text
    <p>I'm trying to get consistant behavior out of the kAudioSessionProperty_OtherMixableAudioShouldDuck property on the iPhone to allow iPod music blending and I'm having trouble. At the start of my app I set an Ambient category like so:</p> <pre><code>-(void) initialize { [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryAmbient error: nil]; } </code></pre> <p>Later on when I attempt to play audio I set the duck property using the following method:</p> <pre><code>//this will crossfade the audio with the ipod music - (void) toggleCrossfadeOn:(UInt32)onOff { //crossfade the ipod music AudioSessionSetProperty(kAudioSessionProperty_OtherMixableAudioShouldDuck,sizeof(onOff),&amp;onOff); AudioSessionSetActive(onOff); } </code></pre> <p>I call this passing a numeric "1" just before playing audio like so:</p> <pre><code> [self toggleCrossfadeOn:1]; [player play]; </code></pre> <p>I then call the crossfade method again passing a zero when my app's audio completes using a playback is stopping callback like so:</p> <pre><code>-(void) playbackIsStoppingForPlayer:(MQAudioPlayer*)audioPlayer { NSLog(@"Releasing player"); [audioPlayer release]; [self toggleCrossfadeOn:0]; } </code></pre> <p>In my production app this exact code works as expected, causing the ipod to fade out just before playing my app's audio then fade back in when the audio finishes playing. In a new project I recently started, I get different behavior. The iPod audio fades down and never fades back in. In my production app I use the AVAudioPlayer where in my new app I've written a custom audio player that uses audio queues. Could somebody help me understand the differences and how to properly use this API?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload