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。