#import <Foundation/Foundation.h>
#import <AudioToolbox/AudioToolbox.h>
@interface Playsound:nsobject
{
systemsoundid sound ; the system sound ID value range is: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];// Get The uikit.framework of the Apple frame resource and remove the path from the system sound you want to play
//[[nsbundle Mainbundle] Urlforresource: @ "tap" withextension: @ "AIF"]; get a custom sound
if (path)
{
osstatus error = audioservicescreatesystemsoundid(cfurlref ) [nsurlfileurlwithpath:p Ath], &sound);
if (Error! = Kaudioservicesnoerror)
sound = 0;
}
}
returnself;
}
-(void) play
{
audioservicesplaysystemsound(sound);
}
@end
1. The sound format is MP3 or m4r needs to be converted into CAF format (can be converted to AIF, AIFF, and then modified suffix)
2. The path in/system/library/audio/uisounds, you need to change can be replaced according to the following list
3 Detailed list:
Information
receivedmessage.caf--receives information and plays only when the SMS interface is open.
SMS-RECEIVED1.CAF-------Three tone
SMS-RECEIVED2.CAF-------Jungzhongchen
SMS-RECEIVED3.CAF-------Glass
sms-received4.caf-------Horn
SMS-RECEIVED5.CAF-------Ringtones
SMS-RECEIVED6.CAF-------Electronic music
SENTMESSAGE.CAF--------Send a message
Mail
MAIL-SENT.CAF----Send mail
NEW-MAIL.CAF-----receive new mail
Telephone
DTMF-0.CAF----------Dial Panel 0 button
DTMF-1.CAF----------Dial Panel 1 button
DTMF-2.CAF----------Dial Panel 2 button
DTMF-3.CAF----------Dial Panel 3 button
DTMF-4.CAF----------Dial Panel 4 button
DTMF-5.CAF----------Dial Panel 5 button
DTMF-6.CAF----------Dial Panel 6 button
DTMF-7.CAF----------Dial Panel 7 button
DTMF-8.CAF----------Dial Panel 8 button
DTMF-9.CAF----------Dial Panel 9 button
DTMF-POUND.CAF---Dial panel # keys
DTMF-STAR.CAF------Dial Panel * keys
VOICEMAIL.CAF-----New voice mail
input device Sound tips
TOCK.CAF-----------------------Click on the keyboard
BEGIN_RECORD.CAF-----------start recording .
begin_video_record.caf--start recording .
photoshutter.caf------------Shutter sound
END_RECORD.CAF--------------End Recording
END_VIDEO_RECORD.CAF-----End Video
other
beep-beep.caf--charging, logging off and connecting the computer
LOCK.CAF------------Lock your phone
SHAKE.CAF---------"This is not clear."
unlock.caf--------Sliding unlock
low_power.caf--Low Battery tip
Voice Control
jbl_ambiguous.caf--found multiple matches
JBL_BEGIN.CAF------Waiting for the user's input
JBL_CANCEL.CAF-----Cancel
JBL_CONFIRM.CAF----Execution
JBL_NO_MATCH.CAF---No match found
Calendar
alarm.caf--Calendar Reminders
iPod Touch 1G
SQ_ALARM.CAF
SQ_BEEP-BEEP.CAF
SQ_LOCK.CAF
SQ_TOCK.CAF