make a button play sound with no lag [duplicate]
Possible Duplicate:
make a button play sound 开发者_开发问答without lag
Im making a button play sound, like a button sound effect for example in jely car 3 when you press like a new game button it would have a sound effect like "boop." I have done that but there is heaps of lag on the ios simulator which means there will be more on the iphone HELP TKS!
i figured it out, basically you just connect it to the first responder
You might want to check out the Audio 101 tutorial on Ray Wenderlich's page. http://www.raywenderlich.com/259/audio-101-for-iphone-developers-playing-audio-programmatically
The first code sample shows how to play a sound. Essentially the code is this:
NSString *soundFile = [[NSBundle mainBundle] pathForResource:@"MySound" ofType:@"caf"];
NSURL *soundFileURL = [NSURL fileURLWithPath:soundFile];
AudioServicesCreateSystemSoundID((CFURLRef)soundFileURL, &_MySound);
AudioServicesPlaySystemSound(_MySound);
This is the simplest way to play a sound. As Ray mentions in his tutorial, there are other options such as OpenAL that promise lower latency.
精彩评论