ios-Use system default sound, vibration __ios

Source: Internet
Author: User
Tags uikit

To import a frame:



Code:

[CPP]View plain copy #import <UIKit/UIKit.h> #import <AudioToolbox/AudioToolbox.h> @interface msgplaysound: NSObject {Systemsoundid sound;//system sound ID range is: 1000-2000}-(ID) initsystemshake;//System vibration-(ID) initsystemso Undwithname: (NSString *) soundname soundtype: (NSString *) soundtype;//Initialize system sound-(void) play;//playback @end
[CPP]  View plain copy #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];    &NBSP;&NBsp;      //[[nsbundle bundlewithidentifier:@ "Com.apple.UIKit" &NBSP;] pathforresource:soundname oftype:soundtype];//get the Apple Framework resource uikit.framework&nbsp, remove the path of the system sound to play            //[[nsbundle mainbundle] urlforresource: @ "Tap"  withextension: @ "AIF"];   get custom sounds             if  (path)  {                osstatus error = audioservicescreatesystemsoundid ((cfurlref) [NSURL fileURLWithPath: Path],&sound);                               if  (error !=  Kaudioservicesnoerror)  {//Get the sound when the error occurred                     sound = nil;                }           }        }       return self;  }     -  (void) play    {       audioservicesplaysystemsound (sound);  }  

Apple system default Sound name Description: (this description comes 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 (first convert to AIF, AIFF, then modify suffix)
2. The path in the/system/library/audio/uisounds, the need to change can be based on the following list to replace
3 Detailed list:
Information
receivedmessage.caf--receives the message 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 key
DTMF-1.CAF----------Dial Panel 1 key
DTMF-2.CAF----------Dial Panel 2 key
DTMF-3.CAF----------Dial Panel 3 key
DTMF-4.CAF----------Dial Panel 4 key
DTMF-5.CAF----------Dial Panel 5 key
DTMF-6.CAF----------Dial Panel 6 key
DTMF-7.CAF----------Dial Panel 7 key
DTMF-8.CAF----------Dial Panel 8 key
DTMF-9.CAF----------Dial Panel 9 key
DTMF-POUND.CAF---Dial Panel # button
DTMF-STAR.CAF------Dial Panel * button
VOICEMAIL.CAF-----New Voice mail

Input device sound prompts
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 the recording.
END_VIDEO_RECORD.CAF-----End the video.

Other
beep-beep.caf--charging, cancellation and connection to computer
LOCK.CAF------------Lock the phone.
SHAKE.CAF---------"That's not clear."
UNLOCK.CAF--------Sliding Unlock
low_power.caf--Low Battery Tips

Speech control
jbl_ambiguous.caf--found multiple matches
JBL_BEGIN.CAF------Waiting for user input
JBL_CANCEL.CAF-----canceled.
JBL_CONFIRM.CAF----Execution
JBL_NO_MATCH.CAF---No match found

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.