震动和声音
这演示如何实现电话的震动(注:震动不能工作在模拟器,只能工作在设备上)
1
|
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
|
|
声音可以工作在模拟器,然后一些声音(如循环的)已被证明不能工作,设置在模拟器中成功与否取决于音频格式.注:必须使用.wav格式在这个例子中.
1
2
3
4
5
6
7
8
9
|
SystemSoundID pmph;
id sndpath = [[ NSBundle mainBundle]
pathForResource:@ "mySound"
ofType:@ "wav"
inDirectory:@ "/" ];
CFURLRef baseURL = (CFURLRef) [[ NSURL alloc] initFileURLWithPath:sndpath];
AudioServicesCreateSystemSoundID (baseURL, &pmph);
AudioServicesPlaySystemSound(pmph);
[baseURL release];
|
|