I just want to play a little ding on when the splash screen loads. I’m guesing that goes in the RootViewControler.m under viewDidLoad. As for playing the audio file I’m googled and found a lot of things I haven’t been able to make work.
What type of audio file should it be? wav mp3 etc. or does it matter.
I’m not sure what ofType@”caf” is, but here is what I have found, when I try it I get AVAudioplayer undeclared (which I’m thinking is a total newb error but don’t know):
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
NSURL* musicFile = [NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:@"click"
ofType:@"caf"]];
AVAudioPlayer *click = [[AVAudioPlayer alloc] initWithContentsOfURL:musicFile error:nil];
[click play];
[click release];
[super viewDidLoad];
}
Thank you for any help,
R
From the Apple Documentation :
pathForResource:ofType:
Returns the full pathname for the resource identified by the specified name and file extension.
The program looks for a file called click.caf in your main bundle. The warning about AVPlayer being undeclared means that you have to add the AVFoundationFramework to your project and import the proper
.h– file with#import <AVFoundation/AVAudioPlayer.h>.