ios流式MP3和录制声音
问题描述:
问题:通过http流式传输音频后无法录制声音。ios流式MP3和录制声音
这我遇到的问题是,我再也不能记录声音使用本指南流MP3后:http://cocoawithlove.com/2008/09/streaming-and-playing-live-mp3-stream.html
我可以录制声音完美的罚款之前,我流的任何MP3。只有在使用指导我流mp3后,我的ios应用程序不能再录制声音。
我想知道你们之前是否有可能遇到过这个问题,或者对此问题发生的原因有任何预感?我会继续发布我的代码进行录制,以防万一您需要查看它。
在我流任何mp3之前,audioRecorderDidFinishRecording始终在记录完成后触发。
i流mp3之后,audioRecorderDidFinishRecording在记录完成后永不开火。
非常感谢您的帮助。
// #########################
NSURL *soundFileUrl = [NSURL fileURLWithPath:self.recordFilePath];
NSDictionary *recordSettings = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:kAudioFormatLinearPCM], AVFormatIDKey,
[NSNumber numberWithInt:AVAudioQualityMax], AVEncoderAudioQualityKey,
[NSNumber numberWithInt:24], AVEncoderBitRateKey,
[NSNumber numberWithInt:1], AVNumberOfChannelsKey,
[NSNumber numberWithFloat:22050.0f], AVSampleRateKey,
nil];
NSError *error = nil;
self.recorder = [[AVAudioRecorder alloc] initWithURL:soundFileUrl settings:recordSettings error:&error];
if (error) {
NSLog(@"%@", error);
} else{
self.recorder.delegate = self;
[self.recorder prepareToRecord];
[self.recorder record];
self.recordCountdown = [NSTimer scheduledTimerWithTimeInterval:(1.0/1.0) target:self selector:@selector(updateLabelCountdown) userInfo:nil repeats:YES];
}
// delegate for finish recording with success and failure
- (void) audioRecorderDidFinishRecording:(AVAudioRecorder *)recorder successfully:(BOOL)flag {
NSLog(@"record did finish flag - %d", flag);
}
- (void) audioRecorderEncodeErrorDidOccur:(AVAudioRecorder *)recorder error:(NSError *)error {
NSLog(@"error record - %@", [error localizedDescription]);
}
答
试试这个
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
参考iPhone SDK: AVAudioRecorder will not record after calling [AVPlayer play]
没有ü找到任何解决办法? – yogs
是的。我最终没有使用这个外部库。我结束了使用UIWebView流音频。 我认为外部库占据了一些重要的音频资源,并且在完成播放音频文件后从不释放它。 –