IOS 播放系統(tǒng)聲音

#import<AudioToolbox/AudioToolbox.h>

- (void)viewDidLoad {

[super viewDidLoad];

[self playBackgroundMusic];

}



-(void)playBackgroundMusic{

//注冊系統(tǒng)id

//不超過三十秒的短音頻

SystemSoundID ID;

NSURL *url = [[NSBundle mainBundle] URLForResource:@"garen" withExtension:@"mp3"];

//創(chuàng)建系統(tǒng)音頻

AudioServicesCreateSystemSoundID((__bridge CFURLRef _Nonnull)(url), &ID);

//播放 系統(tǒng)聲音id從1000開始

AudioServicesPlayAlertSound(ID);

//振動vibrate

AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);

}


Sound ID File name (iPhone) File name (iPod Touch) Category Note

1000 new-mail.caf new-mail.caf MailReceived

1001 mail-sent.caf mail-sent.caf MailSent

1002 Voicemail.caf Voicemail.caf VoicemailReceived

1003 ReceivedMessage.caf ReceivedMessage.caf SMSReceived

1004 SentMessage.caf SentMessage.caf SMSSent

1005 alarm.caf sq_alarm.caf CalendarAlert

1006 low_power.caf low_power.caf LowPower

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

1011 - - SMSReceived_Vibrate

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

1015 Voicemail.caf Voicemail.caf - Available since 2.1

1016 tweet_sent.caf tweet_sent.caf SMSSent Available since 5.0

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

1050 ussd.caf ussd.caf USSDAlert

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

1057 Tink.caf Tink.caf PINKeyPressed

1070 ct-busy.caf ct-busy.caf AudioToneBusy 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.

1072 ct-path-ack.caf ct-path-ack.caf AudioTonePathAcknowledge 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.

1074 ct-call-waiting.caf ct-call-waiting.caf AudioToneCallWaiting 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.

1100 lock.caf sq_lock.caf ScreenLocked

1101 unlock.caf sq_lock.caf ScreenUnlocked

1102 - - FailedUnlock

1103 Tink.caf sq_tock.caf KeyPressed

1104 Tock.caf sq_tock.caf KeyPressed

1105 Tock.caf sq_tock.caf KeyPressed

1106 beep-beep.caf sq_beep-beep.caf ConnectedToPower

1107 RingerChanged.caf RingerChanged.caf RingerSwitchIndication

1108 photoShutter.caf photoShutter.caf CameraShutter

1109 shake.caf shake.caf ShakeToShuffle Available since 3.0

1110 jbl_begin.caf jbl_begin.caf JBL_Begin Available since 3.0

1111 jbl_confirm.caf jbl_confirm.caf JBL_Confirm Available since 3.0

1112 jbl_cancel.caf jbl_cancel.caf JBL_Cancel Available since 3.0

1113 begin_record.caf begin_record.caf BeginRecording Available since 3.0

1114 end_record.caf end_record.caf EndRecording Available since 3.0

1115 jbl_ambiguous.caf jbl_ambiguous.caf JBL_Ambiguous Available since 3.0

1116 jbl_no_match.caf jbl_no_match.caf JBL_NoMatch Available since 3.0

1117 begin_video_record.caf begin_video_record.caf BeginVideoRecording Available since 3.0

1118 end_video_record.caf end_video_record.caf EndVideoRecording Available since 3.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

1152 vc~ended.caf vc~ended.caf VCEnded Available since 4.0

1153 ct-call-waiting.caf ct-call-waiting.caf VCCallWaiting Available since 4.1

1154 vc~ringing.caf vc~ringing.caf VCCallUpgrade Available since 4.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

1254 long_low_short_high.caf long_low_short_high.caf Headset_StartCall

1255 short_double_high.caf short_double_high.caf Headset_Redial

1256 short_low_high.caf short_low_high.caf Headset_AnswerCall

1257 short_double_low.caf short_double_low.caf Headset_EndCall

1258 short_double_low.caf short_double_low.caf Headset_CallWaitingActions

1259 middle_9_short_double_low.caf middle_9_short_double_low.caf Headset_TransitionEnd

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

1306 Tock.caf sq_tock.caf KeyPressClickPreview The category was SystemSoundPreview before 3.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

1311 - - SMSReceived_Vibrate

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

1315 Voicemail.caf Voicemail.caf SystemSoundPreview Available since 2.1

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

1350 - - RingerVibeChanged

1351 - - SilentVibeChanged

4095 - - Vibrate There was no category for this sound before 2.2.

In the SDK this is the constant kSystemSoundID_Vibrate.

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末缅糟,一起剝皮案震驚了整個濱河市哩至,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌镶骗,老刑警劉巖,帶你破解...
    沈念sama閱讀 222,183評論 6 516
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件巡验,死亡現(xiàn)場離奇詭異朵诫,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)毅哗,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,850評論 3 399
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來捧挺,“玉大人虑绵,你說我怎么就攤上這事∶隼樱” “怎么了翅睛?”我有些...
    開封第一講書人閱讀 168,766評論 0 361
  • 文/不壞的土叔 我叫張陵,是天一觀的道長。 經(jīng)常有香客問我捕发,道長疏旨,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 59,854評論 1 299
  • 正文 為了忘掉前任爬骤,我火速辦了婚禮充石,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘霞玄。我一直安慰自己骤铃,他們只是感情好,可當(dāng)我...
    茶點故事閱讀 68,871評論 6 398
  • 文/花漫 我一把揭開白布坷剧。 她就那樣靜靜地躺著惰爬,像睡著了一般。 火紅的嫁衣襯著肌膚如雪惫企。 梳的紋絲不亂的頭發(fā)上撕瞧,一...
    開封第一講書人閱讀 52,457評論 1 311
  • 那天,我揣著相機(jī)與錄音狞尔,去河邊找鬼丛版。 笑死,一個胖子當(dāng)著我的面吹牛偏序,可吹牛的內(nèi)容都是我干的页畦。 我是一名探鬼主播,決...
    沈念sama閱讀 40,999評論 3 422
  • 文/蒼蘭香墨 我猛地睜開眼研儒,長吁一口氣:“原來是場噩夢啊……” “哼豫缨!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起端朵,我...
    開封第一講書人閱讀 39,914評論 0 277
  • 序言:老撾萬榮一對情侶失蹤好芭,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后冲呢,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體舍败,經(jīng)...
    沈念sama閱讀 46,465評論 1 319
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 38,543評論 3 342
  • 正文 我和宋清朗相戀三年敬拓,在試婚紗的時候發(fā)現(xiàn)自己被綠了邻薯。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 40,675評論 1 353
  • 序言:一個原本活蹦亂跳的男人離奇死亡恩尾,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出挽懦,到底是詐尸還是另有隱情翰意,我是刑警寧澤,帶...
    沈念sama閱讀 36,354評論 5 351
  • 正文 年R本政府宣布,位于F島的核電站冀偶,受9級特大地震影響醒第,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜进鸠,卻給世界環(huán)境...
    茶點故事閱讀 42,029評論 3 335
  • 文/蒙蒙 一稠曼、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧客年,春花似錦霞幅、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,514評論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至绍傲,卻和暖如春扔傅,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背烫饼。 一陣腳步聲響...
    開封第一講書人閱讀 33,616評論 1 274
  • 我被黑心中介騙來泰國打工猎塞, 沒想到剛下飛機(jī)就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人杠纵。 一個月前我還...
    沈念sama閱讀 49,091評論 3 378
  • 正文 我出身青樓荠耽,卻偏偏與公主長得像,于是被迫代替她去往敵國和親淡诗。 傳聞我的和親對象是個殘疾皇子骇塘,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 45,685評論 2 360

推薦閱讀更多精彩內(nèi)容