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

2017-09-12  本文已影响0人  无聊之人1123

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" 播放文件的后缀

上一篇 下一篇

猜你喜欢

热点阅读