首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >找不到“‘AudioUnit/AudioUnit.h”文件

找不到“‘AudioUnit/AudioUnit.h”文件
EN

Stack Overflow用户
提问于 2012-08-11 00:05:00
回答 2查看 1.6K关注 0票数 2

我正在使用Audiotoolbox

.h文件

代码语言:javascript
复制
#import <UIKit/UIKit.h>
#import <AudioToolbox/AudioToolbox.h>

@interface ViewController : UIViewController {

}

-(IBAction)buttonPressedWithSound:(id)sender;

@end

在.m文件中

代码语言:javascript
复制
-(IBAction)buttonPressedWithSound:(id)sender {

int randomSoundNumber = arc4random() % 4; //random number from 0 to 3

NSLog(@"random NR = %i", randomSoundNumber);

NSString *effectTitle;

switch (randomSoundNumber) {
    case 0:
        effectTitle = @"Come at me BRO!";
        break;

    default:
        break;
}

SystemSoundID soundID;

NSString *soundPath = [[NSBundle mainBundle] pathForResource:effectTitle ofType:@"mp3"];
NSSound *sound = [[[NSSound alloc] initWithContentsOfFile: soundPath byReference: NO]       autorelease];

[sound play];

AudioServicesCreateSystemSoundID ((CFURLRef)CFBridgingRetain(soundUrl), &soundID);
AudioServicesPlaySystemSound(soundID);
}

但是当我在我的iphone上运行的时候,在AUGraph.h的日志中没有找到它右边的#include AudioUnit/AudioUnit.h和'AudioUnit/AudioUnit.h‘文件。

我如何解决这个问题才能在我的手机上运行它?

EN

回答 2

Stack Overflow用户

发布于 2012-08-11 03:58:33

正如stackmonster所说的,确保它在Build Phases>Link Binary with Library中,你还需要将它包含在你试图使用它的类中(也许也可以尝试包含audioUnit,但不明白为什么你也会这样做)

你也可以尝试使用AVAudioPlayer,这对你来说可能更简单(我知道对我来说是这样)

代码语言:javascript
复制
AVAudioPlayer *theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:NULL];

theAudio.volume = 1.0;

theAudio.delegate = self;

[theAudio prepareToPlay];

[theAudio play];
票数 1
EN

Stack Overflow用户

发布于 2012-08-11 00:11:40

将音频工具箱框架添加到构建Phases...linked库中的应用程序中

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11905366

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档