Import Frame:
Code:
[CPP]View Plaincopy
- #import <UIKit/UIKit.h>
- #import <AudioToolbox/AudioToolbox.h>
- @interface Msgplaysound:nsobject
- {
- Systemsoundid Sound; //system sound ID value range is: 1000-2000
- }
- -(ID) initsystemshake; //System Vibration
- -(ID) Initsystemsoundwithname: (NSString *) soundname soundtype: (NSString *) Soundtype; //Initialize system sound
- -(void) play; //Play
- @end
[CPP]View Plaincopy
- #import "MsgPlaySound.h"
- @implementation Msgplaysound
- -(ID) initsystemshake
- {
- self = [super init];
- if (self) {
- sound = ksystemsoundid_vibrate; //Vibration
- }
- return self;
- }
- -(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) [Nsurl Fileurlwithpath:path],&sound];
- if (Error! = kaudioservicesnoerror) {//Gets the sound when an error occurs
- sound = nil;
- }
- }
- }
- return self;
- }
- -(void) Play
- {
- Audioservicesplaysystemsound (sound);
- }
Apple system default Sound name Description: (this description is from http://bbs.weiphone.com/read-htm-tid-6262661.html)
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
Phone
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
IOS Playback system Sound