ios - 我是否需要在 Thread 中运行 AudioServicesCreateSystemSoundID

标签 ios objective-c xcode ios6

我正在使用 AudioServicesCreateSystemSoundID 来播放声音,它工作正常,除非我不确定我是否需要在线程 block 上运行它,或者它本身在它自己的线程上运行。

我只是担心如果它在主线程上运行,它可能会使我的应用程序没有响应。

NSURL *tapSound   = [[NSBundle mainBundle] URLForResource: @"mysound"
                                                withExtension: @"aiff"];

    // Store the URL as a CFURLRef instance
    //   soundFileURLRef = (__bridge CFURLRef) tapSound ;

    // Create a system sound object representing the sound file.

     SystemSoundID  soundFileObject;

    AudioServicesCreateSystemSoundID (

                                      (__bridge_retained CFURLRef) tapSound,
                                      &soundFileObject
                                      );
    // AudioServicesPlayAlertSound (soundFileObject);
    AudioServicesPlaySystemSound (soundFileObject);

最佳答案

声音将异步播放。您不需要在它自己的线程中运行它。

关于ios - 我是否需要在 Thread 中运行 AudioServicesCreateSystemSoundID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14820772/

相关文章:

iphone - 突出显示单个烛条的核心图

html - 在 iphone 上使用 html/css 输入焦点问题

ios - 在 UITableView 中使用 UISearchController 并在单元格选择上展开 segue

c++ - 是否有可以从 C++/Objective-C 代码调用的与 Mac OS X "open"命令等效的命令?

ios - 如何使用主 ID 检查 sqlite 表中的数据

ios - 在iOS App Store上提交的应用程序:websocket连接失败

swift - 如何在iOS Swift的iframe中加载本地目录?

ios - CocoaPods 和 Swift - 值得信赖吗?

ios - 如何在 iOS 上下载 LIVE HLS m3u8 流

ios - 标签中的图片(Swift)