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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:19:27+00:00 2026-05-23T21:19:27+00:00

I am trying to loop my sound file and I cannot find the parameter

  • 0

I am trying to loop my sound file and I cannot find the parameter to loop the sound file! I’m about to pull out the last standing hair on my head. It loads fine….it plays….I just can’t figure out the code on how to make it loop.

Here is my code:

NSString *eyeBGPath = [[NSBundle mainBundle] pathForResource:@"theeye" ofType:@"caf"];
CFURLRef eyeBGURL = (CFURLRef ) [NSURL fileURLWithPath:eyeBGPath];
AudioServicesCreateSystemSoundID(eyeBGURL, &eyeBackGroundID);
AudioServicesPlaySystemSound(eyeBackGroundID); 

What am I doing wrong here?

I found this:

loops
Indicates whether the receiver restarts playback when it reaches the end of its content. Default: NO.

- (BOOL)loops
Return Value

YES when the receiver restarts playback when it finishes, NO otherwise.

Availability
Available in Mac OS X v10.5 and later.
See Also
– setLoops:
Declared In
NSSound.h

http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSSound_Class/Reference/Reference.html%23//apple_ref/occ/instm/NSSound/loops

I’m confused on how to implement this.

  • 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-23T21:19:27+00:00Added an answer on May 23, 2026 at 9:19 pm

    This is the code that worked for me. If anyone needs help with this, let me know. Someone on the Apple Dev forum pointed me to the AVFoundation docs.

    NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/theeye3.caf", [[NSBundle mainBundle] resourcePath]]];
    
    audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:NULL];
    audioPlayer.numberOfLoops = -1;
    
    [audioPlayer play];
    

    Here is code to pick out a sound file based on a random number from an image array.

    NSString *audioWiz = [[NSString alloc]initWithFormat:@"%d.caf", randNum];
    
    NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:[@"%@/" stringByAppendingString:audioWiz], [[NSBundle mainBundle] resourcePath]]];
    
    audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:NULL];
    audioPlayer.numberOfLoops = 0;
    audioPlayer.volume = 0.1;
    
    [audioPlayer play];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to loop through a query string and pull out certain values
I'm trying to loop through the results from the Last.fm API but it's not
So I have an XML file that I am trying to loop through in
I am trying to loop a 2 second sound continuously that I am using
I'm trying to loop over all JavaScript variables to find ones that match a
I am trying to seamlessly loop an audio file. I was using MP3 which
I am trying to loop through some 50-odd files in a directory. Each file
I'm trying to loop through items of a checkbox list. If it's checked, I
I am trying to loop though my users database to show each username in
I am trying to loop from 100 to 0. How do I do this

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.