使用AudioServicesPlaySystemSound 這個接口來進行聲音和震動的播放, 當然需要在工程中加入AudioToolBox.framework
1. 播放震動
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
2. 播放特定的聲音
static SystemSoundID soundIDTest = 0;
NSString * path = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"wav"];
if (path) {
AudioServicesCreateSystemSoundID( (CFURLRef)[NSURL fileURLWithPath:path], &soundIDTest );
}
AudioServicesPlaySystemSound( soundIDTest );