iOS 播放系统提示音和使用系统方法播放本地提示音

来源:互联网 发布:java类库 编辑:程序博客网 时间:2024/06/05 09:49

1、iPhone系统音效

AudioServicesPlaySystemSound(1007);  //其中1007是系统声音的编号,想用其他音效更改编号就可以了

2、用户自己制作的提示音

//文件路径

NSString *path = [[NSBundle mainBundle] pathForResource:@"send" ofType:@"mp3"];

//播放音效

SystemSoundID soundID;

NSURL *filePath = [NSURL fileURLWithPath:path isDirectory:NO];

AudioServicesCreateSystemSoundID((__bridge CFURLRef)filePath, &soundID);

AudioServicesPlaySystemSound(soundID);

原创粉丝点击