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 462709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:06:08+00:00 2026-05-12T23:06:08+00:00

I have a simple iPhone app with several sounds already playing. However, one in

  • 0

I have a simple iPhone app with several sounds already playing. However, one in particularly won’t. The code block I’ve hacked up is:

NSString *soundPath2 = [[NSBundle mainBundle] pathForResource:@"gameover" ofType:@"wav"];
NSURL *soundFileURL2 = [NSURL fileURLWithPath:soundPath2];
NSError *err;
AVAudioPlayer *sound2 = [[[AVAudioPlayer alloc] initWithContentsOfURL:soundFileURL2 error:&err] autorelease];
NSLog(@"Error: %@", [err description]);
NSLog(@"Duration: %f ", [sound2 duration]);
BOOL b = [sound2 play];
NSLog(@"Play Bool: %d", b);

The console shows the error is null, the boolean returns true, and even the duration is correct! Yet, play does nothing. If I change “gameover” to another sound (a simple beep), all is fine.

While it would be great to get it play, I’m also struggling to understand what error conditions, etc. I can check to 1) know it failed and 2) why.

The sound is question is available at http://wdr1.com/gameover.wav.

  • 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-12T23:06:08+00:00Added an answer on May 12, 2026 at 11:06 pm

    The problem is that you shouldn’t be autoreleasing the AVAudioPlayer. The play method happens asynchronously and if the player gets autoreleased then nothing is holding on to it and it will just die.

    You should release your audio player once the player is done playing in the delegate:

    - (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)audioPlayer successfully:(BOOL)flag
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple iphone app that's based on the CrashLanding sample app. So
I'm working on a simple iPhone app. I have 1 UINavigationController and 2 subclasses
I currently have a simple iPhone app that loads a custom subclass of UIView.
I have a fairly simple iPhone app that downloads a set of UITableView results
I'm working on an iPhone app and would like to have a simple text
I was recently asked if I could code a simple IPhone/IPad app that: Checks
I have a simple UI picker view in an iOS app (iPhone) and I'm
I have a simple iPhone app that allows the user to upload images to
I have very simple iPhone app, which uses just UIButtons , UIlabels , UITableView
I have a simple image viewing iPhone app, and I would like to give

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.