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
I’m confused on how to implement this.
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.
Here is code to pick out a sound file based on a random number from an image array.