我正在实现 AudioToolbox 框架来尝试播放声音效果。这是我的代码:我声明了一个名为 explode 的 SystemSoundID
NSURL *explodeURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Explosion" ofType:@"wav"]];
AudioServicesCreateSystemSoundID((__bridge CFURLRef)
explodeURL, explode);
[self performSelector:@selector(playsfx) withObject:nil afterDelay:2.0];
-(void)playsfx {
AudioServicesPlaySystemSoundID(explode)
}
但由于某种原因,声音永远不会播放。