Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7048527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:54:10+00:00 2026-05-28T02:54:10+00:00

If this is in the apple doc then I’ve not been able to find

  • 0

If this is in the apple doc then I’ve not been able to find it – hoping someone can help:

My app plays occasional short audio clips – I want the audio to mix in with audio playing from other apps in the background like the iPod app – but I also want it to carry on playing these audio clips when the app is running in background.

I have set “App plays audio” in the Required Background Modes settings in info.plist (the app is also using location services too so that is also set in there)

My app sets up an audio session on applicationDidFinishLaunching:

AudioSessionInitialize (NULL,NULL,NULL,NULL);
UInt32 sessionCategory = kAudioSessionCategory_AmbientSound;
AudioSessionSetProperty (kAudioSessionProperty_AudioCategory,sizeof (sessionCategory),&sessionCategory); 
AudioSessionSetActive(true);

In my viewWillAppear: method in the view that is active I have:

[super viewWillAppear:animated];
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder]; 

and the corresponding event handler and endReceivingRemoteControlEvents code in viewWillDisappear: as discussed in iOS 4: Remote controls for background audio

Finally I have an AVAudioPlayer, set up in the normal way, that plays a sound on certain events

bool successful = [avAudioPlayer play];
if(!successful)
    NSLog(@"did not play");

When the app is in foreground the app works fine and plays the audio – but when the app goes into background and the app attempts to play a sound the return value from the [avAudioPlayer play] is NO and the sound does not play – when switched back to foreground the audio starts working again.

If when I set up the session I instead use

    UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback;

Then the audio plays in foreground and background perfectly. But MediaPlayback is not the really the right mode for this app since I am only occasionally playing audio clips – AmbientSound is really the mode I should be using.

What am I missing? Is it just not possible to use kAudioSessionCategory_AmbientSound to play Audio in the background? If so I’ve not found anything in the documentation about that.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:54:10+00:00Added an answer on May 28, 2026 at 2:54 am

    Had to submit a tech support request for this in the end.

    According to Apple background playback is not supported by the AmbientSound category – you have to use MediaPlayback.

    They claim this is in the documentation – I’ve looked again and I could not find it.

    Ok so getting background sounds to mix into MediaPlayback is easy enough using kAudioSessionProperty_OverrideCategoryMixWithOthers – but I am now going to have to jump through some other hoops to replicate the other AmbientSound functionality (obeying the mute switch and not playing when locked). I really don’t understand why AmbientSound is not supported playing in background – but there we go.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is for the Apple platform. My end goal is to do a find
I'm using this sample code to view a PDF in my iPhone app: http://developer.apple.com/library/ios/#samplecode/ZoomingPDFViewer/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010281-Intro-DontLinkElementID_2
Maybe you could help me to find the appropriate way to handle this :
So, I saw this: error:(NSError **)error in the apple doc's. Why two stars? What
I've read the Apple doc about Preferences but this is still a little bit
I'm confused by this: http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/AccessorConventions.html#//apple_ref/doc/uid/20002174-178830-BAJEDEFB Supposing @interface Office : NSObject { NSMutableArray *employees; }
function Apple(){ this.name=apple; } function Orange(){ this.name=orange; this.apple = new Apple(); this.apple.onCalled=function(){ alert(this.name); }
Could you please clarify this part of Apple's documentation: Transitioning to ARC Release Notes
I got the JSON from apple like this { original-purchase-date-pst = 2012-06-28 02:46:02 America/Los_Angeles;
So let's say I have this array: $requiredFruit= @(apple,pear,nectarine,grape) And I'm given a second

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.