iPhone播放声音

NSURL *path = [[NSBundle mainBundle] URLForResource:@"teaSound" withExtension:@"m4r"];
SystemSoundID soundID;
AudioServicesCreateSystemSoundID((CFURLRef)path, &soundID);
AudioServicesPlaySystemSound(soundID);

 代码就是上面几句,另外要添加AudioToolbox.framework

头文件中要

#import <AudioToolbox/AudioToolbox.h>

声音文件30秒内的 aif wav m4r caf。

猜你喜欢

转载自seemefly163-0.iteye.com/blog/1762989