Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue in including AVAudioPlayer

Tags:

iphone

I'm trying to use this class as

AVAudioPlayer *newPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL: fileURL error: nil];

And getting this compiler error

error: AVAudioPlayer.h no such file or directory

I have added #import "AVAudioPlayer.h at the beginning of the .m file

Could you let me know how can I fix it?

Thanks

like image 763
ebaccount Avatar asked May 25 '09 22:05

ebaccount


3 Answers

Instead of

#import "AVAudioPlayer.h"

Try

#import <AVFoundation/AVAudioPlayer.h>

like image 151
Johann Avatar answered Nov 19 '22 10:11

Johann


Add the AVFoundation framework to your project.

like image 38
Rhythmic Fistman Avatar answered Nov 19 '22 09:11

Rhythmic Fistman


The problem is in the fact that as the Fistman said, you probably did not add the Framework to your project. You need to go to the Frameworks folder (in your project tree on the left side, usually just bellow the Resources folder), right click on Frameworks->Add->Existing Frameworks..' and pick AVFoundation from the list. Notice that by default XCode will open the frameworks folder of your set Active SDK and so it must be at least OS 2.2 in order to show up (that's the earliest version when apple released it). Once you added the framework, it should compile and link and you wouldn't have to add the h files manually.

Hope it helped, -Adi

like image 3
Adi Avatar answered Nov 19 '22 08:11

Adi