5.1音频播放
@基本步骤:
+ (void)playSoundWithName:(NSString *)soundStr
{
//1创建一个音效id
SystemSoundID soundID;
//2获取一个音效url
NSURL *url = [[NSBundle mainBundle] URLForResource:soundStr withExtension:nil];
//3给音效url绑定id
AudioServicesCreateSystemSoundID(CFBridgingRetain(url), &soundID);
//4播放音效
AudioServicesPlaySystemSound(soundID);
}
注意点
1为何播放音效后,会自动进入断点?
因为会自动进入全局断点,如果不想总是听到声效,就关闭全局断点吧,或者让声音功能暂时睡眠
浙公网安备 33010602011771号