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

  • Home
  • SEARCH
  • 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 942681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:18:47+00:00 2026-05-15T22:18:47+00:00

I am trying to use iPhone OS 4.0’s multitasking capability. I tried to play

  • 0

I am trying to use iPhone OS 4.0’s multitasking capability. I tried to play audio in the background with no luck. I added UIBackgroundModes property in info.plist and mentioned requires audio to play in background. Also I added the code for playing the audio.
`

NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"someday" ofType:@"mp3"]]; 
AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil];
[audioPlayer play];

`. The audio starts playing once i click on button in the app. But when I shut the app it stops. How can I make it play in the background?

Thanks,
Tony

  • 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-15T22:18:47+00:00Added an answer on May 15, 2026 at 10:18 pm

    It sounds like you didn’t set up your Audio Session correctly. From http://developer.apple.com/iphone/library/documentation/AudioVideo/Conceptual/MultimediaPG/UsingAudio/UsingAudio.html :

    For example, when using the default audio session, audio in your application stops when the Auto-Lock period times out and the screen locks. If you want to ensure that playback continues with the screen locked, include the following lines in your application’s initialization code:

    NSError *setCategoryErr = nil;
    NSError *activationErr  = nil;
    [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error:&setCategoryErr];
    [[AVAudioSession sharedInstance] setActive:YES error:&activationErr];
    

    The AVAudioSessionCategoryPlayback category ensures that playback continues when the screen locks.
    Activating the audio session puts the specified category into effect.

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

Sidebar

Related Questions

I am trying to use the PLDatabase framework in my iPhone app. I've added
I am trying to use c++ in an iphone app. I added the line
I’m trying to use the proprietary iPhone Safari properties -webkit-transition and -webkit-transform to make
I'm trying to use a C++ library (CLucene) from my Cocoa Touch iPhone application
I am trying to use Objective-C blocks in an iPhone 3.1.3 app but am
I am trying to use some external Framework in my iPhone app. I did
I'm creating an iphone app using xcode 4.2, and trying to use the AVFoundation
What type of iPhone application file should I use? Before, I was trying to
I am trying to make this landscape only iphone app. I only use this
I am trying use this example http://www.sajithmr.me/jrecorder/example2.html for recording audio and send it to

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.