This link gives a very detailed list of all the system sounds inside the IOS7, the sound ID, the location of the sound storage although it is now the iOS8 era, but the system sound this east will not be outdated, after all, the sound of the dozens of kinds, not all of a sudden there is too much change. Https://github.com/TUNER88/iOSSystemSoundsLibrary
This stackoverflow contains some useful information and links, including how to play the system sound, how to view refhttp://stackoverflow.com/questions/7831671/ Playing-system-sound-without-importing-your-own
There's also a very vicious GitHub project where he puts all of the. Framework in place for everyone to download. There's audiotoolboxhttps://github.com/ethanarbuckle/ios-7-headers I just needed.
This blog teaches how to use system encapsulated apihttp://www.cnblogs.com/martin1009/archive/2012/06/14/2549473.html
If you want to make a module that requires the ability to play short sound effects where the system needs it, then you can write one of these classes and use the singleton mode to make it available globally. As for the Singleton, I have also written a simple introduction, which is not introduced here. Of course, not using singleton mode is completely fine.
chaudioplayer.h//Created by Huangcharlie on 3/26/15. #import <Foundation/Foundation.h> #import < audiotoolbox/audiotoolbox.h> #import "SynthesizeSingleton.h" @interface chaudioplayer:nsobject{}def_singleton_ For_class (Chaudioplayer);//Play System vibration of device-(void) Updatewithvibration;//play system sound with ID, more D Etail in System sound list//system sound list at://https://github.com/TUNER88/iOSSystemSoundsLibrary//check for certain Sound if needed-(void) Updatewithsoundid: (systemsoundid) soundid;//play resource sound, need to import resource into Proje ct-(void) Updatewithresource: (nsstring*) resourcename OfType: (nsstring*) type;//Action of play-(void) play; @end// chaudioplayer.m//Created by Huangcharlie on 3/26/15. #import "CHAudioPlayer.h" @interface Chaudioplayer () @property ( nonatomic,assign) Systemsoundid Soundid, @end @implementation chaudioplayerimpl_singleton_for_class (CHAudioPlayer) ;//vibration-(void) updatewithvibration{Self.soundid = KsystemsoundId_vibrate;} -(void) Updatewithsoundid: (systemsoundid) soundid{self.soundid = Soundid;} Sound of imported resouces, like wav-(void) Updatewithresource: (nsstring*) resourcename OfType: (nsstring*) type{[self Dispose]; NSString *path = [[NSBundle mainbundle] Pathforresource:resourcename Oftype:type]; if (path) {//register sound to system nsurl* URL = [Nsurl Fileurlwithpath:path]; Cfurlref Infileurl = (__bridge cfurlref) URL; Systemsoundid Tempsoundid; Osstatus error = Audioservicescreatesystemsoundid (Infileurl, &tempsoundid); if (Error = = kaudioservicesnoerror) Self.soundid = Tempsoundid; }}-(void) play{audioservicesplaysystemsound (Self.soundid);} -(void) dispose{audioservicesdisposesystemsoundid (Self.soundid);} @end
Here is a place to pay attention to! If you want to use your own resources to play, you will use the Updatewithresource. Where the following two lines of code are written separately, there is no problem. If written together, it is likely to cause crash for asynchronous reasons or for other reasons. Therefore, the following should be written separately.
Register sound to system nsurl* URL = [Nsurl Fileurlwithpath:path]; Cfurlref Infileurl = (__bridge cfurlref) URL;
The use of the concrete is very simple. Use update where you need to register your voice ... Use play in place of play
iOS development: Make a system sound! Make Your own voice!