Possible Duplicate:
xcode 4.2 soundboard?
Hi I’m creating a soundboard for my iPhone app but I keep getting errors etc in my code can you guys maybe edit it or do you known any better codes for a soundboard i am using Xcode 4.2 and I’m new so please be clear thank you for your time i really appreciate it!!
.h all fine i think no errors
#import <UIKit/UIKit.h>
#import <AudioToolbox/AudioToolbox.h>
@interface ViewController : UIViewController {
}
-(IBAction)sound1:(id)sender;
@end
.m this is the one with errors
#import "ViewController.h"
//@interface ViewController ()
@implementation ViewController
-(IBAction)sound1:(id)sender {
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"sound1" , CFSTR ("wav") , null);
}
uint32 soundID;
AudioservicecreatesystemsoundID(soundfileURLRef, &soundID);
AudioservicesPlaysystemsound(soundID)
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
@end
thank you hope you can help me
AudioToolbox might be a bit too low-level for your needs here… You could probably make your life a lot easier by using AVFoundation; specifically, the AVAudioPlayer class.
In your implementation:
Note that I’m not doing any memory management here. Also, if you need to play more than one sound at a time, you can either create additional instances of AVAudioPlayer, or you might check out the OpenAL library… there’s a great wrapper for it on github here.