Note that there are some explanatory texts on larger screens.

plurals
  1. POAudioSessionSetActive(true) stops the iPod player shortly in case of category kAudioSessionCategory_PlayAndRecord is active
    text
    copied!<p>I am a bit confused. I have the following setup running. I am using the kAudioSessionCategory_PlayAndRecord category and the iPod plays some music in the background.</p> <p>If I want to play some app music with the following category overrides, the iPod music will be stopped shortly through the [[AVAudioSession sharedInstance] setActive:YES...] call, but it seems that ducking and mixing works. The same will happen as soon as my app sound stops, again with the corresponding ...:setActive:NO] call. If I will use the MediaPlayback category the "blending" between app sound and iPod sound works fine without any interruptions. Category switch is not an option for me (i need also the bluetooth override), therefore I am looking forward if someone can help me with that issue. </p> <pre><code>- (IBAction) playAppSound: (id) sender { NSError *activationError = nil; [[AVAudioSession sharedInstance] setActive: NO error: &amp;activationError]; // set internal speakers as default... UInt32 useDefaultSpeakers = 1; AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryDefaultToSpeaker, sizeof(useDefaultSpeakers), &amp;useDefaultSpeakers); // always try to enable ducking UInt32 shouldDuck = 1; AudioSessionSetProperty( kAudioSessionProperty_OtherMixableAudioShouldDuck, sizeof(UInt32), &amp;shouldDuck ); UInt32 doSetProperty = 1; AudioSessionSetProperty ( kAudioSessionProperty_OverrideCategoryMixWithOthers, sizeof (doSetProperty), &amp;doSetProperty ); // Activates the audio session. [[AVAudioSession sharedInstance] setActive: YES error: &amp;activationError]; [appSoundPlayer play]; </code></pre>
 

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