1
loading 2014-04-03 18:41:38 +08:00 via iPhone
选择“静音”,然后开av,结果…啊,呃…
去你妹的开发者 |
4
tonyup 2014-04-03 22:35:26 +08:00 1
Silent mode是允许播放音频的(例如播放音乐的需求)。
注意三点: 1. 在Info.plist中加入UIBackgroundModes audio键值 2. 设置Audio session为AVAudioSessionCategoryPlayback(还有其他几个模式也可支持,具体见官方文档) 3. 音量不能为0(Mute) 官方文档: https://developer.apple.com/library/ios/documentation/Audio/Conceptual/AudioSessionProgrammingGuide/AudioSessionCategoriesandModes/AudioSessionCategoriesandModes.html#//apple_ref/doc/uid/TP40007875-CH10-SW1 |
6
parkman OP @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]; 设置了音量为什么还不能正常播放 |
7
tonyup 2014-04-04 16:37:36 +08:00
如果是Show Raw key/value模式下,在UIBackgroundModes中添加audio键值。否则在Required background modes中添加App plays audio or streams audio/video using AirPlay键值。
|