ios系統聲音

來源:互聯網
上載者:User

標籤:c   tar   ext   a   int   com   

#import <Foundation/Foundation.h>

#import <AudioToolbox/AudioToolbox.h>

 @interface PlaySound : NSObject

{

    SystemSoundID sound;//系統聲音的id 取值範圍為:1000-2000

}

 - (id)initSystemShake;

- (id)initSystemSoundWithName:(NSString *)soundName soundType:(NSString *)soundType;

- (void)play;

@end

 

#import "PlaySound.h"

@implementation PlaySound

- (id)initSystemShake

{

    self = [super init];

    if(self)

    {

        sound = kSystemSoundID_Vibrate;

    }

    returnself;

}

- (id)initSystemSoundWithName:(NSString *)soundName soundType:(NSString *)soundType

{

    self = [super init];

    if(self)

    {

        NSString *path = [NSString stringWithFormat:@"/System/Library/Audio/UISounds/%@.%@",soundName,soundType];

        //[[NSBundle bundleWithIdentifier:@"com.apple.UIKit" ]pathForResource:soundName ofType:soundType];//得到蘋果架構資源UIKit.framework ,從中取出所要播放的系統聲音的路徑

        //[[NSBundle mainBundle] URLForResource: @"tap" withExtension: @"aif"];  擷取自訂的聲音

        if(path)

        {

            OSStatus error = AudioServicesCreateSystemSoundID((CFURLRef)[NSURLfileURLWithPath:path], &sound);

            if(error != kAudioServicesNoError)

                sound = 0;

        }

    }

    returnself;

}

- (void)play

{

 AudioServicesPlaySystemSound(sound);

}

@end

 

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  

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.