ios 如何播放系统声音而不震动

SystemSoundIDsound;

NSString*path = [NSStringstringWithFormat:@"/System/Library/Audio/UISounds/%@.%@",

@"sms-received1",@"caf"];

OSStatuserror = AudioServicesCreateSystemSoundID((__bridgeCFURLRef)[NSURLfileURLWithPath:path],&sound);

if(error!=kAudioServicesNoError)

sound=nil;

AudioServicesPlaySystemSound(sound);

AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); //这个是调用系统的震动

注:@"sms-received1"是要播放的文件名称

@"caf" 播放文件的后缀

你可能感兴趣的:(ios 如何播放系统声音而不震动)