iPhone 播放声音有问题?

发布于 2024-09-17 00:51:23 字数 468 浏览 2 评论 0原文

这段代码有什么问题?我以前用过它,但现在收到这些警告...

警告:从不兼容的指针类型传递“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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

泪痕残 2024-09-24 00:51:23

您的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文