@
tonyup 1. 在Info.plist中加入UIBackgroundModes 加入了值 App plays audio or streams audio/video using AirPlay
2. 3.
NSError *audioSessionError = nil;
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
if ([audioSession setCategory:AVAudioSessionCategoryPlayback
error:&audioSessionError]){
NSLog(@"Successfully set the audio session.");
} else {
NSLog(@"Could not set the audio session");
}
NSString *fileName = [NSString stringWithFormat:@"warning_yellow"];
NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:fileName ofType:@"wav"];
NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
self.audioPlayerRed = [[AVAudioPlayer alloc] initWithContentsOfURL:soundFileURL error:nil];
self.audioPlayerRed.delegate = self;
self.audioPlayerRed.meteringEnabled = YES;
self.audioPlayerRed.volume = 1.0;
[self.audioPlayerRed play];
设置了音量为什么还不能正常播放