Im playing a sound in my app that I would like to loop. My research into this hasnt quite sorted my issue.
my code .m
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"ar4", CFSTR
("wav"), NULL);
UInt32 soundID;
AudioServicesCreateSystemSoundID (soundFileURLRef, &soundID);
AudioServicesPlaySystemSound (soundID);
I think I need to put something like this in
numberOfLoops = -1;
But unsure how to implement in my code as I get undeclared error for numberOfLoops. Some advice would be very much appreciated
Something like this should do your problem:
Then if you want to stop it:
or pause it :
and also import it in your header file:
You should to ofcourse declare it in your header, then synthesize it.
//.h and add the bold part:
@interface ViewController : UIViewController <AVAudioPlayerDelegate> {
//.m