问题描述
我有一个使用AVPlayer的视图控制器。此视图控制器可以加载模态视图控制器,用户可以使用AVAudioRecorder录制音频。
I have a view controller that uses AVPlayer. this view controller can load a modal view controler where the user can record audio using AVAudioRecorder.
这是发生的事情:
如果用户使用[AVPLayer play]在第一个控制器中播放合成,AVAudioRecorder将不会在模态视图控制器中录制。没有错误,但AVAudioRecorder返回的当前时间是0.0;
if the user plays the composition in the fist controller with [AVPLayer play] the AVAudioRecorder will not record in the modal view controller. there are no errors but the current time returned by AVAudioRecorder is 0.0;
如果用户解除模态对话框并重新加载它。 AVAudioRecorder工作正常。
if the user dismisses the modal dialog and reloads it. AVAudioRecorder works fine.
这可以重复
AVAudioRecorder在[AVPlayer播放]调用后第一次调用
this can be repeated over and overAVAudioRecorder does not work the first time it is invoked after a [AVPlayer play] call
我已经和它斗争了几天,只是重新组织了与AVPlayer和AVAudioRecorder相关的代码,它仍然表现得很奇怪。
I have been fighting with this for days and just have reorganized my code related to both AVPlayer and AVAudioRecorder and it's still acting weird.
非常感谢任何帮助或指针
Any help or pointer is much appreciated
提前致谢
Jean-Pierre
Jean-Pierre
推荐答案
我也遇到了同样的问题,这就是我找到的解决方案。
I've been having the same problem too, and this is the solution I found.
录制时,在 AVAudioRecord
初始化后写下此行代码:
When recording, write this line code after AVAudioRecord
is initialized:
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryRecord error:NULL];
然后调用记录
方法。
这篇关于iPhone SDK:调用[AVPlayer播放]后AVAudioRecorder不会录制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!