AudioToolbox播放短音效
//先导入import<AudioToolbox/AudioToolbox.h>
//读取本地不超过三十秒的短音频
NSURL *url = [[NSBundle mainBundle] URLForResource:@"in" withExtension:@"caf"];
//创建系统音频 向系统注册声音ID并播放
SystemSoundID ID;
AudioServicesCreateSystemSoundID((__bridge CFURLRef _Nonnull)(url), &ID);
AudioServicesPlayAlertSound(ID);
//系统声音id从1000开始 (直接就能播放而不用注册ID)
AudioServicesPlayAlertSound(1001);
//振动vibrate
AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);
参考:http://www.jianshu.com/p/b75b7f737512(这篇文章关于AudioToolbox这个框架写的很全可以参考一下)
网友评论