我有一个非常简单的应用程序,我已经建立了测试AVAudioPlayer。我有一个16s aif文件,可以在我的Mac上播放。把它放在一个简单的应用程序,并在我的iPhone上运行,但没有声音。向对象发送'play'会返回成功,并且16秒后audioPlayerDidFinishPlaying成功返回。仍然没有声音。已经检查过iPhone上的音量,很好。已经检查过,以确保我的AVAudioPlayer对象的音量设置为1.0 - 它确实如此。任何人都可以帮忙吗?AVAudioPlayer返回成功,但没有声音从设备
这里是我的代码
NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"Soothing" ofType:@"aif"];
NSURL *playURL = [NSURL fileURLWithPath:soundPath];
NSError *error;
self.myAudioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:playURL error:&error];
NSLog(@"About to play sound");
self.myAudioPlayer.delegate = self;
[self.myAudioPlayer prepareToPlay];
bool success = [self.myAudioPlayer play];
if (!success) {
NSLog(@"Failed to play file");
} else NSLog(@"Looks like it succeded");
没有这样的运气 - 错误是零 – CodeBuddy