以下は、SnareHitSample.wavファイルを再生できない私のコードです。どこが間違っているのかわかりません。
-(void)playAudioFiles
{
NSString * path;
AVAudioPlayer * snd;
NSError * err;
NSString *name;
name = @"SnareHitSample.wav";
path = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:name];
if ([[NSFileManager defaultManager] fileExistsAtPath:path]) {
NSURL * url = [NSURL fileURLWithPath:path];
snd = [[AVAudioPlayer alloc] initWithContentsOfURL:url
error:&err] ;
if (! snd) {
NSLog(@"Sound named '%@' had error %@", name, [err localizedDescription]);
} else {
[snd prepareToPlay];
}
} else {
NSLog(@"Sound file '%@' doesn't exist at '%@'", name, path);
}
}