我是一个在XCode中使用声音的新手,我正在使用音效。我想要一个音效,我知道对于音效你应该使用音频工具箱框架,代码是什么?我如何编码它,变量和属性是什么?
发布于 2011-07-17 17:32:05
首先,将声音转换为lei16 caf。Here's a good write up解释了为什么应该使用该格式。
afconvert -d LEI16 -f caff /path/to/mp3-or-wav-or-whatever这是播放它的代码。
// I usually store "mySound" in an instance variable in the view
// controller init
CFURLRef mySoundUrl = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("my_sound"), CFSTR("caf"), NULL);
SystemSoundID mySound;
AudioServicesCreateSystemSoundID(mySoundUrl, &mySound);
CFRelease(mySoundUrl);
// Plays the sound.
AudioServicesPlaySystemSound(mySound);https://stackoverflow.com/questions/6689368
复制相似问题