これは可能な限り単純な AVAudioPlayer コードであり、再生に失敗しているだけです。エラーはなく、コンソールには何もありません。URL文字列をそこにないものに変更したかのように、ファイルは確実に見つかり、クラッシュします。ここで何が間違っていますか?デリゲートの有無にかかわらず、prepareToPlay の有無にかかわらず試してみましたが、何も得られません。サウンドファイルもいろいろ試しました。本当にこれで私の髪を引き裂きます!
@implementation ViewController
- (IBAction)playSound:(id)sender
{
NSURL *soundLocation = [[NSURL alloc] initWithString:@"Lot01.wav"];
AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:soundLocation error:nil];
[audioPlayer setDelegate:self];
[audioPlayer play];
}
@end