然后顺便百度了一下ID的提示音参照表。放在最下面了就。
static SystemSoundID soundIDTest = 1002;
AudioServicesPlaySystemSound(soundIDTest);
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
导入框架:
代码:
[cpp] view plain copy
1.
2.
3.
4. MsgPlaySound : NSObject
5.
6. SystemSoundID sound;//系统声音的id 取值范围为:1000-2000
7.
8. (id)initSystemShake;//系统 震动
9. (id)initSystemSoundWithName:(NSString *)soundName SoundType:(NSString *)soundType;//初始化系统声音
10. (void)play;//播放
11.
[cpp] view plain copy
1. "MsgPlaySound.h"
2.
3. MsgPlaySound
4.
5. (id)initSystemShake
6.
7. self = [super init];
8. if(self) {
9. sound = kSystemSoundID_Vibrate;//震动
10. }
11. returnself;
12.
13.
14. (id)initSystemSoundWithName:(NSString *)soundName SoundType:(NSString *)soundType
15.
16. self = [super init];
17. if(self) {
18. NSString *path = [NSString stringWithFormat:@"/System/Library/Audio/UISounds/%@.%@",soundName,soundType];
19. //[[NSBundle bundleWithIdentifier:@"com.apple.UIKit" ]pathForResource:soundName ofType:soundType];//得到苹果框架资源UIKit.framework ,从中取出所要播放的系统声音的路径
20. //[[NSBundle mainBundle] URLForResource: @"tap" withExtension: @"aif"]; 获取自定义的声音
21. if(path) {
22. OSStatus error = AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path],&sound);
23.
24. if(error != kAudioServicesNoError) {//获取的声音的时候,出现错误
25. sound = nil;
26. }
27. }
28. }
29. returnself;
30.
31.
32. (void)play
33.
34. AudioServicesPlaySystemSound(sound);
35.
apple系统默认声音名称说明:(此说明来自于http://bbs.weiphone.com/read-htm-tid-6262661.html)
1.声音格式是MP3或m4r的需要转成caf格式(可先转成aif , aiff,然后修改后缀)
2.路径在/System/Library/Audio/UISounds 里,需要更改的可以根据以下列表进行替换
3详细列表:
信息
ReceivedMessage.caf--收到信息,仅在短信界面打开时播放。
sms-received1.caf-------三全音
sms-received2.caf-------管钟琴
sms-received3.caf-------玻璃
sms-received4.caf-------圆号
sms-received5.caf-------铃声
sms-received6.caf-------电子乐
SentMessage.caf--------发送信息
邮件
mail-sent.caf----发送邮件
new-mail.caf-----收到新邮件
电话
dtmf-0.caf----------拨号面板0按键
dtmf-1.caf----------拨号面板1按键
dtmf-2.caf----------拨号面板2按键
dtmf-3.caf----------拨号面板3按键
dtmf-4.caf----------拨号面板4按键
dtmf-5.caf----------拨号面板5按键
dtmf-6.caf----------拨号面板6按键
dtmf-7.caf----------拨号面板7按键
dtmf-8.caf----------拨号面板8按键
dtmf-9.caf----------拨号面板9按键
dtmf-pound.caf---拨号面板#按键
dtmf-star.caf------拨号面板*按键
Voicemail.caf-----新语音邮件
输入设备声音提示
Tock.caf-----------------------点击键盘
begin_record.caf-----------开始录音
begin_video_record.caf--开始录像
photoShutter.caf------------快门声
end_record.caf--------------结束录音
end_video_record.caf-----结束录像
其他
beep-beep.caf--充电、注销及连接电脑
lock.caf------------锁定手机
shake.caf---------“这个还没搞清楚”
unlock.caf--------滑动解锁
low_power.caf--低电量提示
语音控制
jbl_ambiguous.caf--找到多个匹配
jbl_begin.caf------等待用户的输入
jbl_cancel.caf-----取消
jbl_confirm.caf----执行
jbl_no_match.caf---没有找到匹配
日历
alarm.caf--日历提醒
iPod Touch 1G
sq_alarm.caf
sq_beep-beep.caf
sq_lock.caf
sq_tock.caf
AudioServices
Jump to: navigation, search
AudioServices is a group of C functions in AudioToolbox for playing short (≤30 seconds) sounds.
Predefined sounds
/System/Library/Audio/UISounds/.
Sound ID | File name (iPhone) | File name (iPod Touch) | Category | Note |
1015 | Voicemail.caf | Voicemail.caf | - | Available since 2.1 |
1070 | ct-busy.caf | ct-busy.caf | AudioToneBusy | There was no category for this sound before 4.0. |
1074 | ct-call-waiting.caf | ct-call-waiting.caf | AudioToneCallWaiting | There was no category for this sound before 4.0. |
1071 | ct-congestion.caf | ct-congestion.caf | AudioToneCongestion | There was no category for this sound before 4.0. |
1073 | ct-error.caf | ct-error.caf | AudioToneError | There was no category for this sound before 4.0. |
1075 | ct-keytone2.caf | ct-keytone2.caf | AudioToneKey2 | There was no category for this sound before 4.0. |
1072 | ct-path-ack.caf | ct-path-ack.caf | There was no category for this sound before 4.0. | |
1113 | begin_record.caf | begin_record.caf | BeginRecording | Available since 3.0 |
1117 | begin_video_record.caf | begin_video_record.caf | BeginVideoRecording | Available since 3.0 |
1005 | alarm.caf | sq_alarm.caf | CalendarAlert | |
1108 | photoShutter.caf | photoShutter.caf | CameraShutter | |
1106 | beep-beep.caf | sq_beep-beep.caf | ConnectedToPower | |
1114 | end_record.caf | end_record.caf | EndRecording | Available since 3.0 |
1118 | end_video_record.caf | end_video_record.caf | EndVideoRecording | Available since 3.0 |
1102 | - | - | FailedUnlock | |
1256 | short_low_high.caf | short_low_high.caf | Headset_AnswerCall | |
1258 | short_double_low.caf | short_double_low.caf | Headset_CallWaitingActions | |
1257 | short_double_low.caf | short_double_low.caf | Headset_EndCall | |
1255 | short_double_high.caf | short_double_high.caf | Headset_Redial | |
1254 | long_low_short_high.caf | long_low_short_high.caf | Headset_StartCall | |
1259 | middle_9_short_double_low.caf | middle_9_short_double_low.caf | Headset_TransitionEnd | |
1115 | jbl_ambiguous.caf | jbl_ambiguous.caf | JBL_Ambiguous | Available since 3.0 |
1110 | jbl_begin.caf | jbl_begin.caf | JBL_Begin | Available since 3.0 |
1112 | jbl_cancel.caf | jbl_cancel.caf | JBL_Cancel | Available since 3.0 |
1111 | jbl_confirm.caf | jbl_confirm.caf | JBL_Confirm | Available since 3.0 |
1116 | jbl_no_match.caf | jbl_no_match.caf | JBL_NoMatch | Available since 3.0 |
1306 | Tock.caf | sq_tock.caf | KeyPressClickPreview | The category was SystemSoundPreview before 3.2. |
1103 | Tink.caf | sq_tock.caf | KeyPressed | |
1104 | Tock.caf | sq_tock.caf | KeyPressed | |
1105 | Tock.caf | sq_tock.caf | KeyPressed | |
1006 | low_power.caf | low_power.caf | LowPower | |
1000 | new-mail.caf | new-mail.caf | MailReceived | |
1001 | mail-sent.caf | mail-sent.caf | MailSent | |
1057 | Tink.caf | Tink.caf | PINKeyPressed | |
1107 | RingerChanged.caf | RingerChanged.caf | RingerSwitchIndication | |
1350 | - | - | RingerVibeChanged | |
1100 | lock.caf | sq_lock.caf | ScreenLocked | |
1101 | unlock.caf | sq_lock.caf | ScreenUnlocked | |
1109 | shake.caf | shake.caf | ShakeToShuffle | Available since 3.0 |
1351 | - | - | SilentVibeChanged | |
1051 | SIMToolkitCallDropped.caf | SIMToolkitCallDropped.caf | SIMToolkitTone | |
1052 | SIMToolkitGeneralBeep.caf | SIMToolkitGeneralBeep.caf | SIMToolkitTone | |
1053 | SIMToolkitNegativeACK.caf | SIMToolkitNegativeACK.caf | SIMToolkitTone | |
1054 | SIMToolkitPositiveACK.caf | SIMToolkitPositiveACK.caf | SIMToolkitTone | |
1055 | SIMToolkitSMS.caf | SIMToolkitSMS.caf | SIMToolkitTone | |
1003 | ReceivedMessage.caf | ReceivedMessage.caf | SMSReceived | |
1007 | sms-received1.caf | sms-received1.caf | SMSReceived_Alert | |
1008 | sms-received2.caf | sms-received2.caf | SMSReceived_Alert | |
1009 | sms-received3.caf | sms-received3.caf | SMSReceived_Alert | |
1010 | sms-received4.caf | sms-received4.caf | SMSReceived_Alert | |
1012 | sms-received1.caf | sms-received1.caf | SMSReceived_Alert | |
1013 | sms-received5.caf | sms-received5.caf | SMSReceived_Alert | |
1014 | sms-received6.caf | sms-received6.caf | SMSReceived_Alert | |
1020 | Anticipate.caf | Anticipate.caf | SMSReceived_Alert | Available since 4.2 |
1021 | Bloom.caf | Bloom.caf | SMSReceived_Alert | Available since 4.2 |
1022 | Calypso.caf | Calypso.caf | SMSReceived_Alert | Available since 4.2 |
1023 | Choo_Choo.caf | Choo_Choo.caf | SMSReceived_Alert | Available since 4.2 |
1024 | Descent.caf | Descent.caf | SMSReceived_Alert | Available since 4.2 |
1025 | Fanfare.caf | Fanfare.caf | SMSReceived_Alert | Available since 4.2 |
1026 | Ladder.caf | Ladder.caf | SMSReceived_Alert | Available since 4.2 |
1027 | Minuet.caf | Minuet.caf | SMSReceived_Alert | Available since 4.2 |
1028 | News_Flash.caf | News_Flash.caf | SMSReceived_Alert | Available since 4.2 |
1029 | Noir.caf | Noir.caf | SMSReceived_Alert | Available since 4.2 |
1030 | Sherwood_Forest.caf | Sherwood_Forest.caf | SMSReceived_Alert | Available since 4.2 |
1031 | Spell.caf | Spell.caf | SMSReceived_Alert | Available since 4.2 |
1032 | Suspense.caf | Suspense.caf | SMSReceived_Alert | Available since 4.2 |
1033 | Telegraph.caf | Telegraph.caf | SMSReceived_Alert | Available since 4.2 |
1034 | Tiptoes.caf | Tiptoes.caf | SMSReceived_Alert | Available since 4.2 |
1035 | Typewriters.caf | Typewriters.caf | SMSReceived_Alert | Available since 4.2 |
1036 | Update.caf | Update.caf | SMSReceived_Alert | Available since 4.2 |
1307 | sms-received1.caf | sms-received1.caf | SMSReceived_Selection | |
1308 | sms-received2.caf | sms-received2.caf | SMSReceived_Selection | |
1309 | sms-received3.caf | sms-received3.caf | SMSReceived_Selection | |
1310 | sms-received4.caf | sms-received4.caf | SMSReceived_Selection | |
1312 | sms-received1.caf | sms-received1.caf | SMSReceived_Selection | |
1313 | sms-received5.caf | sms-received5.caf | SMSReceived_Selection | |
1314 | sms-received6.caf | sms-received6.caf | SMSReceived_Selection | |
1320 | Anticipate.caf | Anticipate.caf | SMSReceived_Selection | Available since 4.2 |
1321 | Bloom.caf | Bloom.caf | SMSReceived_Selection | Available since 4.2 |
1322 | Calypso.caf | Calypso.caf | SMSReceived_Selection | Available since 4.2 |
1323 | Choo_Choo.caf | Choo_Choo.caf | SMSReceived_Selection | Available since 4.2 |
1324 | Descent.caf | Descent.caf | SMSReceived_Selection | Available since 4.2 |
1325 | Fanfare.caf | Fanfare.caf | SMSReceived_Selection | Available since 4.2 |
1326 | Ladder.caf | Ladder.caf | SMSReceived_Selection | Available since 4.2 |
1327 | Minuet.caf | Minuet.caf | SMSReceived_Selection | Available since 4.2 |
1328 | News_Flash.caf | News_Flash.caf | SMSReceived_Selection | Available since 4.2 |
1329 | Noir.caf | Noir.caf | SMSReceived_Selection | Available since 4.2 |
1330 | Sherwood_Forest.caf | Sherwood_Forest.caf | SMSReceived_Selection | Available since 4.2 |
1331 | Spell.caf | Spell.caf | SMSReceived_Selection | Available since 4.2 |
1332 | Suspense.caf | Suspense.caf | SMSReceived_Selection | Available since 4.2 |
1333 | Telegraph.caf | Telegraph.caf | SMSReceived_Selection | Available since 4.2 |
1334 | Tiptoes.caf | Tiptoes.caf | SMSReceived_Selection | Available since 4.2 |
1335 | Typewriters.caf | Typewriters.caf | SMSReceived_Selection | Available since 4.2 |
1336 | Update.caf | Update.caf | SMSReceived_Selection | Available since 4.2 |
1011 | - | - | SMSReceived_Vibrate | |
1311 | - | - | SMSReceived_Vibrate | |
1004 | SentMessage.caf | SentMessage.caf | SMSSent | |
1016 | tweet_sent.caf | tweet_sent.caf | SMSSent | Available since 5.0 |
1300 | Voicemail.caf | Voicemail.caf | SystemSoundPreview | |
1301 | ReceivedMessage.caf | ReceivedMessage.caf | SystemSoundPreview | |
1302 | new-mail.caf | new-mail.caf | SystemSoundPreview | |
1303 | mail-sent.caf | mail-sent.caf | SystemSoundPreview | |
1304 | alarm.caf | sq_alarm.caf | SystemSoundPreview | |
1305 | lock.caf | sq_lock.caf | SystemSoundPreview | |
1315 | Voicemail.caf | Voicemail.caf | SystemSoundPreview | Available since 2.1 |
1200 | dtmf-0.caf | dtmf-0.caf | TouchTone | |
1201 | dtmf-1.caf | dtmf-1.caf | TouchTone | |
1202 | dtmf-2.caf | dtmf-2.caf | TouchTone | |
1203 | dtmf-3.caf | dtmf-3.caf | TouchTone | |
1204 | dtmf-4.caf | dtmf-4.caf | TouchTone | |
1205 | dtmf-5.caf | dtmf-5.caf | TouchTone | |
1206 | dtmf-6.caf | dtmf-6.caf | TouchTone | |
1207 | dtmf-7.caf | dtmf-7.caf | TouchTone | |
1208 | dtmf-8.caf | dtmf-8.caf | TouchTone | |
1209 | dtmf-9.caf | dtmf-9.caf | TouchTone | |
1210 | dtmf-star.caf | dtmf-star.caf | TouchTone | |
1211 | dtmf-pound.caf | dtmf-pound.caf | TouchTone | |
1050 | ussd.caf | ussd.caf | USSDAlert | |
1154 | vc~ringing.caf | vc~ringing.caf | VCCallUpgrade | Available since 4.1 |
1153 | ct-call-waiting.caf | ct-call-waiting.caf | VCCallWaiting | Available since 4.1 |
1152 | vc~ended.caf | vc~ended.caf | VCEnded | Available since 4.0 |
1150 | vc~invitation-accepted.caf | vc~invitation-accepted.caf | VCInvitationAccepted | Available since 4.0 |
1151 | vc~ringing.caf | vc~ringing.caf | VCRinging | Available since 4.0 |
4095 | - | - | Vibrate | There was no category for this sound before 2.2. In the SDK this is the constant kSystemSoundID_Vibrate. |
1002 | Voicemail.caf | Voicemail.caf | VoicemailReceived |
上面是对应的列表,他们的调用播放相对比较简单,容易实现!!
|
直接调用它既可以实现,不过这里的id就是上面的数字id,慢慢熟悉他们的声音吧!
这里我想说明一下,我本来是打算搜索一些系统铃声的信息,而不是提示音,结果碰得到了提示音,就先记录下来,以后用得着,下面我会记录一下如何在一个app 开发中实现ios系统的铃声!!
一些值得参考的网址:
https://github.com/TUNER88/iOSSystemSoundsLibrary
最后附上我的Demo,先说下功能:从sounds.plist文件中读取,来实现提示音列表,点击相应的cell,会播放相应的声音!注意:在模拟器中是无法听到声音的!!!