0

我无法播放音频。我有一个我调用的例程(见下文)。我没有错误。我已验证音频文件在项目中并发出声音。我在例程中的 NSLogs 告诉我声音正在播放。扬声器/音量都很好。有什么想法吗?

-(void) spaceBackgroundSound {

NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/spaceBackground.aiff", [[NSBundle mainBundle] resourcePath]]];

NSError *error;


AVAudioPlayer *audioSpaceBackgroundSound;
audioSpaceBackgroundSound = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
audioSpaceBackgroundSound.numberOfLoops = -1;

audioSpaceBackgroundSound.volume = 1;
if (audioSpaceBackgroundSound == nil){
    NSLog(@"Got and error here");
}

else

NSLog(@"Background Sound Played");
[audioSpaceBackgroundSound play];

}
4

0 回答 0