【发布时间】:2012-11-27 23:30:24
【问题描述】:
对于播放快速声音,我更喜欢 SystemSound 而不是 AudioPlayer,因为加载时间更快。但是现在我已经升级到 Xcode 4.5.2 并且使用 ARC 我的代码来播放音频 sn-ps 不再有效。请参阅下面的完整代码。我得到的错误来自以下行: AudioServicesCreateSystemSoundID((CFURLRef)filePath, &soundID);我收到带有以下错误消息的红色错误:Cast of Objective type NSURL to C pointer type CFURL (aka const dtruct)。有什么想法可以替换这条线吗??`
NSString *path = [NSString stringWithFormat:@"%@%@", [[NSBundle mainBundle] resourcePath], @"/click.mp3"];
SystemSoundID soundID;
NSURL *filePath = [NSURL fileURLWithPath:path isDirectory:NO];
// here is the problem line
AudioServicesCreateSystemSoundID((CFURLRef)filePath, &soundID);
AudioServicesPlaySystemSound(soundID);
【问题讨论】:
-
试试
AudioServicesCreateSystemSoundID((__bridge CFURLRef)filePath, &soundID); -
@RoboticCat - 感谢您的尝试,但我尝试了并收到链接器错误消息 - 还有其他想法吗??