Reputation: 1
Hi i am trying to play many sounds using AVAudioPlayer and foundation. The code is this
- (IBAction)pushButton19 {
NSString *path = [[NSBundle mainBundle] pathForResource:@"The Terminator" ofType:@"mp3"];
AVAudioPlayer* theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
theAudio.delegate = self;
[theAudio play];
}
- (IBAction)pushButton20 {
NSString *path = [[NSBundle mainBundle] pathForResource:@"The Wizard of Oz" ofType:@"mp3"];
AVAudioPlayer* theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
theAudio.delegate = self;
[theAudio play];
}
on the line theAudio.delegate = self;
it says
class * does not implement the protocol
as well as
Semantic Issue Assigning to ID from incompatible type MainView *
what do i need to do to fix it and can u show me the correct code as im a noob at this?
Upvotes: 0
Views: 208
Reputation: 1595
Your controller must conforms to the AVAudioPlayerDelegate protocol and implements its necessary methods. This is a sample code for playing sound.
Upvotes: 3