AudioServicesPlaySystemSound播放声音

//  使用AudioToolbox framework

// IOS简单播放声音的方法

 

#import <AudioToolbox/AudioToolbox.h>
#pragma mark 播放声音 - (void)playSound { static SystemSoundID shake_sound_male_id = 0; NSString *path = [[NSBundle mainBundle] pathForResource:@"noWeak01" ofType:@"mp3"]; if (path) { //注册声音到系统 AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path],&shake_sound_male_id); AudioServicesPlaySystemSound(shake_sound_male_id); } AudioServicesPlaySystemSound(shake_sound_male_id); //播放注册的声音,(此句代码,可以在本类中的任意位置调用,不限于本方法中) // AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); //让手机震动 }

 

posted @ 2014-03-14 13:03  limengdev  阅读(693)  评论(0编辑  收藏  举报