【发布时间】:2013-03-10 15:55:53
【问题描述】:
我正在制作一个小型 iOS 游戏,并且已经完成了一切,除了声音。我检查了文件格式,尝试了 .wav 和 .aiff ,但它们都不起作用。相关代码如下:
.h文件:
#import <AudioToolbox/AudioToolbox.h>
@public SystemSoundID mBeep;
NSString* path;
NSURL* url;
.m文件:
path = [[NSBundle mainBundle]pathForResource:@"hit" ofType:@"wav"];
url = [NSURL URLWithString:path];
AudioServicesCreateSystemSoundID((CFURLRef)url, &mBeep);
AudioServicesPlaySystemSound(mBeep); //Gets called, doesn't play
如果我使用其中一个未记录的 ID,例如 1103 和 AudioServicesPlaySystemSound,则声音播放正常。
我很确定我的文件没问题,因为同一个 .wav 文件在 Android、VLC、iTunes 等设备上都能完美运行。
有谁知道我做错了什么?
【问题讨论】: