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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:04:36+00:00 2026-05-31T21:04:36+00:00

-(void)viewDidAppear:(BOOL)animated { CFBundleRef mainBundle = CFBundleGetMainBundle(); CFURLRef soundFileURLRef; soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @Intro, CFSTR

  • 0
-(void)viewDidAppear:(BOOL)animated

{
    CFBundleRef mainBundle = CFBundleGetMainBundle();
    CFURLRef soundFileURLRef;
    soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"Intro",
                                              CFSTR ("wav"), NULL);
    UInt32 soundID;
    AudioServicesCreateSystemSoundID (soundFileURLRef, &soundID);
    AudioServicesPlaySystemSound (soundID);
}

I’m a beginner with this. I’m trying to play a wav file in the background of the view controller. I originally made a 30 second wav file, it wouldn’t play, I reduced the length of the audio file to 10 seconds and it plays fine on the view controller. My question is, how to loop this audio file and/or play a longer audio file. Also, will the audio stop when I leave the view controller.

I am using xCode 4.3
I am running the app on a iPhone4 & 4s (iOS 5.1)

Thanks in advance…

  • 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-31T21:04:37+00:00Added an answer on May 31, 2026 at 9:04 pm

    Apple Documentation states

    http://developer.apple.com/library/ios/#documentation/AudioToolbox/Reference/SystemSoundServicesReference/Reference/reference.html

    You can use System Sound Services to play short (30 seconds or shorter) sounds. The interface does not provide level, positioning, looping, or timing control, and does not support simultaneous playback: You can play only one sound at a time. You can use System Sound Services to provide audible alerts. On some iOS devices, alerts can include vibration.

    So no loop is available when using system sounds.

    You can check out this tutorial
    http://mobileorchard.com/easy-audio-playback-with-avaudioplayer/

    - (void)viewDidLoad {
    [super viewDidLoad];
    
    NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/audiofile.mp3", [[NSBundle mainBundle] resourcePath]]];
    
    NSError *error;
    audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
    audioPlayer.numberOfLoops = -1;
    
    if (audioPlayer == nil)
        NSLog([error description]);
    else
        [audioPlayer play];
    
    }
    

    It states that if you set the numberOfLoops property to a negative number causes the audioPlayer to loop indefinitely

    And dont forget to add the AVFoundation framework to your project

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

Sidebar

Related Questions

I have a leak in the following code: - (void)viewDidAppear:(BOOL)animated { //If Home-Theme if
I have a view controller showing UITextField. Here I bring keyboard - (void)viewDidAppear:(BOOL)animated {
i have this animation on the first view controller of a tabbarviewcontroller - (void)viewDidAppear:(BOOL)animated
- (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; NSString *country=[[NSUserDefaults standardUserDefaults]objectForKey:@namecountry]; //url's NSURL *url = [NSURL URLWithString:@someurl];
- (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; NSString *show=[NSString stringWithFormat:@%@,[res objectAtIndex:18]]; float f=[show floatValue]; show1=[NSString stringWithFormat:@%.2f
I have a tableView that loads an XML feed as follows: - (void)viewDidAppear:(BOOL)animated {
- (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; CGRect viewRect = CGRectMake(250, 100, 30, 30); as =
I added -(void) viewDidAppear:(BOOL)animated { NSLog(@view did appear); } to one of my viewcontrollers.
been looking at this for days.. - (void)viewDidAppear:(BOOL)animated { #if !TARGET_IPHONE_SIMULATOR UIButton *returnButton =
On the iPhone, we can simply use (void) viewDidAppear:(BOOL)animated; to perform actions when a

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.