Hello,
Having a bit of trouble using AVAudioPlayer, when i build and run the application I get the error (Symbol(s) not found) which i can't figure out why. My searches have found nothing relevant.
Code and errors:
Header.
Main.
Error.
Any help would be appreciated,
Thanks,
Tom
Having a bit of trouble using AVAudioPlayer, when i build and run the application I get the error (Symbol(s) not found) which i can't figure out why. My searches have found nothing relevant.
Code and errors:
Header.
Code:
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
#import "Settings.h"
@interface FinalProjectViewController : UIViewController {
UIButton *myButton;
AVAudioPlayer *audioPlayer;
}
@property (nonatomic, retain) UIButton *myButton;
@property (nonatomic, retain) AVAudioPlayer *audioPlayer;
-(IBAction) playButtonPressed;
-(IBAction) pauseButtonPressed;
-(IBAction) settingsPressed;
@end
Main.
Code:
#import "FinalProjectViewController.h"
@implementation FinalProjectViewController
@synthesize myButton;
@synthesize audioPlayer;
- (void)viewDidLoad {
[super viewDidLoad];
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"SecretAgent" ofType:@"mp3"];
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:filePath];
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:nil];
[filePath release];
[fileURL release];
[audioPlayer prepareToPlay];
}
-(IBAction) playButtonPressed {
[audioPlayer play];
}
-(IBAction) pauseButtonPressed {
[audioPlayer pause];
}
-(IBAction) settingsPressed {
Settings *myOtherView = [[Settings alloc] init];
myOtherView.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:myOtherView animated:YES];
[myOtherView release];
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
[myButton release];
[audioPlayer release];
}
@end
Error.
Code:
Undefined symbols:
"_OBJC_CLASS_$_AVAudioPlayer", referenced from:
objc-class-ref-to-AVAudioPlayer in FinalProjectViewController.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Any help would be appreciated,
Thanks,
Tom