【问题标题】:iPhone - Code of system soundsiPhone - 系统声音代码
【发布时间】:2011-03-11 13:21:18
【问题描述】:

你知道我在哪里可以找到指向 iOS 系统声音的常量列表,以便我能够将它们提供给 AudioServicesCreateSystemSoundID 方法吗?

【问题讨论】:

    标签: iphone system audio


    【解决方案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        
    };
    

    希望这会有所帮助。

    【讨论】:

    • 谢谢,但是我们可以在 Web 上显示的示例中找到所有这些名称,例如:developer.apple.com/library/ios/#samplecode/SysSound/Listings/…
    • 你指的是哪些名字?
    • "TAP" in --> NSURL *tapSound = [[NSBundle mainBundle] URLForResource: @"tap" withExtension: @"aif"]; // 将 URL 存储为 CFURLRef 实例 self.soundFileURLRef = (CFURLRef) [tapSound retain]; // 创建一个代表声音文件的系统声音对象。 AudioServicesCreateSystemSoundID (soundFileURLRef, &soundFileObject);我在网络示例中发现了许多其他人
    • tap 是添加到应用程序包中的资源 - SysSound。它在资源下的声音文件夹中 - tap.aif
    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 2011-08-25
      • 1970-01-01
      • 1970-01-01
      • 2012-07-17
      • 2012-10-18
      • 1970-01-01
      • 2010-11-12
      • 1970-01-01
      • 2012-03-22
      相关资源
      最近更新 更多