【发布时间】:2014-06-09 16:21:04
【问题描述】:
尝试实现一个简单的音效在应用后台播放。代码基于此处的答案:Best way to play simple sound effect in iOS。
- (void) viewDidLoad {
NSString *path = [[NSBundle mainBundle] pathForResource:@"poke_sound" ofType:@"mp3"];
NSURL *pathURL = [NSURL fileURLWithPath : path];
SystemSoundID audioEffect;
AudioServicesCreateSystemSoundID((CFURLRef) CFBridgingRetain(pathURL), &audioEffect);
AudioServicesPlaySystemSound(audioEffect);
}
当我在模拟器中运行应用程序时不会播放噪音。感谢您的帮助!
注意:我使用的是 xcode 6 beta,所以谁知道那里会弹出什么错误
【问题讨论】:
标签: ios objective-c audio