I am trying to play a button click sound,also that i should be able to manage click sound along with volume button.
What i have done is Added AVFoundationFramework to project,
in .h file
#import <AVFoundation/AVAudioPlayer.h> #import <AVFoundation/AVFoundation.h>
in .m file under button click method
NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"sound1" ofType:@"mp3"]; NSURL *soundUrl = [NSURL fileURLWithPath:soundPath]; AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithURL:soundUrl]; [player play];
but i get the above error.Any help would be appreciated.Answer1:
It's <a href="https://developer.apple.com/library/ios/DOCUMENTATION/AVFoundation/Reference/AVAudioPlayerClassReference/Reference/Reference.html#//apple_ref/occ/instm/AVAudioPlayer/initWithContentsOfURL%3aerror%3a" rel="nofollow">"
initWithContentsOfURL:"</a> not "
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:soundUrl];