我正在使用 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/