iPhone 播放声音有问题?
这段代码有什么问题?我以前用过它,但现在收到这些警告...
警告:从不兼容的指针类型传递“AudioServicesCreateSystemSoundID”的参数 2
警告:传递“AudioServicesPlaySystemSound”的参数 1 从指针生成整数而不进行强制转换
-(void)playfireSound{
NSString *path = [[NSBundle mainBundle] pathForResource:@"fireSound" ofType:@"wav"];
NSURL *url = [NSURL fileURLWithPath:path];
AudioServicesCreateSystemSoundID((CFURLRef) url, &fireSound);
AudioServicesPlaySystemSound(fireSound);
}
What's wrong with this code? I've used it before but now I'm getting these warnings...
warning: passing argument 2 of 'AudioServicesCreateSystemSoundID' from incompatible pointer type
warning: passing argument 1 of 'AudioServicesPlaySystemSound' makes integer from pointer without a cast
-(void)playfireSound{
NSString *path = [[NSBundle mainBundle] pathForResource:@"fireSound" ofType:@"wav"];
NSURL *url = [NSURL fileURLWithPath:path];
AudioServicesCreateSystemSoundID((CFURLRef) url, &fireSound);
AudioServicesPlaySystemSound(fireSound);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的 fireSound 变量声明可能不适合与此 API 一起使用。也许您将其声明为某种类型的对象,而不是 int 类型的 SystemSoundID。
Your declaration of your fireSound variable is probably incorrect for use with this API. Maybe you declared it as an object of some sort, instead of as an SystemSoundID, which is of type int.