MrM*_*age 7 iphone keyboard audio objective-c core-audio
我已将iPhone的Tock声音添加到我自己的自定义键盘中,如下所示:
NSString *path = [[NSBundle bundleWithIdentifier:@"com.apple.UIKit"] pathForResource:@"Tock" ofType:@"aiff"];
SystemSoundID soundID;
AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path], &soundID);
AudioServicesPlaySystemSound(soundID);
// we don't dispose of the sound to keep the sound in the cache for the next time
//AudioServicesDisposeSystemSoundID(soundID);
Run Code Online (Sandbox Code Playgroud)
然而,在iPhone OS 3.1中,键盘Tock声音已被低沉,例如比其他声音更安静,而不是3.0.我的方法的声音仍然很响,并且音量最大.我怎样才能获得与iPhone默认键盘相同的音量?
顺便说一句,Twitterrific中的Tock声音适当地低沉.
干杯
MrMage
使用0x450作为SystemSoundID以正确的音量为我工作 - 请注意它不尊重键盘点击开/关首选项.
我不确定这是多么便携 - 它适用于模拟器和iPod Touch第三代.我怀疑它适用于所有设备,但在软件更新中可能会更改,恕不另行通知.
我通过在AudioServicesPlaySystemSound上设置断点并按下普通键盘键来获得此数字 - 第一个汇编指令将SystemSoundID复制到寄存器中,因此您可以在调试器的"寄存器"视图中看到它.
| 归档时间: |
|
| 查看次数: |
2504 次 |
| 最近记录: |