2011-03-11 160 views
5

您是否知道我可以在哪里找到指向iOS系统声音的常量列表,以使我能够将它们提供给AudioServicesCreateSystemSoundID方法?iPhone - 系统声音代码

回答

1

这是AudioServices.h

//================================================================================================== 
#pragma mark AudioServices Constants 

/*! 
    @enum   AudioServices constants 
    @abstract  Constants for use with System Sound portion of the AudioServices APIs. 
    @constant  kSystemSoundID_UserPreferredAlert 
         Use this constant with the play sound APIs to 
         playback the alert sound selected by the User in System Preferences. 
    @constant  kSystemSoundID_Vibrate 
         Use this constant with the play sound APIs to vibrate the device 
         - iPhone only 
          - on a device with no vibration capability (like iPod Touch) this will 
          do nothing 
    @constant  kSystemSoundID_FlashScreen 
         Use this constant with the play sound APIs to flash the screen 
         - Desktop systems only 
*/ 
enum 
{ 
#if TARGET_OS_IPHONE 
    kSystemSoundID_Vibrate    = 0x00000FFF 
#else 
    kSystemSoundID_UserPreferredAlert = 0x00001000, 
    kSystemSoundID_FlashScreen   = 0x00000FFE, 
     // this has been renamed to be consistent 
    kUserPreferredAlert  = kSystemSoundID_UserPreferredAlert 
#endif   
}; 

希望这有助于。

+0

谢谢,但是我们可以在Web上显示的示例中找到所有这些名称,如下所示:https://developer.apple.com/library/ios/#samplecode/SysSound/Listings/Classes_SysSoundViewController_m.html #// apple_ref/doc/uid/DTS40008018-Classes_SysSoundViewController_m -DontLinkElementID_6 – Oliver 2011-03-11 13:59:34

+0

你指的是哪个名字? – Viraj 2011-03-11 14:05:24

+0

“TAP”in - > NSURL * tapSound = [[NSBundle mainBundle] URLForResource:@“tap” withExtension:@“aif”]; //将URL保存为CFURLRef实例 self.soundFileURLRef =(CFURLRef)[tapSound retain]; //创建一个代表声音文件的系统声音对象。 AudioServicesCreateSystemSoundID( soundFileURLRef, &soundFileObject );我在网页上发现了很多其他的例子 – Oliver 2011-03-11 14:08:16

0

我知道的唯一一个是在AudioToolbox/AudioServices.h中的kSystemSoundID_Vibrate