【发布时间】:2010-08-29 00:01:58
【问题描述】:
我习惯于创造这样的声音:
NSString *explosionsoundpath = [[NSBundle mainBundle] pathForResource:@"explosion" ofType:@"caf"];
CFURLRef explosionurl = (CFURLRef ) [NSURL fileURLWithPath:explosionsoundpath];
AudioServicesCreateSystemSoundID (explosionurl, &explosion1a);
AudioServicesCreateSystemSoundID (explosionurl, &explosion1b);
其中explosion1a 和explosion1b 是在.h 文件中声明的实例变量:
SystemSoundID explosion1a;
每当我尝试在这样的数组中进行此过程时
NSString *plasmasoundpath = [[NSBundle mainBundle] pathForResource:@"plasmasound" ofType:@"caf"];
CFURLRef plasmaurl = (CFURLRef ) [NSURL fileURLWithPath:plasmasoundpath];
SystemSoundID plasmalaunch1;
AudioServicesCreateSystemSoundID (plasmaurl, &plasmalaunch1);
[self.plasmasounds addObject:plasmalaunch1];
我收到警告:
"Passing argument 1 of addObject makes pointer from integer without a cast.
如果我在 addObject 参数中的 Plaslaunch1 之前放置 & 符号,我会得到一个
incompatible pointer type warning.
我正在尝试创建一组音效,以后可以通过调用来播放:
SystemSoundID sound = [self.plasmasounds objectAtIndex:i];
AudioServicesPlaySystemSound(sound);
感谢有关如何使这项工作(或解决此问题的更好方法)的建议!
【问题讨论】:
-
为什么这是一个社区维基?
标签: iphone objective-c xcode audio audiotoolbox