开发者

make a button play sound with no lag [duplicate]

开发者 https://www.devze.com 2023-02-28 04:31 出处:网络
This question already has an answer here: Closed 11 years ago. Possible Duplicate: make a button play sound 开发者_开发问答without lag
This question already has an answer here: Closed 11 years ago.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消