标签:
SystemSoundID shake_sound_male_id = 0; NSString *thesoundFilePath = [[NSBundle mainBundle] pathForResource:@"ReceivedMessage" ofType:@"caf"]; //音乐文件路径 CFURLRef thesoundURL = (CFURLRef)CFBridgingRetain([NSURL fileURLWithPath:thesoundFilePath]); AudioServicesCreateSystemSoundID(thesoundURL, &shake_sound_male_id); AudioServicesPlaySystemSound(shake_sound_male_id); AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);//播放震动
AudioServicesPlaySystemSound(1004); //更换播放系统的声音 id值可以百度查询 AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);//震动
dispatch_async(dispatch_get_main_queue(), ^{ _lbName=@"Name"; });
//这样实现延时调用是错误的,playSound是不会被调用的 可以在主线程调用 dispatch_async(dispatch_get_global_queue(2, 0), ^{ [self performSelector:@selector(playSound) withObject:nil afterDelay:0.5f];//NSTimer 也需要注意这点 });
//这个是抄的 原地址http://www.cocoachina.com/bbs/read.php?tid=193276 [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(playSound) object:nil]; [self performSelector:@selector(playSound) withObject:nil afterDelay:0.5f];
以后要多记录一下咯,很短以为能记住,过段时间又忘了,又要打开以前的项目来看,自己记忆力真的不行,以后就多
记录下。
标签:
原文地址:http://www.cnblogs.com/try-wyh/p/4625192.html